那麼好吧,我們來試試luabind.以下內容參考了不少網上的教程,由於被多方轉載,已經不知道作者是誰了,在這裏對他們表示萬分的感謝.
使用vs2005編譯luabind
紅色部分是我自己編譯的時候遇到的一些問題,或者應該注意的地方
- 下載lua (我使用的版本 lua-5.1.4)
從官方網站http://www.lua.org/download.html可得到源碼包. - 編譯lua
使用VS.NET環境的使用VS提供的"Visual Studio命令提示",進入解開的源碼包根目錄下,按readme文提示,運行etc/luavs.bat,一般即可編譯成功. - 對於使用lua的開發者來說,可以直接到http://luabinaries.luaforge.net/download.html下載編譯後版本.
- 下載boost (我用的boost_1_41_0)
從官方網站http://www.boost.org/users/download/下載源碼包. - 編譯bjam
從VS命令提示進入<boost_root>/tools/jam/src/,運行build.bat. 根據需要可以使用各種參數,比如希望使用vc8(VS 2005),則運行 build.bat vc8.
生成的目標文件在<boost_root>/tools/jam/src/bin.ntx86/bjam.exe. - 編譯boost
將bjam.exe拷貝到<boost_root>目錄下,在VS命令提示進入<boost_root>,運行bjam. 其他參數請自行查詢.
編譯時間比較長,生成的目標文件在<boost_root>/bin.v2/libs.(或者在<boost_root> 新建一個bat,寫入如下內容: 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 ,參數自己按需要修改.這樣你就可以直接用vs命令提示運行這個bat文件了. ) - 下載luabind
從http://sourceforge.net/projects/luabind/下載源碼包. (我用的luabind-0.8.1.開始的時候用的0.9rc1,編不過去) - 編譯luabind
使用VS新建win32項目,新建選項爲靜態庫Static Link Library,不使用預編譯頭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 ;
不知道這會不會對編譯造成影響.