3

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.

22
  • The linker is looking for libicui18n.so.58, libicuuc.so.5 and libicudata.so.58, but doesn't find them. If you do not have them installed, then you will need to do so. If you do have them installed, then you'll need to tell the linker how to find them by extending the linker load path as in here:stackoverflow.com/a/40327731/4640820 Mar 3, 2018 at 22:29
  • @TomášPospíšek, thanks for the input. I don't think it's those libraries because I checked darknet's 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?
    – raggot
    Mar 4, 2018 at 10:26
  • If you want this on Stack Overflow instead, simply delete it here and repost it there. That's better than migrating anyway since that way the question will appear as newly asked on SO.
    – terdon
    Mar 4, 2018 at 13:42
  • 1
    "So, I might have 2 installations. I don't know how to verify this though." -> You can use find / -name 'libqt*'. Also you can do ẁhich qtdiag` and ldd $(which qtdiag). Mar 5, 2018 at 7:51
  • @TomášPospíšek, thanks a lot for the suggestions! I think 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 feeling make is looking in the wrong place. In any case, I tried to add the folders I got using find to LD_LIBRARY_PATH and tried to make again, but no luck :(
    – raggot
    Mar 6, 2018 at 19:18

2 Answers 2

2

In short: I solved the problem by rebuilding OpenCV from scratch. Credit for this solution goes to user Tomáš Pospíšek.

The installation of OpenCV relied on the Python3 installation and packages of Anaconda instead of root. No matter the content of PATH, PYTHONPATH, or LD_LIBRARY_PATH, and regardless the fact I had renamed the anaconda folder to anaconda_renamed to avoid it being ever found, OpenCV itself was built to rely on Anaconda's packages. Not surprisingly, at this point they were not found.

The problem has not been easy to fix, as even when I tried to rebuild OpenCV from scratch using the standard cmake installation instruction by OpenCV, Anaconda still ended up in the path. However, by using cmake-gui, and by searching for anaconda in the fields, I managed to find where it was used.

After several attempts to gracefully solve this issue by linking the fields of cmake away from anaconda, and seeing how by default CMake kept finding Anaconda packages here and there, I ended up deleting Anaconda from my system, pulling the latest version of opencv and opencv-contrib and following OpenCV's installation instructions once again.

The make process resulted in some errors with some packages of CUDA (something like cudaarithm and cudatest). Excluding them from the build using cmake-gui worked. I hope I will never regret these exclusions.

PS: if other unlucky users will also find that their make -j4 command results into the building process getting stuck at 99% for hours, try make -j1 instead.

1
0

I had different software complain it wasn't finding qt files and PATH was set to the correct bin directory and LD_LIBRARY_PATH was set to the correct lib directory. The problem was that PATH didn't also point to the include directory for QT. I added both the include directory and the include/Qt directory. Then I ran configure on opencv and make. Then my program was able to compiles.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .