lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


--- Bren Lynne wrote:
> The Dead Justice project is definitely finding the library (it
> complains that it can't if I remove it) but I still get the
> linker errors quoted below.

scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol
"void
__cdecl lua_mathlibopen(struct lua_State *)"
(?lua_mathlibopen@@YAXPAUlua_State@@@Z)


lua_mathlibopen@@YAXPAUlua_State@@@Z

--- Bren Lynne wrote:
> The Dead Justice project is definitely finding the library (it
> complains that it can't if I remove it) but I still get the
> linker errors quoted below.

Include Lua headers like this:

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

Why?

> scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol
> "void
> __cdecl lua_mathlibopen(struct lua_State *)"
> (?lua_mathlibopen@@YAXPAUlua_State@@@Z)

The Lua library file contains the function "lua_mathlibopen", but
the linker is looking for a function named
"lua_mathlibopen@@YAXPAUlua_State@@@Z". This is because C++
compilers add parameter type information to the names of functions
to allow function overloading (having more than one function with
the same name). This is usually called 'name mangling'.

You need to tell your C++ compiler that those Lua function are in a
C library and are *not* mangled. You do that by using 'extern "C"'
in the function prototypes, or by wrapping the prototypes thusly:

extern "C" {
  // prototypes
  // for
  // C
  // functions
}

Cheers,
Eric


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com