Question

I've been trying to do this for a day. I've read through the documentation, and searched online for help. I just can't seem to figure it out between different versions of boost/lua/luabind used with precompiled headers, and VS2010 vs VS2012.

I found a great website here http://blog.nuclex-games.com/tutorials/cxx/luabind-introduction/ but when I follow those instructions I get LNK2019 errors (I'm assuming because he build luabind/boost/lua for VS2010.

I also found this, http://urbsch.at/?read=1 I took the project and changed the addresses to my boost/lua files and it compiled fine but when I tried to run my project that is using luabind I still received LNK2019 errors.

I'm using visual studios 2012. If someone could list out some step by step instructions I would be so grateful. Including what to download and where and what to add in the project properties. Because at this point I'm sure I'll mess it up if It's not foolproof.

These is one of the 49 errors I often end up with.

1>ScriptManager.obj : error LNK2019: unresolved external symbol _lua_gettop referenced in function "public: __thiscall luabind::adl::index_proxy::index_proxy(class luabind::adl::object const &,struct lua_State *,char const (&)[13])" (??$?0$$BY0N@$$CBD@?$index_proxy@Vobject@adl@luabind@@@adl@luabind@@QAE@ABVobject@12@PAUlua_State@@AAY0N@$$CBD@Z)

Was it helpful?

Solution

Ok, I figured it out (a while ago.) Here is complete, step by step, fool proof instructions on how to get it to work.

1) Download the demo from here http://blog.nuclex-games.com/tutorials/cxx/luabind-introduction/

2) Create a new file (say "Parts") to hold the three parts neccisary for luabind.

3) Open the reference folder from the download above and move those 3 folders to the "Parts" folder you just created.

4) Now you need to recompile new .lib files for Lua and LuaBind. Open the LibrarySources.7z file from the download above.

4) Create a new Visual Studio 2012 project named Lua, open extract all the files from "LibrarySources.7z/lua-5.2.0/src" to the place visual studios usually puts your .cpp and .h files.

5) Add the files to the project (.h files in the header folder of project explorer and .c files in the source folder.)

6) Go to SolutionExplorer->Properties->General->Configuration_Type and set it to Static Library (.lib)

7) Compile the project.

8) Go to the folder debug folder of your lua project and file the lua.lib file you created.

9) Now go to the "Parts" foler you created to "Parts/Lua" You should see 2 folders there that say msvc-10.0-x64/86, create a new one that says msvc-11.0-x86 and put the lua.lib file you just created in that.

10) For luabind you need to do the same thing, however you only need to extract the src folder from luabind to your project.

11) Now in project properties C/C++ -> Additional Include Directories, add "C:/Parts/boost/include" "C:/Parts/lua/include" and "C:/Parts/luabind/include"

12) Now go to Linker->General->Additional Library Directories and add "C:/Parts/lua/msvc-11.0-x86"

13) Now go back to solution explorer->Properties->General and change it to a static lib.

14) Compile that, go to its debug folder and add the luabind.lib you created to the parts/luabind/msvs-11.0-x86 like you did for lua.

15) Now in you're project that you want to use luabind with Go to Properties->C/C++ -> General and add "C:/Parts/boost/include" "C:/Parts/lua/include" and "C:/Parts/luabind/include"

16) Go to properties->linker->general->Additional Library Directories and add the addresses to both .lib files you just made.

Fin.

OTHER TIPS

I can't post a complete answer right now because I'm on a phone but I there are some things I had to do for luabind to work properly.

  1. Luabind 0.9.1 does not work with lua 5.2.x. Only with 5.1.x.

  2. If you are building lua, does not use the c++ compiler. Lua bind uses extern C to import lua headers and using the c++ will cause some conflicts.

  3. If you are using a pre build of lua, make sure it was build with vs2012.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top