Failure to link Qhull C++ interface in ROS catkin project - c++

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.

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.

Related

Numerous LD linking errors while linking against downloaded package

I've been trying to compile an open-source C++ project Typesense, which has this list of dependencies:
Snappy
zlib
OpenSSL (>=1.0.2)
curl
ICU
brpc
braft
Host and target OS is Debian Linux. Compilation is handled via cmake->make sequence of commands. I was able to install some of dependencies through a package manager (I believe they reside in /usr/lib then), the last two I had to compile on my own, I put them in /usr/local/lib.
All the dependencies were successfully compiled, and the target project compiled too.
When it comes to linking stage, I get numerous errors like
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcurl.a(libcurl_la-easy.o): in function `global_init':
(.text+0x94): undefined reference to `libssh2_init'
...
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcurl.a(libcurl_la-http2.o): in function `on_header':
(.text+0x6c): undefined reference to `nghttp2_session_get_stream_user_data'
...
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcurl.a(libcurl_la-socks_gssapi.o): in function `check_gss_err.part.0':
(.text+0x57): undefined reference to `gss_release_buffer'
/usr/bin/ld: (.text+0x77): undefined reference to `gss_display_status'
/usr/bin/ld: (.text+0x9b): undefined reference to `gss_release_buffer'
/usr/bin/ld: (.text+0xcf): undefined reference to `gss_release_buffer'
/usr/bin/ld: (.text+0xef): undefined reference to `gss_display_status'
/usr/bin/ld: (.text+0x112): undefined reference to `gss_release_buffer'
/usr/bin/ld: (.text+0x17e): undefined reference to `gss_release_buffer'
...
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcurl.a(libcurl_la-curl_rtmp.o): in function `rtmp_connect':
(.text+0xd4): undefined reference to `RTMP_Connect1'
...
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcurl.a(libcurl_la-openldap.o): in function `ldap_connecting':
(.text+0x111): undefined reference to `ldap_result'
There is at least a hundred of such errors. I'm not at all proficient with Linux and complex building of projects. How do I possibly fix linking errors for libraries that I just downloaded through a package manager?
EDIT: Libraries, that cmake seems to link against at the end:
braft;
brpc;
/usr/lib/x86_64-linux-gnu/libleveldb.a;
glog;
h2o-evloop;
iconv;
/usr/lib/x86_64-linux-gnu/libcurl.a;
for;
/usr/lib/x86_64-linux-gnu/libicui18n.a;
/usr/lib/x86_64-linux-gnu/libicuuc.a;
/usr/lib/x86_64-linux-gnu/libicudata.a;
rocksdb;
/usr/lib/x86_64-linux-gnu/libsnappy.a;
/usr/lib/x86_64-linux-gnu/libz.a;
rt;
/usr/lib/x86_64-linux-gnu/libssl.a;
/usr/lib/x86_64-linux-gnu/libcrypto.a;
pthread;
dl;
-static-libgcc;
-static-libstdc++;
gflags_shared;
/usr/lib/x86_64-linux-gnu/libprotobuf.a;
-lpthread
Your dependency list is incomplete. It only includes immediate dependencies.
Your version of libcurl is built with ssh, gssapi, nghttp2, ldap, rtmp and possibly other goodies, none of which you are linking against. You are using static linking, and static libraries do not have a built in concept of dependencies. This means you have to manually include all the non-immediate dependencies in your build command. You can get the impression of how many more libraries you need to include by executing this command
ldd /path/to/your/libcurl.so
and observing the list of dependencies your libcurl has.
The same thing may be true about other libraries you use.
One way to resolve the issue is to use dynamic linking. This way you just link to immediate dependencies, and they know their dependencies.

Undefined references when compiling project with libvpx

I've build libvpx.a and headers with MSYS (for MinGW). When I'm trying to compile an example a lot of undefined references to vpx members occurs:
g++ -m32 -static -o dist/Debug/MinGW-Windows/test1 build/Debug/MinGW-Windows/main.o -L/D/Libraries/libvpx/ -lvpx
build/Debug/MinGW-Windows/main.o: In function `main':
D:\Projects\CPP_test\Test1/main.cpp:107: undefined reference to `die'
D:\Projects\CPP_test\Test1/main.cpp:109: undefined reference to `vpx_video_reader_open'
D:\Projects\CPP_test\Test1/main.cpp:111: undefined reference to `die'
D:\Projects\CPP_test\Test1/main.cpp:114: undefined reference to `die'
D:\Projects\CPP_test\Test1/main.cpp:116: undefined reference to `vpx_video_reader_get_info'
D:\Projects\CPP_test\Test1/main.cpp:118: undefined reference to `get_vpx_decoder_by_fourcc'
D:\Projects\CPP_test\Test1/main.cpp:120: undefined reference to `die'
D:\Projects\CPP_test\Test1/main.cpp:125: undefined reference to `die_codec'
D:\Projects\CPP_test\Test1/main.cpp:127: undefined reference to `vpx_video_reader_read_frame'
D:\Projects\CPP_test\Test1/main.cpp:132: undefined reference to `vpx_video_reader_get_frame'
D:\Projects\CPP_test\Test1/main.cpp:134: undefined reference to `die_codec'
D:\Projects\CPP_test\Test1/main.cpp:137: undefined reference to `vpx_img_write'
D:\Projects\CPP_test\Test1/main.cpp:144: undefined reference to `die_codec'
D:\Projects\CPP_test\Test1/main.cpp:149: undefined reference to `vpx_video_reader_close'
All includes made, lib is linked...
So what am I doing wrong?
PS: Maybe it's not enough to link the libvpx.a file, and I also need the .c files that come with the sources (if so, I do not understand what for the .a lib file is needed)?
It looks like you just copied and pasted blindly from the example.
The functions die_codec and vpx_video_* all come from tools_common.c (https://github.com/webmproject/libvpx/blob/master/tools_common.c) and video_reader.h (https://github.com/webmproject/libvpx/blob/master/video_reader.c), which I believe is not a core part of the libvpx sdk (see here: http://www.webmproject.org/docs/webm-sdk/files.html).
In order for your example to work, you will need to copy-paste those files (both the .c and .h files) as well and include them in your main.cc file.

boost-1.55.0 undefined reference to `boost::thread::join() even after linking with the correct library

I get undefined symbol reference errors even after linking with the correct boost library:
undefined reference to `boost::thread::join()
undefined reference to `boost::thread::start_thread()
nm libboost_thread.so -Cg|grep boost::thread::join shows
000000000000ce00 T boost::thread::join_noexcept()
000000000000c1a0 T boost::thread::joinable() const
What happened to join() ?
boost::thread::join() is an inline function now.
Your build system probably does not maintain dependencies on system headers and ends up linking object files compiled against an older version of boost. Do a full rebuild.

Eclipse integrate with qt

i download qt and eclipse with c++ cdt , i see that qt come with qt ide (qt creator) , to develop qt appliation and that fine , but i want to do this wit eclipse , i mean use c++ code with qt inside eclipse . is there any ? because i am trying to use qt to design my user interface only and using other code from other libraries to do other things .
i try to include header files (usr/include/qt4) , but i still have a problem when i compile the program such us ( can't find qgui.h ) any help the integrate qt with eclipse like netbeans .
edit :
here is my output
13:48:48 **** Incremental Build of configuration Debug for project test ****
Info: Internal Builder is used for build
g++ -o test src/test.o -lQtCore
src/test.o: In function `main':
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:6: undefined reference to `QApplication::QApplication(int&, char**, int)'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:8: undefined reference to `QPushButton::QPushButton(QString const&, QWidget*)'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QApplication::exec()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QPushButton::~QPushButton()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QApplication::~QApplication()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:8: undefined reference to `QPushButton::~QPushButton()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QPushButton::~QPushButton()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QApplication::~QApplication()'
src/test.o: In function `QWidget::resize(int, int)':
/usr/include/qt4/QtGui/qwidget.h:996: undefined reference to `QWidget::resize(QSize const&)'
collect2: error: ld returned 1 exit status
13:48:49 Build Finished (took 1s.609ms)
I had to adjust the following settings in "Project Properties => C/C++ General => Paths and Symbols":
On the "Includes" tab, for the GNU C++ language, add the following include paths:
/usr/include/qt4
/usr/include/qt4/QtCore
/usr/include/qt4/QtGui
On the "Symbols" tab, for the GNU C++ language, define the following symbols with a value of "1" (might be different for you, but at least the QT_CC_GNU, QT_CORE_LIB and QT_GUI_LIB are necessary):
QT_CC_GNU
QT_CORE_LIB
QT_GUI_LIB
QT_NO_DEBUG
QT_SHARED
QT_TESTLIB_LIB
QT_WEBKIT
With these settings, the source indexer works well. Other than that, Eclipse is simply calling "make" for the build.

c++, MingW, undefined reference to `libiconv'

I'm getting these errors with MingW:
undefined reference to `libiconv_close'
undefined reference to `libiconv_open'
undefined reference to `libiconv'
I have the libiconv package from MingW installed. What is causing this? If this is of some importance, I'm trying to get tinygettext working.
You must have forgotten to add -liconv to the link line. Adding that there should resolve those problems.