[CMake] Problem embedding Python in C

Eric Noulard eric.noulard at gmail.com
Tue Jun 9 14:22:08 EDT 2009


2009/6/10 Ángel Alonso <feler at archlinux.us>:
> Hi,
>
> I'm using cmake for a project that embed Python in  C.
>
> For include the Python libs i use: include(FindPythonLibs)

One usually do:

find_package(PythonLibs)
instead of:
include(FindPythonLibs)

>
> But compiling, I get this errors:
>
> /usr/lib/python2.6/config/libpython2.6.a(posixmodule.o): In function
> `posix_tmpnam':
> (.text+0x8f4): warning: the use of `tmpnam_r' is dangerous, better use
[...]


include(FindPythonLibs) may not be enough:
you seem to be missing something like:

target_link_library(<your_target> ${PYTHON_LIBRARIES})

[...]

>
> I also try include(FindThreads) but the problem persist.

Same for FindThreads.

find_package(Threads)

however I dont' know that one works because the FindThreads.cmake
module does not seem to define THREADS_LIBRARIES
in order for you to
target_link_library(<your_target> ${THREADS_LIBRARIES})

May be the author of FindThreads may help us with the usage of this module?

> I think that is a problem of cmake, because in other tests that I made (with
> a simple Makefile, not cmake) it works.

compare the link command used by CMake and te one you use in your makefile.

make VERBOSE=1

with CMake generated makefile should show you the full link line.


-- 
Erk


More information about the CMake mailing list