Associate Lua with Visual Studio 2010

We use the Lua (www.lua.org) script so that users can configure our server software written in C ++.

At the moment, we are transferring the 32-bit version of Windows of our project to Visual Studio 2010. As soon as everything works well with VS 2008, we thought that we would have no problems with the update process.

Unfortunately, when we tried to associate lualib (as a dll) with our project in VS 2010, the lua functions could not be found by the linker (error messages are displayed below).

It seems that some calling conventions in 2010 are incorrect, for example, an application may look for lua functions with the prefix "_".

To access the lua functions (written in C) from our project modules (C ++) we use the following:

extern "C" { #include "lua/src/lua.h" #include "lua/src/lualib.h" #include "lua/src/lauxlib.h" } 

The same project compiles and communicates with lualib successfully on VS 2008 and Linux (g ++).

Can anyone help me with this?

  1> dscscript.obj: error LNK2019: unresolved external symbol __imp__luaL_openlibs referenced in function "public: int __thiscall DsCScriptEngine :: Init (void)" ( ?Init@DsCScriptEngine @@ QAEHXZ)

 1> dscscript.obj: error LNK2019: unresolved external symbol __imp__luaL_newstate referenced in function "public: int __thiscall DsCScriptEngine :: Init (void)" ( ?Init@DsCScriptEngine @@ QAEHXZ)

 1> dscscript.obj: error LNK2019: unresolved external symbol __imp__lua_close referenced in function "public: void __thiscall DsCScriptEngine :: Shutdown (void)" ( ?Shutdown@DsCScriptEngine @@ QAEXXZ)

 1> dscscript.obj: error LNK2019: unresolved external symbol __imp__lua_pcall referenced in function "public: long __thiscall DsCScriptEngine :: Execute (char const *)" ( ?Execute@DsCScriptEngine @@ QAEJPBD@Z )

and etc.

+4
source share
1 answer

The missing names reported are correct, this is not a compilation problem. You must refer to the wrong .lib. The name you use does not sound right, it is not "lualib", the current version of the import library is called lua5.1.lib (or lua51.lib, I don’t know what the difference is). Download from here .

+4
source

All Articles