ARRGH! Problems linking Lua 5.1

Started by
1 comment, last by Mushu 17 years, 8 months ago
Well, okay. I'm trying to integrate Lua just like everyone else, and am getting linker errors for, essentially, every lua_* function. I'm linking to the library produced by the MSVC (7.1) build script included with the source; the following code generates the following errors:
#include <lua\lua.h>
#include <lua\lauxlib.h>

#pragma comment ( lib, "lua51.lib" )


int main(int argc, char* argv[])
{
	lua_State* L = luaL_newstate();
	
	lua_close(L);
	return 0;
}

// error LNK2019: unresolved external symbol "void __cdecl lua_close(struct lua_State *)"
// error LNK2019: unresolved external symbol "struct lua_State * __cdecl luaL_newstate(void)"


The libs were built using the luavs.bat script included with the Lua source. Ideas?
Advertisement
firstly you want to link the lib before including the headers.
Is this C or C++ code? if the latter you want to prevent name mangling by
Quote:
extern "C"
{
# include "lua.h"
# include "lauxlib.h"
# include "lualib.h"
}


[edit]
Quote:C++ compilation has 3 distinct steps

Very true :)
Quote:Original post by dmail
firstly you want to link the lib before including the headers.

Inconsequential - C++ compilation has 3 distinct steps (preprocessing, compilation, linking) during which the #include and #pragma directives (in this case) are processed in such a way that their order is irrelevant.
Quote:Is this C or C++ code? if the latter you want to prevent name mangling by

C++. Lemmie give that a shot, seems like that's a more probable issue.

EDIT: Yep, that was it. Big thanks <3 <3

This topic is closed to new replies.

Advertisement