boost-python

Cmake could not find boost_python

别说谁变了你拦得住时间么 提交于 2020-08-06 07:58:37
问题 I am trying to build this simple boost python demo from this link on my MacOS High Sierra. Following is the hello_ext.cpp : #include <boost/python.hpp> char const* greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("greet", greet); } Following is the CmakeLists.txt : cmake_minimum_required(VERSION 3.5) # Find python and Boost - both are required dependencies find_package(PythonLibs 2.7 REQUIRED) find_package(Boost COMPONENTS python REQUIRED)

Cmake could not find boost_python

不打扰是莪最后的温柔 提交于 2020-08-06 07:58:11
问题 I am trying to build this simple boost python demo from this link on my MacOS High Sierra. Following is the hello_ext.cpp : #include <boost/python.hpp> char const* greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("greet", greet); } Following is the CmakeLists.txt : cmake_minimum_required(VERSION 3.5) # Find python and Boost - both are required dependencies find_package(PythonLibs 2.7 REQUIRED) find_package(Boost COMPONENTS python REQUIRED)

Boost.Python Hello World on Mac OS X

本秂侑毒 提交于 2020-08-06 07:42:30
问题 I am trying to setup and compile the Hello World example for Boost.Python: http://www.boost.org/doc/libs/1_57_0/libs/python/doc/tutorial/doc/html/python/hello.html I installed bjam, boost, boost-build, and boost-python from Homebrew: brew install bjam brew install boost brew install boost-build brew install boost-python My python install is also via Homebrew. I am not sure how to properly modify the example Jamroot file so that it is compatible with my system setup. I changed the boost path

Why the following code compiles with `c++03` but not with `c++11`

守給你的承諾、 提交于 2020-07-29 13:37:12
问题 I am using the boost::python library in this tiny mwe. #include <deque> #include <boost/python.hpp> typedef std::deque<long unsigned int> DequeUInt64; BOOST_PYTHON_MODULE_INIT(tmp) { boost::python::class_<DequeUInt64>("DequeUInt64") .def("push_back" ,&DequeUInt64::push_back) .def("push_front" ,&DequeUInt64::push_front); } I observed that the code above compiles with std=c++03 and gnu++03 but not with c++11 or c++0x . The error is: tmp.cpp: In function 'void init_module_tmp()': tmp.cpp:8:47:

Force linking against Python release library in debug mode in Windows/Visual Studio from CMake

被刻印的时光 ゝ 提交于 2020-06-12 07:32:10
问题 I'm developing a Python binding for a C++ library using Boost Python, for Linux and Windows (Visual Studio). In Windows, the static Boost Python library has a dependency against Python (this is motive for another thread, here), so, in my CMake config I need to do: if((${CMAKE_SYSTEM_NAME} STREQUAL "Linux") OR APPLE) target_link_libraries(my_python_module ${Boost_LIBRARIES}) elseif(WIN32 AND MSVC) add_definitions(/DBOOST_PYTHON_STATIC_LIB) target_link_libraries(my_python_module ${Boost

Is this Boost::Python (Python 3.7) error “__init__() should return None, not 'NoneType'” a linking problem?

人走茶凉 提交于 2020-05-09 05:28:57
问题 Update I'm not going to add this as an answer, since I still haven't technically solved the problem. But since I've now spent 2.5 days trying to get things to work with boost-python3, I've lost the will to live with it. I've just come across pybind11 (how my previous lengthy searches for python binding tools didn't turn it up, I don't know) and am using that. 2.5 days of misery compares to <20 minutes installing and building their cmake example... and all the specific-python-version

Is this Boost::Python (Python 3.7) error “__init__() should return None, not 'NoneType'” a linking problem?

白昼怎懂夜的黑 提交于 2020-05-09 05:24:06
问题 Update I'm not going to add this as an answer, since I still haven't technically solved the problem. But since I've now spent 2.5 days trying to get things to work with boost-python3, I've lost the will to live with it. I've just come across pybind11 (how my previous lengthy searches for python binding tools didn't turn it up, I don't know) and am using that. 2.5 days of misery compares to <20 minutes installing and building their cmake example... and all the specific-python-version

Instantiating shared_ptr's in boost::python

十年热恋 提交于 2020-03-06 08:26:11
问题 I had a question about boost python. I've been working on exporting some functionality of a project into boost python, and I haven't found a way to solve the following problem: I have a set of StatusEffect objects that i store and use throughout the game. At the game startup, I want to be able to call a python script that will populate/add to the set of status effect objects. I'm having no problems exposing the StatusEffect class and it's derived class to python and calling the script. The

Boost.Python tries to link against python27.lib using Visual C++

我是研究僧i 提交于 2020-01-25 10:51:07
问题 I'm trying to build boost python using Python 3.2. I'm linking against python32.lib and libboost_python3-vc110-mt-gd-1_52.lib. I also definied BOOST_ALL_NO_LIB to disable boost's auto link feature. Still I'm getting the following error: fatal error LNK1104: cannot open file 'python27.lib' How to tell boost to use Python 3.2? 回答1: Do you have multiple Python installations on your computer? You probably have to create a user-config.jam file with content like this: using python : 3.2 : C:\Path

C++ and Boost.Python - how to expose variable to python and update it in loop?

坚强是说给别人听的谎言 提交于 2020-01-25 06:52:52
问题 Introduction I have a python code called from c++, using boost.python package. I can pass some variables, when calling MyFunc from .py like this: Py_SetPythonHome(pySearchPath); try { Py_Initialize(); numpy::initialize(); object module = import("__main__"); object name_space = module.attr("__dict__"); exec(python_full, name_space, name_space); object MyFunc = name_space["MyFunc"]; object result = MyFunc(var1, var2, var3)); //HERE //Python results storage numpy::ndarray ret = extract<numpy: