I am trying to write an C++ extension for python which involves Python C API. According to my previous experience on doing this with Visual Studio, I just need to include python's header files and link python's static libraries and everything would work fine.
However I couldn't do this on OS X Mavericks now. I installed a separate Python 3.4.2 from python.org and added an include entry in my Cmake configuration:include_directories("/Library/Frameworks/Python.framework/Versions/3.4/Headers")
Then I have no clue how to proceed with the static libraries part. On Windows they are stored in %python_root%/libs
and you can find .lib
files there. But on OS X I couldn't find such directory in which .a
static libraries are placed.
I tried several solutions such as attaching the result of python-config --lib
to compile options and set(CMAKE_BUILD_TYPE Release)
while they all ended up with the following error:
Undefined symbols for architecture x86_64:
"_PyLong_FromLong", referenced from:
test() in Main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried distutils
as well, but it didn't seem to work properly, either :(