Can't get luabind to compile...

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

Can't get luabind to compile...

Post by unholysavagery »

I've been trying for days now, I created a c++ express project and dropped all of the source files in it and compiled it in to a lib with no problems but when I use it I get link errors.

I know I'm suppose to use bjam to compile it but I'm not sure how to set the directories? Please can anyone explain the process to me or even send me a download link to the latest version of a lib that was compiled for 32 bit windows?
This is the internet, men are men, women are men and children are the FBI.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Can't get luabind to compile...

Post by Falco Girgis »

Ugh. Isn't there already a precompiled library out there for Luabind? I screwed with it a bit (tried to compile the lib for Dreamcast) before realizing it wouldn't work on DC (version of GCC was too old). I switched to toLua++ and never looked back.

Trufun is the resident LuaBind expert around here. Good luck with all of the blatant C++ whoring going on in the Boost libraries.
User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

Re: Can't get luabind to compile...

Post by unholysavagery »

I've been looking for days and all I found was a precompiled version thats to old.

Let me explain what I did.

First I got an installer for lua 5.1.4.23 from here: http://luaforge.net/frs/download.php/39 ... 1.4.23.exe

Then I got an installer for boost 1.38 from here: http://www.boostpro.com/download/boost_1_38_setup.exe

Then I downloaded the source files for luabind 0.8.1 from here http://sourceforge.net/project/download ... a=62200134

After that I went to my console and typed:
set BOOST_ROOT = C:\Program Files (x86)\boost\boost_1_37
set LUA_PATH = C:\Program Files (x86)\Lua\5.1
path C:\Program Files (x86)\boost\boost_1_37\bin
cd\luabind-0.8.1
bjam.exe
Then I get the following error:
Unable to load Boost.Build: could not find "boost-build.jam"
---------------------------------------------------------------
Attempted search from C:\luabind-0.8.1 up to the root

Please consult the documentation at 'http://www.boost.org'.
What am I doing wrong and how do I compile luabind with bjam?!
This is the internet, men are men, women are men and children are the FBI.
User avatar
trufun202
Game Developer
Game Developer
Posts: 1105
Joined: Sun Sep 21, 2008 12:27 am
Location: Dallas, TX
Contact:

Re: Can't get luabind to compile...

Post by trufun202 »

It's been months since I had to deal with compiling LuaBind, so I honestly don't remember all of the steps it took. But yeah, I do remember it was a pain in the ass and I had to make a few modifications to the code to get it to compile. I didn't use bjam, I just used VS 2008.

Tonight I'll grab my compiled libraries and post them for ya.
-Chris

YouTube | Twitter | Rad Raygun

“REAL ARTISTS SHIP” - Steve Jobs
User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

Re: Can't get luabind to compile...

Post by unholysavagery »

trufun202 wrote:It's been months since I had to deal with compiling LuaBind, so I honestly don't remember all of the steps it took. But yeah, I do remember it was a pain in the ass and I had to make a few modifications to the code to get it to compile. I didn't use bjam, I just used VS 2008.

Tonight I'll grab my compiled libraries and post them for ya.
Thank you sir!
This is the internet, men are men, women are men and children are the FBI.
User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

Re: Can't get luabind to compile...

Post by unholysavagery »

Actually I think when I originally compiled it with VS 2008 it kinda worked, does anyone have an idea what may be causing these compilation errors when I try to use the lib?

1>------ Build started: Project: Ether, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>Linking...
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_Container_base_secure::~_Container_base_secure(void)" (??1_Container_base_secure@std@@QAE@XZ) already defined in Main.obj
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in libcpmtd.lib(xlock.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in libcpmtd.lib(xlock.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z) already defined in libcpmtd.lib(stdthrow.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in Main.obj
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in Main.obj
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in Main.obj
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in Main.obj
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::_Container_base_secure::_Orphan_all(void)const " (?_Orphan_all@_Container_base_secure@std@@QBEXXZ) already defined in Main.obj
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_Container_base_secure::_Container_base_secure(void)" (??0_Container_base_secure@std@@QAE@XZ) already defined in Main.obj
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: __wassert already defined in LIBCMTD.lib(wassert.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: __invalid_parameter already defined in LIBCMTD.lib(invarg.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: __CrtDbgReportW already defined in LIBCMTD.lib(dbgrptw.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: "public: bool __thiscall type_info::operator==(class type_info const &)const " (??8type_info@@QBE_NABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: "public: int __thiscall type_info::before(class type_info const &)const " (?before@type_info@@QBEHABV1@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Debug\Ether.exe : fatal error LNK1169: one or more multiply defined symbols found
1>Build log was saved at "file://c:\Users\Steven\Desktop\Ether\Debug\BuildLog.htm"
1>Ether - 22 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This is the internet, men are men, women are men and children are the FBI.
User avatar
trufun202
Game Developer
Game Developer
Posts: 1105
Joined: Sun Sep 21, 2008 12:27 am
Location: Dallas, TX
Contact:

Re: Can't get luabind to compile...

Post by trufun202 »

Here's a copy of Lua 5.1 and LuaBind that I'm using. I included the entire folder, in case that helps.

But, specifically in my project I'm referencing lua.x86.debug.lib and luabind.x86.debug.lib. As you can see, these are built in debug mode, but they should get you up and running. I haven't needed a release mode copy of the libraries yet, so I haven't really bothered...

Lua5.1.zip

To include:

1. Extract Lua5.1.zip to c:\[somewhere]\Lua5.1\

2. Go to Tools > Options > Projects and Solutions > VC++ Directories
- Show "Include files" - add path to c:\[somewhere]\Lua5.1\include
- Show "Library Files" - add path to c:\[somewhere]\Lua5.1

3. Go to Project > Properties > Configuration Properties > Linker > Input
- Under "Additional Dependencies", add:
lua.x86.debug.lib
luabind.x86.debug.lib

4. In your code, include the following:

Code: Select all

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

#include "luabind/luabind.hpp"
5. Now just register your stuff with LuaBind, such as:

Code: Select all

   void RegisterWithLua()
	{
		/* initialize Lua */
		L = lua_open();

		/* load Lua base libraries */
		luaL_openlibs(L);

		luabind::open(L);

		luabind::module(L) [
		luabind::class_<Kelesis>("Kelesis")
			.def(luabind::constructor<>())
			.property("HP", &Kelesis::GetHP, &Kelesis::SetHP)
			.property("MaxHP", &Kelesis::GetMaxHP, &Kelesis::SetMaxHP)
			.property("Lives", &Kelesis::GetLives, &Kelesis::SetLives)
			.property("MaxLives", &Kelesis::GetMaxLives, &Kelesis::SetMaxLives)
			.def("AddItemToInventory", &Kelesis::AddItemToInventory)
			.def("HasItem", &Kelesis::HasItem)
			.def("RemoveItem", &Kelesis::RemoveItem)
			.def("EquipItem", &Kelesis::EquipItem)
		];

		luabind::module(L) [
			luabind::def("WriteToLog", WriteToLog)
		];

		luabind::module(L) [
			luabind::def("GetKelesis", GetKelesis)
		];

		/* run the script */
		luaL_dofile(L, "UpdateScene.lua");		
	}
-Chris

YouTube | Twitter | Rad Raygun

“REAL ARTISTS SHIP” - Steve Jobs
User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

Re: Can't get luabind to compile...

Post by unholysavagery »

trufun202 wrote:Here's a copy of Lua 5.1 and LuaBind that I'm using. I included the entire folder, in case that helps.

But, specifically in my project I'm referencing lua.x86.debug.lib and luabind.x86.debug.lib. As you can see, these are built in debug mode, but they should get you up and running. I haven't needed a release mode copy of the libraries yet, so I haven't really bothered...

Lua5.1.zip

To include:

1. Extract Lua5.1.zip to c:\[somewhere]\Lua5.1\

2. Go to Tools > Options > Projects and Solutions > VC++ Directories
- Show "Include files" - add path to c:\[somewhere]\Lua5.1\include
- Show "Library Files" - add path to c:\[somewhere]\Lua5.1

3. Go to Project > Properties > Configuration Properties > Linker > Input
- Under "Additional Dependencies", add:
lua.x86.debug.lib
luabind.x86.debug.lib

4. In your code, include the following:

Code: Select all

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

#include "luabind/luabind.hpp"
5. Now just register your stuff with LuaBind, such as:

Code: Select all

   void RegisterWithLua()
	{
		/* initialize Lua */
		L = lua_open();

		/* load Lua base libraries */
		luaL_openlibs(L);

		luabind::open(L);

		luabind::module(L) [
		luabind::class_<Kelesis>("Kelesis")
			.def(luabind::constructor<>())
			.property("HP", &Kelesis::GetHP, &Kelesis::SetHP)
			.property("MaxHP", &Kelesis::GetMaxHP, &Kelesis::SetMaxHP)
			.property("Lives", &Kelesis::GetLives, &Kelesis::SetLives)
			.property("MaxLives", &Kelesis::GetMaxLives, &Kelesis::SetMaxLives)
			.def("AddItemToInventory", &Kelesis::AddItemToInventory)
			.def("HasItem", &Kelesis::HasItem)
			.def("RemoveItem", &Kelesis::RemoveItem)
			.def("EquipItem", &Kelesis::EquipItem)
		];

		luabind::module(L) [
			luabind::def("WriteToLog", WriteToLog)
		];

		luabind::module(L) [
			luabind::def("GetKelesis", GetKelesis)
		];

		/* run the script */
		luaL_dofile(L, "UpdateScene.lua");		
	}
Did it exactly as you said to and I'm still getting link errors...
This is the internet, men are men, women are men and children are the FBI.
User avatar
trufun202
Game Developer
Game Developer
Posts: 1105
Joined: Sun Sep 21, 2008 12:27 am
Location: Dallas, TX
Contact:

Re: Can't get luabind to compile...

Post by trufun202 »

You're getting alot of "already defined..." errors, so it looks like you're referencing the libraries in two places. Make sure you clear out your old references before you follow the steps I outlined.
-Chris

YouTube | Twitter | Rad Raygun

“REAL ARTISTS SHIP” - Steve Jobs
User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

Re: Can't get luabind to compile...

Post by unholysavagery »

Found out that I compiled it correctly from the start.... I figured out I needed to use Multi-threaded Debug DLL (/MDd) for the runtime library of my game even though I thought that was for DLLs and LIBs but it seems to work in EXEs.

Found a post on some random forum that said link errors may be caused by the runtime library, I looked at it days ago and thought there was no way that would be the right setting but today I tried it and it worked... So yeah that was it!
This is the internet, men are men, women are men and children are the FBI.
User avatar
trufun202
Game Developer
Game Developer
Posts: 1105
Joined: Sun Sep 21, 2008 12:27 am
Location: Dallas, TX
Contact:

Re: Can't get luabind to compile...

Post by trufun202 »

Awesome! Lua + LuaBind is some powerful 'chit - now show us what you're made of! ;)
-Chris

YouTube | Twitter | Rad Raygun

“REAL ARTISTS SHIP” - Steve Jobs
Post Reply