I am adding boost.python for my game. I write wrappers for my classes to use in scripts. The problem is with this library with my application. I am using cmake build system.
Now I have a simple application with 1 file and a makefile for it:
PYTHON = /usr/include/python2.7 BOOST_INC = /usr/include BOOST_LIB = /usr/lib TARGET = main $(TARGET).so: $(TARGET).o g++ -shared -Wl,--export-dynamic \ $(TARGET).o -L$(BOOST_LIB) -lboost_python \ -L/usr/lib/python2.7/config -lpython2.7 \ -o $(TARGET).so $(TARGET).o: $(TARGET).cpp g++ -I$(PYTHON) -I$(BOOST_INC) -c -fPIC $(TARGET).cpp
And it works. It creates a “so” file for me, which I can import from python.
Now the question is: how to do this for cmake?
I wrote in the main CMakeList.txt :
... find_package(Boost COMPONENTS filesystem system date_time python REQUIRED) message("Include dirs of boost: " ${Boost_INCLUDE_DIRS} ) message("Libs of boost: " ${Boost_LIBRARIES} ) include_directories( ${Boost_INCLUDE_DIRS} ... ) target_link_libraries(Themisto ${Boost_LIBRARIES} ... ) ...
message shows:
Include dirs of boost: /usr/include Libs of boost: /usr/lib/libboost_filesystem-mt.a/usr/lib/libboost_system-mt.a/usr/lib/libboost_date_time-mt.a/usr/lib/libboost_python-mt.a
Ok, so I added a simple .cpp file for my project with the inclusion of <boost/python.hpp> . I get a compilation error:
/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directory
Therefore, you do not need to include all directories.
And the second question:
How to organize two-stage building script-cpp files? In the makefile that I showed, there are TARGET.o and TARGET.so , how to handle these 2 commands in cmake?
As I understand it, the best way is to create a subproject and do something there.
Thanks.
c ++ python boost hyperlink cmake
Ockonal
source share