[CMake] SWIG python3

Matthias Fulz mfulz at olznet.de
Mon Mar 12 19:03:23 EDT 2012


Ok the error is related to my arch linux.
Cmake can't find python 3.2 because the lib is named "libpython3.2mu".
Does anybody know about this and perhaps has a solution?

On Mon, 2012-03-12 at 22:52 +0100, Matthias Fulz wrote:
> Hi,
> 
> I'm trying basic examples for using SWIG to generate python extensions
> for c++:
> 
> cmake_minimum_required(VERSION 2.8)
> 
> FIND_PACKAGE(SWIG REQUIRED)
> INCLUDE(${SWIG_USE_FILE})
> 
> FIND_PACKAGE(PythonLibs)
> INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
> 
> INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
> 
> SET(CMAKE_SWIG_FLAGS "")
> 
> SET_SOURCE_FILES_PROPERTIES(number.i PROPERTIES CPLUSPLUS ON)
> SET_SOURCE_FILES_PROPERTIES(number.i PROPERTIES SWIG_FLAGS
> "-includeall")
> SWIG_ADD_MODULE(number python
>   number.i number.hpp number.cpp)
> SWIG_LINK_LIBRARIES(number ${PYTHON_LIBRARIES})
> 
> This CMakeLists.txt is working fine, but only for python2, when I try to
> import it in python3, I'll receive the following error:
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "number.py", line 26, in <module>
>     _number = swig_import_helper()
>   File "number.py", line 22, in swig_import_helper
>     _mod = imp.load_module('_number', fp, pathname, description)
> ImportError: dynamic module does not define init function
> (PyInit__number)
> 
> Could someone help me out here?
> 
> Thanks,
> 
> Matthias
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120313/88be9db3/attachment-0001.pgp>


More information about the CMake mailing list