Jump to content
  • Advertisement
Sign in to follow this  
Mushu

ARRGH! Problems linking Lua 5.1

This topic is 4348 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!