CMake Link Library Fails in the Docker image - c++

When building the docker image of a c++ project I'm facing issues when compiling the project inside the docker image because of a library linking issue
Docker file which is in the https://github.com/chinthakarukshan/jasminegraph/tree/master/docker location builds a docker image on top of ubuntu base image installing the necessary libraries required by the project. When compiling the project I'm getting a library linking issue and fails building the project with below error.
/usr/bin/ld: cannot find -lsqlite3
collect2: error: ld returned 1 exit status
make[3]: *** [JasmineGraph] Error 1
sqlite3 library is already installed in the Dockerfile. But it fails when linking the library.
Below is the cmake code which links the sqlite3 library with the project.
target_link_libraries(JasmineGraph sqlite3)
Below is the link to the corresponding CMakeList file.
https://github.com/chinthakarukshan/jasminegraph/blob/master/CMakeLists.txt

You need to install dev version:
RUN apt-get install -y libsqlite3-dev

Related

Linking problems with dlib: recompile with -fPIC

I would like to use this ROS package which relies on dlib. I compile with catkin build, but I get this error in linking I guess:
/usr/bin/ld: /usr/lib/libdlib.a(threads_kernel_shared.o): relocation R_X86_64_PC32 against symbol `_ZN4dlib21threads_kernel_shared14thread_starterEPv' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [/home/alberto/tiago_dual_public_ws/devel/.private/gazr/lib/libgazr.so] Error 1
make[1]: *** [CMakeFiles/gazr.dir/all] Error 2
make: *** [all] Error 2
I have installed dlib using sudo apt-get install libdlib-dev on my Ubuntu 18.05 (ROS Melodic) machine. How can I solve this problem? Documentation of dlib and the repo instruction does not help me a lot.
Thanks in advance.
I found 2 possible solution to the problem.
Installing dlib with sudo apt-get install libdlib-dev
In this case you should link dlib to your library target like target_link_libraries(gazr dlib ${OpenCV_LIBRARIES})
Rememberto use find_package(dlib REQUIRED)
Installing dlib from source
It's also possible to use directly the dlib source file. In this case you need to add the dlib source directory to the project using add_subdirectory(your_path/dlib dlib) and add it to the library target_link_libraries(gazr dlib ${OpenCV_LIBRARIES}).
ATTENTION: In this case you shall not use find_package(dlib REQUIRED)
Hope this is helpful!

Qt error cannot find -lQtCore -lQtGui -lQtTest -QtOpenGl -lcore on linux ubuntu 16.04

I am using Qt 5.12.2 on a linux ubuntu 16.04 and when I execute a program I get an error saying that it is not finding -lQtCore, -lQtGui, -lQtTest, -lQtOpenGl and -lcore and I also get
collect2 error: ld returned 1 exit status.
What can i do to fix this?
I have already tried solving this using the command sudo apt-get install libglu1-mesa-dev and sudo apt-get install mesa-common-dev
It appears that you do not have the Qt5 libraries installed on your system. The libraries are included with the Qt Creator runtime, so it can always find them. When you run an executable outside of Qt Creator, you must (typically) copy the libraries required to the folder where the executable has been placed.
Check out the details in the docs.
https://doc.qt.io/qt-5/linux-deployment.html

compiling code with opencv - /usr/bin/ld: cannot find -lippicv

When compiling some code with opencv I get this error
# g++ txtbin-03.1.cpp -o txtbin `pkg-config opencv --cflags --libs`
/usr/bin/ld: cannot find -lippicv
collect2: error: ld returned 1 exit status
installing opencv
# apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
# apt-get install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
# cd /var/bin && git clone https://github.com/Itseez/opencv.git && cd opencv
# cmake . && make -j2 && make install
In my case, all it took was to copy libippicv.a from the OpenCV SDK to /usr/local/lib:
sudo cp 3rdparty/ippicv/unpack/ippicv_lnx/lib/intel64/libippicv.a /usr/local/lib/
Recompiling whole library isn't necessary, especially if you don't need this library. I found great and instantly working solution here. In case link expired or broke:
The solution is simply to remove -lippicv from opencv pkg-config configuration file. So you have to locate opencv.pc file, which default is in /usr/local/lib/pkgconfig/ directory. Then from section Libs: just remove aforementioned library.
Recompile OpenCv using following option:
cmake -DWITH_IPP=ON . && make -j $(nproc) && make install
libippicv.a is a third party library, so you need to explicitly provide it during compilation or make it part of your execution environment.
It is located in ~/OpenCV/opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_lnx/lib/intel64/
Also, provide cmake -DWITH_IPP=ON at the time of Makefile generation.
I was running into the same problem while trying to install the opencv_contrib repository (opencv-3.1.0/Ubuntu 16.04), and none of the solutions worked (I tried to make OpenCV with flag WITH_IPP=ON, but somehow OpenCV 3.1.0 failed to download the ippicv library(?) and there was no error prompt so I only figured this out when I tried to locate ippicv in terminal).
My solution was to download another OpenCV build (3.0.0 worked for me), make + make install with flag WITH_IPP=ON, and then copy the downloaded ippicv library (which should be located in /usr/local/share/OpenCV/3rdparty/lib/libippicv.a by now) to /usr/local/lib/.
I don't know if this is a known bug in OpenCV 3.1.0, but this one is definitely worth keeping an eye out for.

c++ LAPACK library not detected whereas it's installed

I have installed the lapack library using the following commands:
sudo apt-get install liblapack-dev
In synaptic I have checked if everything was installed and it sounds good:
I would like to compile the g2o library which use liblaback but by doing cmake I have the following output:
CMake Error at cmake_modules/FindLAPACK.cmake:247 (message): A
required library with LAPACK API not found. Please specify library
location. Call Stack (most recent call first): CMakeLists.txt:75
(FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
I'm pretty sure that It's not because the CmakeList file and all the Cmake file including for example the FindLAPACK.cmake (can find it there) file because I remember to have compiled it well before using another computer with Ubuntu 14.04.
So now I don't know what is the problem. I tried to uninstall, purge and then install it again but still the same issue.
I also checked the /etc/ld.so.conf in case and it contains
include /etc/ld.so.conf.d/*.conf
/usr/local/lib
I did then to be sure
sudo ldconfig -p
I noticed that the library is on /usr/lib
For example:
/usr/lib/liblapack.so
/usr/lib/liblapack.so.3
/usr/lib/liblapack.so.3gf
/etc/alternatives/liblapack.so /etc/alternatives/liblapack.so.3
/etc/alternatives/liblapack.so.3gf /usr/lib/liblapack.so
/usr/lib/liblapack.so.3 /usr/lib/liblapack.so.3gf
/usr/lib/atlas-base/atlas/liblapack.so
/usr/lib/atlas-base/atlas/liblapack.so.3
/usr/lib/atlas-base/atlas/liblapack.so.3.0
/usr/lib/lapack/liblapack.so /usr/lib/lapack/liblapack.so.3
/usr/lib/lapack/liblapack.so.3.0
/var/lib/dpkg/alternatives/liblapack.so
/var/lib/dpkg/alternatives/liblapack.so.3
If I take a look on the Cmake file error, I have those lines inside:
/usr/bin/ld: /usr/local/lib/liblapack.a(xerbla.f.o): undefined
reference to symbol '_gfortran_string_len_trim##GFORTRAN_1.0'
//usr/lib/x86_64-linux-gnu/libgfortran.so.3: error adding symbols: DSO
missing from command line collect2: error: ld returned 1 exit status
But I checked and Gfortran is well installed also.
Do you have any idea ? I getting crazy about it.

Building OpenBlas with msys2

I have a windows 7-64bit computer and I am trying to build OpenBlas library through Msys2.
There seems to be some problem with the gcc as after installing minGW and unziped OpenBlas folder, I open msys2 and I navigate to the folder where OpenBlas is located. I type the command make and I get this error:
make: gcc: Command not found
make: *** [getarch] Error 127
See our PKGBUILD for openblas:
https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-openblas/PKGBUILD#L33