从零开始使用luabind

来源:互联网 发布:淘宝怎么撤销小二介入 编辑:程序博客网 时间:2024/05/01 06:57

从零开始使用luabind

(2010-01-28 21:48:41)
转载
标签:

vs2005

luabind

it

那么好吧,我们来试试luabind.以下内容参考了不少网上的教程,由于被多方转载,已经不知道作者是谁了,在这里对他们表示万分的感谢.

使用vs2005编译luabind

红色部分是我自己编译的时候遇到的一些问题,或者应该注意的地方

  1. 下载lua (我使用的版本 lua-5.1.4)
    从官方网站http://www.lua.org/download.html可得到源码包.
  2. 编译lua
    使用VS.NET环境的使用VS提供的"Visual Studio命令提示",进入解开的源码包根目录下,按readme文提示,运行etc/luavs.bat,一般即可编译成功.
  3. 对于使用lua的开发者来说,可以直接到http://luabinaries.luaforge.net/download.html下载编译后版本.
  4. 下载boost (我用的boost_1_41_0)
    从官方网站http://www.boost.org/users/download/下载源码包.
  5. 编译bjam 
    从VS命令提示进入<boost_root>/tools/jam/src/,运行build.bat. 根据需要可以使用各种参数,比如希望使用vc8(VS 2005),则运行 build.bat vc8.
    生成的目标文件在<boost_root>/tools/jam/src/bin.ntx86/bjam.exe.
  6. 编译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文件了.  )
  7. 下载luabind
    http://sourceforge.net/projects/luabind/下载源码包. (我用的luabind-0.8.1.开始的时候用的0.9rc1,编不过去)
  8. 编译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 ;

不知道这会不会对编译造成影响.