如何编译luabind支持vs2010之后所有版本

步骤

  • 下载https://github.com/luabind/luabind/tree/0.9。 其最后一次commit为

    Revision: 8c66030818f0eacbb7356c16776539b55d8c5319
    Author: Peter Colberg <peter.colberg@utoronto.ca>
    Date: 12/24/2011 1:53:29 AM
    Message:
    Lua 5.2: use new macro lua_pushglobaltable

    This macro is not mentioned in the Lua 5.2 manual.
    ----
    Modified: luabind/object.hpp
    Modified: src/scope.cpp

     

  • 添加#include "luabind_compatibility.hpp",内容为
  • /*
    @Author Sygn (https://github.com/sygn-jp)
    
    This file is from https://github.com/sygh-JP/CompactLua . Detailed descriptions could be found
    at the author's blog: http://sygh.hatenadiary.jp/entry/2014/06/22/000456 (Japanese only).
    */
    
    #pragma once
    
    #include <lua.hpp>
    #include <boost/version.hpp>
    
    
    // Luabind 0.9.1 uses "boost::operator" but it has been moved to "boost::iterators::operator" in Boost 1.57.0 or later.
    // As a result, many compilation errors will occur at the macro "LUABIND_OPERATOR_ADL_WKND" in "luabind/object.hpp".
    // One of the best and wisest solutions is to modify the source code of Luabind directly.
    // As an alternative way, the following workaround can avoid modifying it but is unbeautiful and pollutes the namespace "boost".
    
    #if (BOOST_VERSION >= 105700)
    #include <boost/operators.hpp>
    namespace luabind
    {
        namespace detail
        {
            // Forward declaration
            template<typename T> class basic_iterator;
        }
    }
    namespace boost
    {
        template<typename T> bool operator ==(
            const luabind::detail::basic_iterator<T>& x,
            const luabind::detail::basic_iterator<T>& y)
        {
            return boost::iterators::operator ==(x, y);
        }
    
        template<typename T> bool operator !=(
            const luabind::detail::basic_iterator<T>& x,
            const luabind::detail::basic_iterator<T>& y)
        {
            return boost::iterators::operator !=(x, y);
        }
    }
    #endif

     

  • 为config。h,和lua_include.hpp 添加#include "luabind_compatibility.hpp"
  • 在policy。hpp添加
  • LUABIND_NUMBER_CONVERTER(long double, number)
    LUABIND_NUMBER_CONVERTER(__int64, number)
    LUABIND_NUMBER_CONVERTER(unsigned __int64, number)

     

 

转载于:https://www.cnblogs.com/cutepig/p/10493502.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Luabind是一个开源的C++库,用于绑定Lua脚本和C++代码。它使得在C++代码中调用Lua脚本变得更加容易。在Linux平台上安装Luabind库需要进行以下步骤: 1. 下载Luabind库 可以从Luabind的官方网站(http://luabind.sourceforge.net/)下载最新版本Luabind库。下载后将文件解压缩到一个目录中。 2. 安装Lua库 在Linux系统上安装Luabind库之前,需要确保已经安装了Lua库。如果还没有安装Lua库,可以通过以下命令来安装: sudo apt-get install lua5.1 3. 安装boost库 Luabind库依赖于boost库,因此需要先安装boost库。可以通过以下命令来安装: sudo apt-get install libboost-all-dev 4. 编译和安装Luabind库 进入Luabind库的解压缩目录,然后执行以下命令: ./configure make sudo make install 执行完成后,Luabind库就已经安装完成了。 5. 测试Luabind库 可以通过以下步骤来测试Luabind库是否安装成功: 创建一个名为test.cpp的文件,包含以下代码: #include <iostream> #include <luabind/luabind.hpp> void hello() { std::cout << "Hello, world!" << std::endl; } int main() { lua_State* L = luaL_newstate(); luaL_openlibs(L); luabind::open(L); luabind::module(L) [ luabind::def("hello", &hello) ]; luaL_dostring(L, "hello()"); lua_close(L); return 0; } 编译test.cpp文件: g++ -o test test.cpp -lluabind -llua -lboost_system 运行test文件,如果输出“Hello, world!”则表示Luabind库已经安装成功。 注:以上命令可能需要root权限,如果遇到权限问题,可以在命令前加上sudo。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值