编译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. 编译多线程dll、Debug版boost:
bjam toolset=msvc-7.1 variant=debug threading=multi link=shared
3. 编译多线程dll、Release版boost
bjam toolset=msvc-7.1 variant=release threading=multi link=shared
4. 直接运行bjam,会编译多线程dll、Release版
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++、Genenral、Additional 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文件进行修改得到,已经编译通过