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

Attachment: signature.asc
Description: This is a digitally signed message part

--

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

Reply via email to