Error of compiling Caffe, related to openCV (I think)

119 views
Skip to first unread message

Fatemeh Vakhshiteh

unread,
May 27, 2016, 9:24:56 AM5/27/16
to Caffe Users
hello everyone
:I really need your helps solving the problem I faced in compiling Caffe, the following is the error message I get when I compile Caffe


.build_release/examples/cpp_classification/classification.o: In function `main':
classification.cpp:(.text.startup+0x1b7): undefined reference to `cv::imread(std::string const&, int)'
collect2: error: ld returned 1 exit status
make: *** [.build_release/examples/cpp_classification/classification.bin] Error 1
make: *** Waiting for unfinished jobs....


Thanks a lot
Fatemeh

Hossein Hasanpour

unread,
May 27, 2016, 10:53:00 AM5/27/16
to Caffe Users
Hello,
Did you configure OpenCV properly? is it even installed?!

Fatemeh Vakhshiteh

unread,
May 27, 2016, 11:27:20 AM5/27/16
to Caffe Users
I have downloaded and installed opencv-3.1.0 and follow a certain instruction (adding repositories, making a "release" folder, running cmake, and at the end compile it. the strange thing is that no errors are shown during compiling
 ?I searched through the net and figured out that some people states that this version of opencv causes some issues! is  this right

در جمعه 27 مهٔ 2016، ساعت 19:23:00 (UTC+4:30)، Hossein Hasanpour نوشته:

Hossein Hasanpour

unread,
May 27, 2016, 11:38:24 AM5/27/16
to Caffe Users
The reason you didnt get any compilation error is that, thats a linking issue it seems.
If you read farsi, you might want to have a look here ,if you dont, have a look at this step by step guide here

Fatemeh Vakhshiteh

unread,
May 27, 2016, 11:59:40 AM5/27/16
to Caffe Users
thanks! 
one more question and I will follow the steps ... what if I have installed some applications, libraries, etc and then follow the these steps again? for example, I have installed cuda but not like the way mentioned in the steps you suggested. should I do this particular step again or skip it? If I want to go through all these steps  again?  does that mean I have to uninstall those first and install again? thanks
در جمعه 27 مهٔ 2016، ساعت 20:08:24 (UTC+4:30)، Hossein Hasanpour نوشته:

Hossein Hasanpour

unread,
May 27, 2016, 12:03:05 PM5/27/16
to Caffe Users
not necessarily, most of the time its not how they are installed, rather, its how they are configured. so the first step would be to try the configuration part and if that didnt help,
either ask questions regarding the specific issue or, yet easier follow the guide completely from the very start.

Fatemeh Vakhshiteh

unread,
May 27, 2016, 12:32:54 PM5/27/16
to Caffe Users
So there is possibility that I have done something wrong in configuring phase of openCV, which might be repeated if I follow the steps you suggested. for this reason, would you please briefly let me know what I should do regarding configuration?

I did the following:

installing repositories:
sudo apt-get install libxine-dev
sudo apt-get install libxine2-dev
sudo apt-get install qt-sdk cmake libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils libpng-dev libtiff-dev qt5-default libvtk6-dev zlib1g-dev libwebp-dev libtiff5-dev libopenexr-dev libgdal-dev libx264-dev libxine2-dev libeigen3-dev python-dev python-tk python-numpy python3-dev python3-tk python3-numpy ant default-jdk doxygen
sudo apt-get -qq remove ffmpeg x264 libx264-dev
sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg gstreamer0.10-ffmpeg

extracting opencv zip file:
OpenCVver="opencv-3.1.0"
unzip  $OpenCVver -d ~/Develop
cd ~/Develop/$OpenCVver
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

coppying ippcv zip file :
OpenCVver="opencv-3.1.0"
cp ippicv_linux_20151201.tgz ~/Develop/$OpenCVver/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

compiling opencv:
OpenCVver="opencv-3.1.0"
cd ~/Develop/$OpenCVver/release
make -j $(nproc)
sudo make install -j $(nproc)
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo sh -c 'echo "/usr/local/lib">/etc/ld.so.conf.d/opencv.conf'
sudo ldconfig

sudo ln -s ~/Develop/$OpenCVver/release/lib/cv2.so /usr/lib/python2.7/dist-packages/cv2.so


 

در جمعه 27 مهٔ 2016، ساعت 20:33:05 (UTC+4:30)، Hossein Hasanpour نوشته:

Hossein Hasanpour

unread,
May 27, 2016, 12:58:12 PM5/27/16
to Caffe Users
You should have a look at your make.config file as I have already said, its probably a linker issue, and that means your make.config file misses something.
you would want to check your opencv section in make.config against the one in the guide.

Fatemeh Vakhshiteh

unread,
May 27, 2016, 1:55:33 PM5/27/16
to Caffe Users
 ?where can I find make.config file 

در جمعه 27 مهٔ 2016، ساعت 21:28:12 (UTC+4:30)، Hossein Hasanpour نوشته:

Hossein Hasanpour

unread,
May 27, 2016, 2:35:17 PM5/27/16
to Caffe Users
its actually makefile not make (Makefile.config.example to be exact), which you need to change to Makefile.config and then do the needed changes there and then initiate the compilation process. 
you probably know about that right? since without it you wouldn't be able to start the compilation process in first place!

Fatemeh Vakhshiteh

unread,
May 27, 2016, 4:03:00 PM5/27/16
to Caffe Users
I am not that expert, but I do my best

:By the way, would you please explain these two lines

Add <installpath> to your build and link process by adding -I<installpath> to your compile
    line and -L<installpath> -lcudnn to your link line

I do really appreciate it 


در جمعه 27 مهٔ 2016، ساعت 23:05:17 (UTC+4:30)، Hossein Hasanpour نوشته:

Hossein Hasanpour

unread,
May 27, 2016, 4:52:49 PM5/27/16
to Caffe Users
those lines apparently show how one should carry out a compilation process involving cudnn library, but out of context I have no more to say, I'm not a linux expert by the way, 
as a side note, we do have an official windows version, and almost everything is taken care of automatically. 
all prerequisites except cudnn and cuda toolkit are downloaded using nuget, the compilation is done using Visual Studio 2013 and its the easiest way of getting caffe to work at the moment imho.

Felix Abecassis

unread,
May 27, 2016, 8:23:59 PM5/27/16
to Caffe Users
Reply all
Reply to author
Forward
0 new messages