Problems linking 4.0

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems linking 4.0

Bren Lynne
Hi all,

Apologies as this appears to be an often asked question, but none of the
hits in the archive solved my problem, and I'm really scratching my head
over what appears to be a relatively simple issue.

I am trying to build the Dead Justice project, a game that was recently
released into the open source community by Cat Mother games.
http://catmother.sourceforge.net/

The game uses LUA 4.0 as a scripting language.

I downloaded LUA 4.0 and built in no problem, creating lua.lib and/or
luad.lib.

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.

I've tried several things, including building from scratch, turning off
precompiled headers, wrapping the lua.h include in extern "C", various ways
of specifying the lib dir, verifying lualib.h is included, etc, all to no
avail.  I do notice that LUALIB_API does not seem to be defined in the LUA
build settings, but defining it generates other compiler errors.

Any help would be appreciated.  Thanks!

------------------------

--------------------Configuration: deadjustice - Win32
Debug--------------------
Linking...
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_mathlibopen(struct lua_State *)"
(?lua_mathlibopen@@YAXPAUlua_State@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_unref(struct lua_State *,int)"
(?lua_unref@@YAXPAUlua_State@@H@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_unref(struct lua_State *,int)"
(?lua_unref@@YAXPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_getref(struct lua_State *,int)" (?lua_getref@@YAHPAUlua_State@@H@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "int
__cdecl lua_getref(struct lua_State *,int)"
(?lua_getref@@YAHPAUlua_State@@H@Z)
scriptd.lib(lua_ex.obj) : error LNK2001: unresolved external symbol "int
__cdecl lua_getref(struct lua_State *,int)"
(?lua_getref@@YAHPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_strlibopen(struct lua_State *)"
(?lua_strlibopen@@YAXPAUlua_State@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_setglobals(struct lua_State *)"
(?lua_setglobals@@YAXPAUlua_State@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_getglobal(struct lua_State *,char const *)"
(?lua_getglobal@@YAXPAUlua_State@@PBD@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_ref(struct lua_State *,int)" (?lua_ref@@YAHPAUlua_State@@H@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "int
__cdecl lua_ref(struct lua_State *,int)" (?lua_ref@@YAHPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_getglobals(struct lua_State *)"
(?lua_getglobals@@YAXPAUlua_State@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_newtable(struct lua_State *)"
(?lua_newtable@@YAXPAUlua_State@@@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_newtable(struct lua_State *)"
(?lua_newtable@@YAXPAUlua_State@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_setglobal(struct lua_State *,char const *)"
(?lua_setglobal@@YAXPAUlua_State@@PBD@Z)
scriptd.lib(Scriptable.obj) : error LNK2001: unresolved external symbol
"void __cdecl lua_setglobal(struct lua_State *,char const *)"
(?lua_setglobal@@YAXPAUlua_State@@PBD@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushcclosure(struct lua_State *,int (__cdecl*)(struct lua_State
*),int)" (?lua_pushcclosure@@YAXPAUlua_State@@P6AH0@ZH@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushusertag(struct lua_State *,void *,int)"
(?lua_pushusertag@@YAXPAUlua_State@@PAXH@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushusertag(struct lua_State *,void *,int)"
(?lua_pushusertag@@YAXPAUlua_State@@PAXH@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_newtag(struct lua_State *)" (?lua_newtag@@YAHPAUlua_State@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "struct
lua_State * __cdecl lua_open(int)" (?lua_open@@YAPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_close(struct lua_State *)" (?lua_close@@YAXPAUlua_State@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_settop(struct lua_State *,int)"
(?lua_settop@@YAXPAUlua_State@@H@Z)
scriptd.lib(Scriptable.obj) : error LNK2001: unresolved external symbol
"void __cdecl lua_settop(struct lua_State *,int)"
(?lua_settop@@YAXPAUlua_State@@H@Z)
scriptd.lib(RestoreStack.obj) : error LNK2001: unresolved external symbol
"void __cdecl lua_settop(struct lua_State *,int)"
(?lua_settop@@YAXPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_call(struct lua_State *,int,int)" (?lua_call@@YAHPAUlua_State@@HH@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_type(struct lua_State *,int)" (?lua_type@@YAHPAUlua_State@@H@Z)
scriptd.lib(Scriptable.obj) : error LNK2001: unresolved external symbol "int
__cdecl lua_type(struct lua_State *,int)" (?lua_type@@YAHPAUlua_State@@H@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "int
__cdecl lua_type(struct lua_State *,int)" (?lua_type@@YAHPAUlua_State@@H@Z)
scriptd.lib(lua_ex.obj) : error LNK2001: unresolved external symbol "int
__cdecl lua_type(struct lua_State *,int)" (?lua_type@@YAHPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_dofile(struct lua_State *,char const *)"
(?lua_dofile@@YAHPAUlua_State@@PBD@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_dostring(struct lua_State *,char const *)"
(?lua_dostring@@YAHPAUlua_State@@PBD@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_dobuffer(struct lua_State *,char const *,unsigned int,char const *)"
(?lua_dobuffer@@YAHPAUlua_State@@PBDI1@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_gettable(struct lua_State *,int)"
(?lua_gettable@@YAXPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_rawget(struct lua_State *,int)"
(?lua_rawget@@YAXPAUlua_State@@H@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_rawget(struct lua_State *,int)"
(?lua_rawget@@YAXPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_rawgeti(struct lua_State *,int,int)"
(?lua_rawgeti@@YAXPAUlua_State@@HH@Z)
scriptd.lib(Scriptable.obj) : error LNK2001: unresolved external symbol
"void __cdecl lua_rawgeti(struct lua_State *,int,int)"
(?lua_rawgeti@@YAXPAUlua_State@@HH@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_rawgeti(struct lua_State *,int,int)"
(?lua_rawgeti@@YAXPAUlua_State@@HH@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_next(struct lua_State *,int)" (?lua_next@@YAHPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushnil(struct lua_State *)" (?lua_pushnil@@YAXPAUlua_State@@@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushnil(struct lua_State *)" (?lua_pushnil@@YAXPAUlua_State@@@Z)
scriptd.lib(lua_ex.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushnil(struct lua_State *)" (?lua_pushnil@@YAXPAUlua_State@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushnumber(struct lua_State *,double)"
(?lua_pushnumber@@YAXPAUlua_State@@N@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushnumber(struct lua_State *,double)"
(?lua_pushnumber@@YAXPAUlua_State@@N@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushstring(struct lua_State *,char const *)"
(?lua_pushstring@@YAXPAUlua_State@@PBD@Z)
scriptd.lib(lua_ex.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushstring(struct lua_State *,char const *)"
(?lua_pushstring@@YAXPAUlua_State@@PBD@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_pushvalue(struct lua_State *,int)"
(?lua_pushvalue@@YAXPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_settable(struct lua_State *,int)"
(?lua_settable@@YAXPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_rawset(struct lua_State *,int)"
(?lua_rawset@@YAXPAUlua_State@@H@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_rawset(struct lua_State *,int)"
(?lua_rawset@@YAXPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_rawseti(struct lua_State *,int,int)"
(?lua_rawseti@@YAXPAUlua_State@@HH@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_rawseti(struct lua_State *,int,int)"
(?lua_rawseti@@YAXPAUlua_State@@HH@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_settag(struct lua_State *,int)"
(?lua_settag@@YAXPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_remove(struct lua_State *,int)"
(?lua_remove@@YAXPAUlua_State@@H@Z)
scriptd.lib(Scriptable.obj) : error LNK2001: unresolved external symbol
"void __cdecl lua_remove(struct lua_State *,int)"
(?lua_remove@@YAXPAUlua_State@@H@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void
__cdecl lua_remove(struct lua_State *,int)"
(?lua_remove@@YAXPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_tag(struct lua_State *,int)" (?lua_tag@@YAHPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "char const
* __cdecl lua_typename(struct lua_State *,int)"
(?lua_typename@@YAPBDPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_iscfunction(struct lua_State *,int)"
(?lua_iscfunction@@YAHPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_equal(struct lua_State *,int,int)" (?lua_equal@@YAHPAUlua_State@@HH@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_lessthan(struct lua_State *,int,int)"
(?lua_lessthan@@YAHPAUlua_State@@HH@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_stackspace(struct lua_State *)" (?lua_stackspace@@YAHPAUlua_State@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "double
__cdecl lua_tonumber(struct lua_State *,int)"
(?lua_tonumber@@YANPAUlua_State@@H@Z)
scriptd.lib(Scriptable.obj) : error LNK2001: unresolved external symbol
"double __cdecl lua_tonumber(struct lua_State *,int)"
(?lua_tonumber@@YANPAUlua_State@@H@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "double
__cdecl lua_tonumber(struct lua_State *,int)"
(?lua_tonumber@@YANPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "char const
* __cdecl lua_tostring(struct lua_State *,int)"
(?lua_tostring@@YAPBDPAUlua_State@@H@Z)
scriptd.lib(lua_ex.obj) : error LNK2001: unresolved external symbol "char
const * __cdecl lua_tostring(struct lua_State *,int)"
(?lua_tostring@@YAPBDPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_isstring(struct lua_State *,int)" (?lua_isstring@@YAHPAUlua_State@@H@Z)
scriptd.lib(Scriptable.obj) : error LNK2001: unresolved external symbol "int
__cdecl lua_isstring(struct lua_State *,int)"
(?lua_isstring@@YAHPAUlua_State@@H@Z)
scriptd.lib(lua_ex.obj) : error LNK2001: unresolved external symbol "int
__cdecl lua_isstring(struct lua_State *,int)"
(?lua_isstring@@YAHPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int
(__cdecl*__cdecl lua_tocfunction(struct lua_State *,int))(struct lua_State
*)" (?lua_tocfunction@@YAP6AHPAUlua_State@@@Z0H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "void *
__cdecl lua_touserdata(struct lua_State *,int)"
(?lua_touserdata@@YAPAXPAUlua_State@@H@Z)
scriptd.lib(Scriptable.obj) : error LNK2001: unresolved external symbol
"void * __cdecl lua_touserdata(struct lua_State *,int)"
(?lua_touserdata@@YAPAXPAUlua_State@@H@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "void *
__cdecl lua_touserdata(struct lua_State *,int)"
(?lua_touserdata@@YAPAXPAUlua_State@@H@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_gettop(struct lua_State *)" (?lua_gettop@@YAHPAUlua_State@@@Z)
scriptd.lib(RestoreStack.obj) : error LNK2001: unresolved external symbol
"int __cdecl lua_gettop(struct lua_State *)"
(?lua_gettop@@YAHPAUlua_State@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_getinfo(struct lua_State *,char const *,struct lua_Debug *)"
(?lua_getinfo@@YAHPAUlua_State@@PBDPAUlua_Debug@@@Z)
scriptd.lib(VM.obj) : error LNK2001: unresolved external symbol "int __cdecl
lua_getstack(struct lua_State *,int,struct lua_Debug *)"
(?lua_getstack@@YAHPAUlua_State@@HPAUlua_Debug@@@Z)
scriptd.lib(Scriptable.obj) : error LNK2001: unresolved external symbol
"void __cdecl lua_error(struct lua_State *,char const *)"
(?lua_error@@YAXPAUlua_State@@PBD@Z)
scriptd.lib(Scriptable.obj) : error LNK2001: unresolved external symbol "int
__cdecl lua_isnumber(struct lua_State *,int)"
(?lua_isnumber@@YAHPAUlua_State@@H@Z)
scriptd.lib(Table.obj) : error LNK2001: unresolved external symbol "int
__cdecl lua_getn(struct lua_State *,int)" (?lua_getn@@YAHPAUlua_State@@H@Z)
exe/deadjusticed.exe : fatal error LNK1120: 51 unresolved externals
Error executing link.exe.

deadjusticed.exe - 83 error(s), 0 warning(s)


Reply | Threaded
Open this post in threaded view
|

Re: Problems linking 4.0

Eric Tetz-2
--- 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