我有一个项目在链接中显示以下错误:
/usr/lib/i386-linux-gnu/libpython2.7.so: undefined reference to '__fdelt_chk@GLIBC_2.15'
Run Code Online (Sandbox Code Playgroud)
我使用的是安装了 libc6 (GLIBC_2.19) 的 Ubuntu 14.04。我无法理解这个问题,也没有找到解决方案。
我在使用Boost-Python为Python封装枚举时遇到问题。
最初,我打算在try-catch(我在下面插入了整个代码)语句中执行以下操作:
main_namespace["Motion"] = enum_<TestClass::Motion>("Motion")
.value("walk", TestClass::walk)
.value("bike", TestClass::bike)
;
Run Code Online (Sandbox Code Playgroud)
一切都很好,编译已经完成。在运行时,我收到此错误(对我来说这没有意义):
AttributeError: 'NoneType' object has no attribute 'Motion'
Run Code Online (Sandbox Code Playgroud)
之后,我决定在代码中使用BOOST_PYTHON_MODULE编写一个Python模块。初始化Python解释器后,我想立即使用此模块,但不知道how(?)。以下是我的整个代码:
#include <boost/python.hpp>
#include <iostream>
using namespace std;
using namespace boost::python;
BOOST_PYTHON_MODULE(test)
{
enum_<TestClass::Motion>("Motion")
.value("walk", TestClass::walk)
.value("bike", TestClass::bike)
;
}
int main()
{
Py_Initialize();
try
{
object pyMainModule = import("__main__");
object main_namespace = pyMainModule.attr("__dict__");
//What previously I intended to do
//main_namespace["Motion"] = enum_<TestClass::Motion>("Motion")
// .value("walk", TestClass::walk)
// .value("bike", TestClass::bike)
//;
//I want to use my enum here
//I need something …Run Code Online (Sandbox Code Playgroud)