- Notifications
You must be signed in to change notification settings - Fork2
mac compile testing for boost-python3
License
orlando23-dev/boost-python3-mac
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
These are a few examples on how to use the boost::python library to extend Python with C++ libraries.Some of the are based on theexisting tutorial for boost::python from Joel de Guzman.Others are independent.
- CMake (>= 2.8.3)
- Boost (tested with 1.4.2, but should work with >= 1.3.2)
- Python (tested with 2.7, but should work with >= 2.2)
- a C++ compiler for your platform, e.g.GCC orMinGW
The examples should work on Linux, Windows and Mac, but currently have not been tested under Windows.
Mac OS X withhomebrew
There is a special package needed called boost-python. The standard boost package will not be recognized by cmake.
brew install cmake boost-python
Furthermore, for the homebrew python lib to be used, its path must be provided to cmake. This is handled in thebuild.sh script, but for reference, or if any issues arise, that can be done manually as follows (substitute the path as appropriate for your Python version):
cmake -DPYTHON_LIBRARY=/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib ..- Set the
BOOST_ROOTenvironment variable if Boost is installed in a non-standard directory - create a build directory, e.g. directly in the project directory and cd to it:
mkdir build ; cd build - run
cmake ..and afterwardsmake
Alternatively, run the providedbuild.sh script.
All examples contain tests, but these only try to run the examples without checking the output. Their purpose is mainly to make sure that compilation works and produces valid Python modules.
The code works with Python 3 both on Linux and on OS X. However, there are several caveats.
- Build Boost::Python against Python 3 (needs at least version 1.56.0)
- make sure
pythonresolves to python3 (e.g., by using a python3 VE) - run
cmake -DBOOST_ROOT=xxx ..
Some effort has been made to make Python 3 compilation automatic, by making modifications tobuild.sh andCMakeLists.txt that account for quirks on the Apple platform regarding cmake, paths, and naming conventions for python/python3. Having said that, if you usebuild.sh, then you will still need to do the following:
- Build Boost::Python against Python 3 (needs at least version 1.56.0)
- make sure
pythonresolves to python3 (e.g., by using virtualenv)
If you are building withoutbuild.sh, then you will additionally need to:
- run
cmake -DBOOST_ROOT=xxx -DPYTHON_LIBRARY=xxx -DPYTHON_INCLUDE_DIR=xxx .. - As of the time of this writing, the naming convention is that python2 is called "python" and python3 is called "python3" on the Apple platform. Therefore, in
CMakeLists.txtverify that the lineFIND_PACKAGE(Boost COMPONENTS python)is changed toFIND_PACKAGE(Boost COMPONENTS python3).
- pre-requsisite:https://stackoverflow.com/questions/42123509/cmake-finds-boost-but-the-imported-targets-not-available-for-boost-versionupdatecmake to 3.11.3 to avoid running issue:
Boost 1.63 requires CMake 3.7 or newer.Boost 1.64 requires CMake 3.8 or newer.Boost 1.65 and 1.65.1 require CMake 3.9.3 or newer.Boost 1.66 requires CMake 3.11 or newer.Boost 1.67 is only supported by CMake master since March 2018.
- on orlando's local computer
- generate makefile
$ cmake -DBoost_INCLUDE_DIRS=/usr/local/opt/boost/icnlude -DBoost_LIBRARIES=/usr/local/opt/boost-python3/lib:/usr/local/opt/boost/lib -DPYTHON_LIBRARY=~/miniconda3/lib/libpython3.6m.dylib -DPYTHON_INCLUDE_DIR=~/miniconda3/include/python3.6m
- build
$ make
refer to :https://stackoverflow.com/questions/15929566/need-help-getting-started-with-boost-python
issue:"vtable for boost::python::objects::py_function_impl_base", referenced from:boost::python::objects::py_function_impl_base::py_function_impl_base() in hello.cpp.oNOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
About
mac compile testing for boost-python3
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Contributors6
Uh oh!
There was an error while loading.Please reload this page.