Jump to content
  • Advertisement
Sign in to follow this  
kyron21

What am I doing wrong?

This topic is 3704 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

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.

Share this post


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

Share this post


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

Share this post


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

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!