What am I doing wrong?

Started by
2 comments, last by Tenac 15 years, 10 months ago
Here is the code I was using to make sure I have everything setup right just to test.

#include <stdio.h>
extern "C"
{
 #include <lua.h>
}
 
int main(int argc, char* argv[ ])
{
   lua_State* luaVM = lua_open();
 
   if (NULL == luaVM)
   {
      printf("Error Initializing lua\n");
      return -1;
   }
 
   // Do stuff with lua code.
    
   lua_close( luaVM );
 
   return 0;
}

This was code just copied and pasted from an embedding lua tutorial at gamedev.net Here is the error I get ------ Build started: Project: LuaTest, Configuration: Debug Win32 ------ Compiling... main.cpp c:\documents and settings\justin fluhmann\my documents\c++ projects\luatest\luatest\main.cpp(9) : error C3861: 'luaL_newstate': identifier not found Build log was saved at "file://c:\Documents and Settings\Justin Fluhmann\My Documents\C++ Projects\LuaTest\LuaTest\Debug\BuildLog.htm" LuaTest - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== I'm pretty sure I set the project up right. Windows console project, set my include directory to C:/Lua/include, and my library directory to C:/Lua which is where all the Lua files are stored. I'm using VS2005 Standard if that helps anyone.
Advertisement
extern "C"
{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}

And make sure you have lua's .dll in the executables folder and lua's .lib linked to your project. (I use lua5.1.dll and lua5.1.lib)
ouch, when I include those other header files I get more errors. I'm not using DLL's. I was just using the static library. When you say link the library to the project, you mean set the path of the library files in the project properties right?

------ Build started: Project: LuaTest, Configuration: Debug Win32 ------
Compiling...
main.cpp
Linking...
main.obj : error LNK2019: unresolved external symbol _lua_close referenced in function _main
main.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in function _main
C:\Documents and Settings\Justin Fluhmann\My Documents\C++ Projects\LuaTest\Debug\LuaTest.exe : fatal error LNK1120: 2 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Justin Fluhmann\My Documents\C++ Projects\LuaTest\LuaTest\Debug\BuildLog.htm"
LuaTest - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Download lua5.1.dll and lua5.1.lib. Place the .dll in the same directory that the .exe is in. Then put the .lib in your compiler's lib folder. Then in MSVC go to Project -> Properties -> Configuration Properties -> Linker -> Input. And in "Additional Dependencies" add lua5.1.lib

EDIT: and please put a little information into your title rather than just saying "help", you should say that it's a lua specific problem.

[Edited by - Tenac on June 28, 2008 7:33:25 PM]

This topic is closed to new replies.

Advertisement