Embedding Lua in Visual C++ 2008
Posted: Sat Dec 06, 2008 9:18 pm
Well, I am making a game engine for Windows with C++, Win32 API, DirectX, and Lua. So far everything has been working fine except for Lua and it's really getting annoying... Anyways, I have downloaded the Lua source code, built it, and i can run any script i put in the lua.exe application (the console app) such as: print("hello"). Here's where my problem is, I have added the src folder in the MSVC++ include directories, and in the library directories. When I try to compile this program:
extern "C" {
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}
int main()
{
lua_State *L = lua_open();
// load the libs
luaL_openlibs(L);
printf("Hello World");
lua_close(L);
return 0;
}
I get the following build log...
1>------ Build started: Project: luatest, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>Linking...
1>main.obj : error LNK2019: unresolved external symbol _lua_close referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _luaL_openlibs referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in function _main
1>C:\Users\Cole\Documents\Visual Studio 2008\Projects\luatest\Debug\luatest.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Users\Cole\Documents\Visual Studio 2008\Projects\luatest\luatest\Debug\BuildLog.htm"
1>luatest - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
WHAT THE HECK IS GOING ON!!! I have looked all over the internet and I cannot find what is wrong!!! Please reply soon.
----------------------------------------------------------------------------------------------------------------------------------------------
Edit- I can now compile it but when i try to run it it says "This application has failed to start because lua5.1.4.dll was not found. Re-installing the application may fix this problem."
extern "C" {
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}
int main()
{
lua_State *L = lua_open();
// load the libs
luaL_openlibs(L);
printf("Hello World");
lua_close(L);
return 0;
}
I get the following build log...
1>------ Build started: Project: luatest, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>Linking...
1>main.obj : error LNK2019: unresolved external symbol _lua_close referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _luaL_openlibs referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in function _main
1>C:\Users\Cole\Documents\Visual Studio 2008\Projects\luatest\Debug\luatest.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Users\Cole\Documents\Visual Studio 2008\Projects\luatest\luatest\Debug\BuildLog.htm"
1>luatest - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
WHAT THE HECK IS GOING ON!!! I have looked all over the internet and I cannot find what is wrong!!! Please reply soon.
----------------------------------------------------------------------------------------------------------------------------------------------
Edit- I can now compile it but when i try to run it it says "This application has failed to start because lua5.1.4.dll was not found. Re-installing the application may fix this problem."