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

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.

Related

How to install Boost from source

I am trying to install the Boost C++ from source.
I first tried using yum to install them in (Amazon Linux AMI) but it installed a version that is too old. I need at least version 1.54
So I tried to follow the instructions here:
https://www.boost.org/doc/libs/1_70_0/more/getting_started/unix-variants.html
Once I downloaded the source, I tried symlinking the header files to /usr/include:
ln -s /root/boost_1_70_0/boost /usr/include/boost
Then I followed the instructions to try to build:
cd /root/boost_1_70_0
./bootstrap.sh
./b2 install
Then when I try to compile my program that needs boost libraries (happens to be OSRM), I get this error:
make[2]: *** No rule to make target `/usr/lib64/libboost_date_time-mt.so', needed by `osrm-components'. Stop.
So it seems somehow I need to build the boost .so files to go in /usr/lib64. But how do I do that?
I believe that you've already built the boost .so files but I don't know where. It normally tries to install them in /usr/local, see section 5.1 of the instructions you referenced.
You may be able to find them with locate, e.g.:
locate boost
Otherwise, you can call ./bootstrap.sh with a prefix indicating where you want it to build the libraries, e.g.:
./bootstrap.sh --prefix=/root/boost_1_70_0/stage
./b2 install
You can then copy the .so files together with with their symbolic links to /usr/lib64, e.g.:
cd /usr/lib64
rm -fr libboost*
cp -a /root/boost_1_70_0/stage/lib/libboost* .
chmod a+x libboost*
Note: the line rm -fr libboost* in /usr/lib64 is to remove the very old version of boost that you installed with yum.

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

CMake/Make cannot find libusb

I'm new to C/C++ and am trying to build and run ttwatch from github locally on an Ubuntu machine (Trusty Tahr). Instructions include installing some libraries first: cmake, openssl, curl, libusb, and include a note to install the "-dev" versions (eg. libssl-dev, libcurl-dev, libusb-1.0-0-dev). I'm having some trouble with libusb. I see questions about this all over the internet, but haven't yet found a solution that works.
Running cmake . appears to work fine:
meowmeow#kittytown:~/code/ttwatch$ cmake .
-- Enabled daemon function
-- Found libusb-1.0:
-- - Includes: /usr/include/libusb-1.0
-- - Libraries: /usr/lib/x86_64-linux-gnu/libusb.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/meowmeow/code/ttwatch
But running make shows that libusb is not being located properly:
meowmeow#kittytown:~/code/ttwatch$ make
[ 42%] Built target libttbin
[ 42%] Built target libttwatch
[ 42%] Built target ttbincnv
[ 42%] Built target ttbinmod
[ 42%] Built target manifest
Linking CXX executable ttwatch
CMakeFiles/ttwatch.dir/src/ttwatch.c.o: In function `main':
/home/meowmeow/code/ttwatch/src/ttwatch.c:1618: undefined reference to `libusb_init'
/home/meowmeow/code/ttwatch/src/ttwatch.c:1796: undefined reference to `libusb_exit'
...
If I check /usr/includes/, I see libusb:
meowmeow#kittytown:~/code/ttwatch$ ls /usr/include/libusb-1.0/libusb.h
/usr/include/libusb-1.0/libusb.h
And dpkg shows:
meowmeow#kittytown:~/code/ttwatch$ dpkg -L libusb-1.0-0-dev
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/libusb-1.0.pc
/usr/lib/x86_64-linux-gnu/libusb-1.0.a
/usr/share
/usr/share/doc
/usr/share/doc/libusb-1.0-0-dev
/usr/share/doc/libusb-1.0-0-dev/copyright
/usr/include
/usr/include/libusb-1.0
/usr/include/libusb-1.0/libusb.h
/usr/lib/x86_64-linux-gnu/libusb-1.0.so
/usr/share/doc/libusb-1.0-0-dev/README
/usr/share/doc/libusb-1.0-0-dev/changelog.Debian.gz
meowmeow#kittytown:~/code/ttwatch$ dpkg -L libusb-1.0-0
/.
/lib
/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libusb-1.0-0
/usr/share/doc/libusb-1.0-0/README
/usr/share/doc/libusb-1.0-0/copyright
/usr/share/doc/libusb-1.0-0/changelog.Debian.gz
/lib/x86_64-linux-gnu/libusb-1.0.so.0
The file ttwatch/includes/libttwatch.h includes libusb as #include <libusb.h>, and I've tried modifying that to #include <libusb-1.0/libusb.h>, in hopes of better matching my /usr/includes/ files, but that didn't change the error output.
Any help would be greatly appreciated!
EDIT:
Using make VERBOSE=1does show -lusb, and not -lusb-1.0:
...
/usr/bin/c++ -g CMakeFiles/ttwatch.dir/src/ttwatch.c.o CMakeFiles/ttwatch.dir/src/log.c.o CMakeFiles/ttwatch.dir/src/options.c.o CMakeFiles/ttwatch.dir/src/json.c.o CMakeFiles/ttwatch.dir/src/download.c.o CMakeFiles/ttwatch.dir/src/firmware.c.o CMakeFiles/ttwatch.dir/src/misc.c.o CMakeFiles/ttwatch.dir/src/get_activities.c.o CMakeFiles/ttwatch.dir/src/update_gps.c.o CMakeFiles/ttwatch.dir/src/set_time.c.o -o ttwatch -rdynamic libttwatch.a libttbin.a -lusb -lssl -lcrypto -lcurl
And libusb.so appears to exist:
meowmeow#kittytown:~/code/ttwatch$ dpkg-query -S /usr/lib/x86_64-linux-gnu/libusb.so
libusb-dev: /usr/lib/x86_64-linux-gnu/libusb.so
I tried uninstalling libusb-dev (sudo apt-get remove libusb-dev) and installed libusb-1.0 (sudo apt-get install libusb-1.0) to see if that would solve the issue. I now have a /usr/lib/x86_64-linux-gnu/libusb-1.0.so (note the 1.0) instead, but am now getting this from make:
make[2]: *** No rule to make target /usr/lib/x86_64-linux-gnu/libusb.so', needed by ttwatch'. Stop.
I was not aware that Debian has the packages libusb-dev and
libusb-1.0-dev. From the package information I cannot tell why there are 2
packages for the same library, perhaps libusb-dev is an older version with a
different API and other packages might still have that as a dependency. So
removing the package might not be a good idea, unless you don't care/need
packages depending on libusb-dev, in which case you can do apt-get purge
libusb-dev && apt-get autoremove. Be ware that this might uninstall
packages that you need. So do it only if you know what you are doing.
I did not expect that Debian allows you to install both packages at the same
time, but this could be if the APIs of both libraries are different and don't
conflict with each other.
This seems to confuse cmake, which somehow cannot handle when both libraries
are simultaneously installed. I've gone through the issues page and I
haven't found an issue relating to that. So if you cannot manage to build it,
I'd suggest that you go to the issue page, if you don't have an github
account, create one and leave a bug report about building the package when
libusb-dev and libusb-1.0-dev are simultaneously installed.
Another option would be to make a small modification in the file cmake_modules/FindLibUSB.cmake before you do
$ mkdir build && cd build
$ cmake ..
Find the line find_library(LIBUSB_1_LIBRARY, on the current stable version it is line 62. The next line is NAMES
and the next line is usb-1.0 usb. Remove the usb from that, so that
find_library only searches for libusb-1.0. Save the file and then you can do
$ mkdir build && cd build
$ cmake ..
This should fix the problem.

How to Install Wt into a Custom Folder Without "fatal error: Wt/WApplication: No such file or directory"

I'm new to Wt and c++ and I just installed the Wt webframework on Ubuntu 16.04 LTS into a custom folder in my home directory. I cannot install or build any software into the /usr diretories of this computer. Even if I could, the PPA hasn't been active for 2 1/2 years, and the official Ubuntu installation instructions are also outdated. Aptitude no longer ships with Ubuntu and will eventually be discontinued.
I compliled and installed everything successfully, yet when I try to compile the Hello World example I get the following error:
g++ -o hello hello.cpp -lwt -lwthttp
fatal error: Wt/WApplication: No such file or directory
Here are my installation steps:
Boost:
wget https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.tar.bz2
tar --bzip2 -xf boost_1_65_1.tar.bz2
cd boost_1_65_1
./bootstrap.sh --prefix=../myfolder
sudo ./b2 install --prefix=../myfolder
CMake:
wget https://cmake.org/files/v3.9/cmake-3.9.2.tar.gz
tar -xvzf cmake-3.9.2.tar.gz
cd cmake-3.9.2
./configure --prefix=../myfolder
make
sudo make install
vim .profile
export PATH=$PATH:/home/ubuntu/myfolder/bin
Wt:
git clone https://github.com/emweb/wt.git
cd wt
cmake -DCMAKE_INSTALL_PREFIX:PATH=../myfolder .
-- Generating done
-- Build files have been written to: /home/ubuntu/myfolder
make
sudo make install
make -C examples
Since I'm lumping everything together in /myfolder I did not use the /build folder per the Wt installation instructions. The libwt and libboost libraries are in /myfolder/lib. I assumed all of the linking was taken care of during installation.
Any thoughts? Thanks in advance.
You have to tell your compiler to look for includes and libraries in the right folders, so instead of:
g++ -o hello hello.cpp -lwt -lwthttp
Try:
g++ -o hello hello.cpp -I/home/ubuntu/myfolder/include -L/home/ubuntu/myfolder/lib -lwt -lwthttp
Note that when you run your application, you'll also have to make sure that it can find the dynamic libs (.so files) it needs. You could do this:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/ubuntu/myfolder/lib"

configure: error: no boost.filesystem library found

So I'm trying to install ncmpcpp though this github, and the first step is to run the sh autogen.sh script. I've run into a few missing libraries, etc., but I've been able to install them and move on- up until now. I've done some searching and installed a handful of things I thought would help fix it, but to no avail.
sudo apt-get install libboost1.55-all-dev
sudo apt-get install libboost-system-dev
sudo apt-get install libboost-system1.54-dev
sudo apt-get install libboost1.54-dev
sudo apt-get install libboost-filesystem-dev
sudo apt-get install libboost-filesystem-dev libboost-thread-dev
Truth is I don't know enough about Boost or what I'm missing to fix it on my own.
This is where the problem starts:
checking for boost/filesystem.hpp... yes
checking for main in -lboost_filesystem-mt... no
configure: error: no boost.filesystem library found
edit: Here are the surrounding lines to '-lboost_filesystem-mt' in the config.log file.
configure:15510: checking for main in -lboost_filesystem-mt
configure:15529: g++ -o conftest -g -O2 -std=c++0x conftest.cpp -lboost_filesystem-mt >&5
/usr/bin/ld: cannot find -lboost_filesystem-mt
collect2: error: ld returned 1 exit status
configure:15529: $? = 1
configure: failed program was:
| /* confdefs.h */
... and then it goes on to describe the confdefs.h file.
Remove these linkes from configure.ac (section "setting boost environment"):
AS_IF([test -z "${BOOST_LIB_SUFFIX+x}"], [BOOST_LIB_SUFFIX=-mt])
AC_ARG_VAR([BOOST_LIB_SUFFIX], [Boost library name suffix [default=-mt]])
Long ago, the Boost libraries used to have a -mt suffix to indicate that they were multithreading-aware. Debian/Ubuntu dropped this years ago. Maybe other distributions retained it. The Boost library names were never very standardized in any case, which is why configure scripts often try do deal with them, often in broken ways.
You can either remove these two lines or call it like this:
$ BOOST_LIB_SUFFIX="" ./autogen.sh
The proper fix is to convert the script to use the Boost macros from the Autoconf Archive.