Luabind未定义的符号/ Luabind::scope::scope

我刚开始使用Luabind,并尝试运行http://www.rasterbar.com/products/luabind/docs.html#calling-lua-functions中指定的Hello World测试代码。然而,编译时出现了未定义符号错误。

Undefined symbols for architecture x86_64:
  "luabind::scope::scope(std::__1::auto_ptr<luabind::detail::registration>)", referenced from:
      luabind::scope luabind::def<void (*)(), luabind::detail::null_type>(char const*, void (*)(), luabind::detail::null_type const&) in TestClass.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

其他函数如luabind::openluabind::call_function可以正常工作。我在OSX上通过Homebrew安装了luabind和lua 5.1。

点赞
用户195160
用户195160

看起来你正在使用libc++编译你的程序,同时尝试链接到一个使用stdlibc++库编译的luabind库。

线索是std::__1::auto_ptr。这个__1的内联命名空间是libc++用来区分其ABI与stdlibc++的命名空间。

因此,如果无法找到luabind::scope::scope(std::__1::auto_ptrluabind::detail::registration),很可能是因为libluabind没有它。通过导出其符号,您可能会发现它具有luabind::scope::scope(std::auto_ptrluabind::detail::registration)。

如果我是对的,只需使用libc++重新编译libluabind,您就会发现它可以与您的测试程序一起正常工作。

2015-12-08 13:28:10