那么好吧,我們來(lái)試試luabind.以下內(nèi)容參考了不少網(wǎng)上的教程,由于被多方轉(zhuǎn)載,已經(jīng)不知道作者是誰(shuí)了,在這里對(duì)他們表示萬(wàn)分的感謝.
使用vs2005編譯luabind
紅色部分是我自己編譯的時(shí)候遇到的一些問(wèn)題,或者應(yīng)該注意的地方
- 下載lua (我使用的版本 lua-5.1.4)
從官方網(wǎng)站http://www.lua.org/download.html可得到源碼包. - 編譯lua
使用VS.NET環(huán)境的使用VS提供的"Visual Studio命令提示",進(jìn)入解開的源碼包根目錄下,按readme文提示,運(yùn)行etc\luavs.bat,一般即可編譯成功. - 對(duì)于使用lua的開發(fā)者來(lái)說(shuō),可以直接到http://luabinaries.luaforge.net/download.html下載編譯后版本.
- 下載boost (我用的boost_1_41_0)
從官方網(wǎng)站http://www.boost.org/users/download/下載源碼包. - 編譯bjam
從VS命令提示進(jìn)入<boost_root>\tools\jam\src\,運(yùn)行build.bat. 根據(jù)需要可以使用各種參數(shù),比如希望使用vc8(VS 2005),則運(yùn)行 build.bat vc8.
生成的目標(biāo)文件在<boost_root>\tools\jam\src\bin.ntx86\bjam.exe. - 編譯boost
將bjam.exe拷貝到<boost_root>目錄下,在VS命令提示進(jìn)入<boost_root>,運(yùn)行bjam. 其他參數(shù)請(qǐng)自行查詢.
編譯時(shí)間比較長(zhǎng),生成的目標(biāo)文件在<boost_root>\bin.v2\libs.(或者在<boost_root> 新建一個(gè)bat,寫入如下內(nèi)容: bjam --toolset=msvc-8.0 --stagedir=./lib_x86 --builddir=./ address-model=32 link=static runtime-link=static threading=multi stage debug release
bjam --toolset=msvc-8.0 --stagedir=./lib_x64 --builddir=./ address-model=64 link=static runtime-link=static threading=multi stage debug release ,參數(shù)自己按需要修改.這樣你就可以直接用vs命令提示運(yùn)行這個(gè)bat文件了. ) - 下載luabind
從http://sourceforge.net/projects/luabind/下載源碼包. (我用的luabind-0.8.1.開始的時(shí)候用的0.9rc1,編不過(guò)去) - 編譯luabind
使用VS新建win32項(xiàng)目,新建選項(xiàng)為靜態(tài)庫(kù)Static Link Library,不使用預(yù)編譯頭Precompiled header. 將<luabind_root>\src下所有cpp文件加入工程. 將<boost_root>,<lua_root>\src,<luabind_root>加入附加包含路徑.
編譯luabind.lib.
另外,我修改了boost_1_41_0\tools\build\v2\user-config.jam文件中的 # using msvc : 8.0;
改后: # using msvc : 8.0 : : <compileflags>/wd4819 <compileflags>/D_CRT_SECURE_NO_DEPRECATE <compileflags>/D_SCL_SECURE_NO_DEPRECATE <compileflags>/D_SECURE_SCL=0 ;
不知道這會(huì)不會(huì)對(duì)編譯造成影響.