Before starting, I would like to point out there actually is a very similar (probably exactly identical) question. However, I have been unable to solve my problem looking at the accepted answers.
I followed the instructions provided by this website to install OpenCV3 on Ubuntu 16.04. I reached the point where I tried to compile a test program (section 6) with g++. The compilation returns this:
/usr/bin/ld: warning: libicui18n.so.58, needed by //home/raggot/anaconda3/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libicuuc.so.58, needed by //home/raggot/anaconda3/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libicudata.so.58, needed by //home/raggot/anaconda3/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `u_errorName_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_setMillis_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_getAlias_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_inDaylightTime_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `u_strToLower_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_getStandardName_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `u_strToUpper_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_setSubstChars_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_getMaxCharSize_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_getTimeZoneDisplayName_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_fromUnicode_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_open_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_getDefaultName_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_getDefaultTimeZone_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_clone_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_getDSTSavings_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucol_strcoll_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_close_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_countAvailable_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_openCountryTimeZones_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucol_open_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_compareNames_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_close_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_getAvailableName_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_openTimeZoneIDEnumeration_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_open_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucol_setAttribute_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_openTimeZones_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `uenum_close_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_countAliases_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucol_close_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucol_getSortKey_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucal_get_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `uenum_next_58'
//home/raggot/anaconda3/lib/libQt5Core.so.5: undefined reference to `ucnv_toUnicode_58'
collect2: error: ld returned 1 exit status
Attempting to apply this answer to my problem, I tried to localise the installation path of Qt5 on my system. I did it by using dpkg --listfiles libqt5core5a
. I added the resulting path to LD_LIBRARY_PATH
, but it didn't help.
I tried reinstalling Qt5 by sudo apt install qt5-default
and also installed qttools5-dev
but it also did not help.
My problem might have something to do with the fact the compiler is using anaconda's library, while I am actually working in the global environment. Some more research showed also that my Qt5 installation using apt install
has version 5.5.1, while if I type qtdiag
I see version 5.6.2 showing up. That could be because at some point I might have installed Qt5 under anaconda as well. So, I might have 2 installations. I don't know how to verify this though.
What could be the cause of the problem?
Edit:
Thanks to the comments, I realised anaconda3
should not even be in the PATH
in the first place. With some hacking around, I found that it was added to the path at login in .bashrc
, probably because I asked so during the installation of Anaconda. I removed it and tried to make
again.
This is what I now see (extract of a very long output):
/usr/local/lib/libopencv_imgcodecs.so: undefined reference to `jpeg_stdio_dest@LIBJPEG_9.0'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QGraphicsView::staticMetaObject@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QSize::scaled(QSize const&, Qt::AspectRatioMode) const@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QWidget::update()@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QWidget::paintEngine() const@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QAbstractSlider::setMinimum(int)@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QCheckBox::minimumSizeHint() const@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QFileInfo::QFileInfo(QString const&)@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QWidget::hideEvent(QHideEvent*)@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QObject::connectNotify(QMetaMethod const&)@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `non-virtual thunk to QBoxLayout::hasHeightForWidth() const@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QWidget::isFullScreen() const@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QWidget::hasHeightForWidth() const@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QPen::QPen(QBrush const&, double, Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QStatusBar::showMessage(QString const&, int)@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QObject::customEvent(QEvent*)@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QObject::QObject(QObject*)@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QFont::setLetterSpacing(QFont::SpacingType, double)@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QGraphicsView::dragLeaveEvent(QDragLeaveEvent*)@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `typeinfo for QHBoxLayout@Qt_5'
/usr/local/lib/libopencv_highgui.so: undefined reference to `QGLWidget::~QGLWidget()@Qt_5'
This makes me think I now just miss something in the PATH
.
I found where these libraries are defined (in my installation of Qt5) in the subfolders of /usr/include/x86_64-linux-gnu/qt5/
, and subsequently added all of them to PATH
by means of export
commands in .profile
, and then run source .profile
. If I now run echo $PATH
I see them all in place.
Unfortunately, the error message is still the same if I run the make
command.
Edit #2:
After adding all subfolders containing the headers of Qt5 to PATH
, I tried to add a copy of PATH
in LD_LIBRARY_PATH
by doing
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PATH
Once again however, the error message did not change in nature. I really don't understand why the compiler doesn't see the Qt5 libraries.
make
error log and it doesn't refer to them (I edited my question to extend info there). I do think the path is missing or incorrect, but I don't know how to check or fix that. Would you have any suggestions on how I can find out what exact path I should provide, and where?find / -name 'libqt*'
. Also you can do ẁhich qtdiag` andldd $(which qtdiag)
.which qtdiag
brought me to the right direction. The answer is/home/raggot/anaconda3/bin/qtdiag
where I would have expected something at root level like/usr/lib/x86_64-linux-gnu/qt5/
. That strengthens my feelingmake
is looking in the wrong place. In any case, I tried to add the folders I got usingfind
toLD_LIBRARY_PATH
and tried tomake
again, but no luck :(