Sign in to follow this  
Lith

c++ and lua

Recommended Posts

Lith    429
I have been trying to use lua with c++, but i cant get this basic program to work properly. I tried google but i didnt get the answer This is my code:
#include <stdio.h>

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

lua_State* L;

int main ( int argc, char *argv[] )
{
	L = lua_open();

	luaL_openlibs(L);

	lua_close(L);

	return 0;
}

These are the errors:
main.obj : error LNK2019: unresolved external symbol _lua_close referenced in function _main
main.obj : error LNK2019: unresolved external symbol _luaL_openlibs referenced in function _main
main.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in function _main

I think that unresolved externals are to do with library files and the linker not finding functions and varibles in any file after it's read the header file. But i put all the header files in the right place because it's not complaining about that, i put the 2 lib files that i got with the lua source code with all the other VC++ lib files

Share this post


Link to post
Share on other sites
klee1    166
Well, this is definitely a linking problem...

What is most likely happening is that they are in the VC++ folder, but you still are not telling your program to link with the libraries.

Try adding them in the project properties under Linking:

1)Right-click on your project.
2)Click Properties.
3)On the left find Linker.
4)Under it find and open Input.
5)Add the libraries to "Additional Dependencies."

Hope this helps!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this