在Windows下编译 Boost 1.35、Lua 5.1和LuaBind 0.7

编译boost工具bjam:

1.      使用Visual Studio 2005 Command Prompt环境运行<boost_root>/tools/jam/src/build.bat

2.      生成的目标文件在<boost_root>/tools/jam/src/bin.ntx86/bjam.exe

编译boost 1.35:

1.      bjam.exe拷贝到<boost_roo>目录

2.      编译多线程dllDebugboost:

bjam toolset=msvc-7.1 variant=debug threading=multi link=shared

3.      编译多线程dllReleaseboost

bjam toolset=msvc-7.1 variant=release threading=multi link=shared

4.      直接运行bjam,会编译多线程dllRelease

5.      生成的目标文件在<boost_root>/bin.v2/libs

编译lua 5.1

1.      使用Visual Studio 2005 Command Prompt环境在<Lua_root>目录下运行etc/luavs.bat

2.      生成的目标文件在<Lua_root>/src

包括lua.exe, luac.exe, lua51.dll, lua51.lib, lua51.exp

编译luabind 0.7

1.      修改luabind部分源代码,增加以下红色部分代码以兼容lua 5.1:

<luabind_root>/lua_include.hpp

extern "C"

{

        #include "lua.h"

        #include "lauxlib.h"

}

 

<luabind_root>/src/pcall.cpp

 int resume_impl(lua_State *L, int nargs, int)

 {

#if LUA_VERSION_NUM >= 501

        // Lua 5.1 added  LUA_YIELD as a possible return value,

        // this was causing crashes, because the caller expects 0 on success.

        int res = lua_resume(L, nargs);

        return (res == LUA_YIELD) ? 0 : res;

#else

        return lua_resume(L, nargs);

#endif // LUA_VERSION_NUM >= 501

}

 

<luabind_root>/src/ref.cpp

 #include <luabind/lua_include.hpp>

 #include <luabind/detail/debug.hpp>

 

// Lua 5.1 Fixes

#if LUA_VERSION_NUM >= 501

#define LUA_REFNIL (-1)

#undef luaL_setn

#undef luaL_getn

#endif // LUA_VERSION_NUM >= 501

 

 

 namespace luabind { namespace detail

 {

 

<luabind_root>/test/main.cpp

     : m_state(lua_open())

 {

     luaopen_base(m_state);

#if LUA_VERSION_NUM >= 501

    luaL_openlibs(m_state);

#else

     lua_baselibopen(m_state);

#endif

     m_top = lua_gettop(m_state);

     luabind::open(m_state);

 }

 

2.      Visual Studo 2005新建一个Win32 Project,命名为luabind,选择为Static Link Library,不使用Precompiled header

3.     

<luabind_root>/src目录下的所有.cpp文件加到工程中

4.      在工程设置中,C/C++GenenralAdditional Include Directories下增加

<lua_root>/src

<boost_root>

<luabind_root>

5.      编译,生成luabind.lib

 

 

 

 

 

P.S. luabind依赖于boost,但不会使用那些需要编译的boost库,所以如果你的程序中只是需要使用luabind,可以跳过第1、2步,直接编译lua和luabind

 

在这里可以下载我修改过的luabind 0.7源代码,根据luabind提供的lua5.1 compatible diff文件进行修改得到,已经编译通过

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值