0

I have one .cpp file which includes files from two subdirectories(subfolders linoise and noiseutils). I am trying to expose c++ class to python (I tried World example but when I try this more complex task I get error). I am usimh CMakeLists.txt to compile and create .so files. ANd it works fine, it creates three .so libraries (one in working directory, one in noiseutils, and one in libnoise).

when I try

import map

it get error map.so: undefined symbol: _ZTIN5noise6module6ModuleE

project (map)
cmake_minimum_required(VERSION 2.8)

find_package(PythonLibs)
include_directories (${PYTHON_INCLUDE_DIRS})

find_package(Boost 1.45.0 COMPONENTS python)
include_directories (${Boost_INCLUDE_DIRS})
set (LIBNOISE_PATH ${MY_SOURCE_DIR}/libnoise)
set (LIBNOISEUTILS_PATH ${MY_SOURCE_DIR}/noiseutils)


add_subdirectory(libnoise)
add_subdirectory(noiseutils)

add_library (
    map SHARED  
    Wrapped.cpp
)



target_link_libraries (
    map
    boost_python
    ${PYTHON_LIBRARIES}
    ${Boost_LIBRARIES}
)

Do I need somehow to connect all three .so libraries or is it already in one file in working directory ? (It generates Make file, compiles and generates .so files, I tried to remove lib from name to be same as in wrapped file but it still throws error)

PaolaJ.
  • 10,872
  • 22
  • 73
  • 111
  • possible duplicate of [Compiled .so for boost python cannot find module](http://stackoverflow.com/questions/19936166/compiled-so-for-boost-python-cannot-find-module) – Tanner Sansbury Dec 17 '13 at 14:34

2 Answers2

0

Did you update your config files in /etc and run ldconfig? May be your program does not know where the "so" file is located. Either way you must at the very least run ldconfig after creating a new "so" file so the OS knows about the new "so" file.

user2737761
  • 115
  • 7
0

It looks like your "map" library depends on stuff from the libraries libnoise and noiseutils, but you've not told the linker that there is a dependency. Add the names of those library targets to the target_link_libraries directive:

target_link_libraries (
    map
    libnoise
    noiseutils
    boost_python
    ${PYTHON_LIBRARIES}
    ${Boost_LIBRARIES}
)

Note I don't know what the actual names are. Use the same name as you use in ADD_LIBRARY down in those subprojects.

Check the results before and after with ldd libmap.so (or whatever the name is): It will show all .so dependencies, and after this fix, it should show libnoise/noiseutils.

Peter
  • 14,559
  • 35
  • 55