3

I'm having some trouble getting the QHull C++ interface working in a catkin project. My project compiles fine and I've specified the library to be used by the linker, however it fails to link with the following error messages.

CMakeFiles/path_to/my_code.cpp.o: In function `main':
my_code.cpp:(.text+0x17ab): undefined reference to `orgQhull::RboxPoints::RboxPoints()'
my_code.cpp:(.text+0x182a): undefined reference to `orgQhull::PointCoordinates::appendPoints(std::istream&)'
my_code.cpp:(.text+0x1839): undefined reference to `orgQhull::Qhull::Qhull()'
my_code.cpp:(.text+0x1857): undefined reference to `orgQhull::Qhull::runQhull(orgQhull::RboxPoints const&, char const*)'
my_code.cpp:(.text+0x18aa): undefined reference to `orgQhull::Qhull::outputQhull(char const*)'
my_code.cpp:(.text+0x19d0): undefined reference to `orgQhull::Qhull::~Qhull()'
my_code.cpp:(.text+0x19ee): undefined reference to `orgQhull::RboxPoints::~RboxPoints()'
my_code.cpp:(.text+0x1c10): undefined reference to `orgQhull::Qhull::~Qhull()'
my_code.cpp:(.text+0x1c38): undefined reference to `orgQhull::RboxPoints::~RboxPoints()'
CMakeFiles/build_path/my_code.cpp.o: In function `orgQhull::Qhull::setOutputStream(std::ostream*)':

I've installed the following packages, to get the shared object and development files.

  • libqhull-dev
  • libqhull-doc
  • libqhull7
  • qhull-bin

I don't know if this is related to the problem, but looking into the libqhull.so shared object there are no symbols in it.

####:/usr/lib/x86_64-linux-gnu$ nm -g libqhull.so
nm: libqhull.so: no symbols

Has anyone got any experience getting this to work on linux? Any help would be appreciated.

  • this is a linking problem, it would be helpful if you post your project CMakeLists file ? – Vtik Jan 13 '17 at 14:32

1 Answers1

4

I'm using ROS Indigo, this works for me:

SET(qhullDir path_to_qhull_code)
INCLUDE_DIRECTORIES(${qhullDir}/src/libqhullcpp)
INCLUDE_DIRECTORIES(${qhullDir}/src)
LINK_DIRECTORIES(${qhullDir}/build)

INCLUDE_DIRECTORIES(${qhullDir}/src/libqhullcpp)
INCLUDE_DIRECTORIES(include)

SET(qhullLibs qhullcpp qhull_r)
add_library(${PROJECT_NAME}_library
  src/myClass.cpp) 

add_executable(libExample
 src/myrunnable.cpp)
target_link_libraries(libExample
 ${PROJECT_NAME}_library ${qhullLibs})
SET_TARGET_PROPERTIES(libExample PROPERTIES
 COMPILE_DEFINITIONS "qh_QHpointer")

I'm compiling qhull from source with cmake.

Maybe this helps someone.

kmartinho
  • 144
  • 1
  • 10