caffe icon indicating copy to clipboard operation
caffe copied to clipboard

Error: 'make all' 'make test'

Open ankitdhall opened this issue 11 years ago • 45 comments

I ran

cd caffe cp Makefile.config.example Makefile.config make all make test make runtest

as suggested on a website to complete the installation. I am a beginner and have recently installed Ubuntu 14.04 and I am running Caffe without CUDA/GPU. Most of the tests seem to be running without a problem. Help would be greatly appreciated. I encountered the following(seems to show some kind of error):

ankit@Ankit:~/caffe$ make all CXX/LD -o .build_release/tools/convert_imageset.bin .build_release/lib/libcaffe.so: undefined reference to cv::imread(cv::String const&, int)' .build_release/lib/libcaffe.so: undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator >&, std::vector<int, std::allocator > const&)' .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)' collect2: error: ld returned 1 exit status make: *** [.build_release/tools/convert_imageset.bin] Error 1

ankit@Ankit:~/caffe$ make test CXX/LD -o .build_release/test/test_all.testbin src/caffe/test/test_caffe_main.cpp

LD .build_release/src/caffe/test/test_threshold_layer.o .build_release/lib/libcaffe.so: undefined reference to cv::imread(cv::String const&, int)' .build_release/lib/libcaffe.so: undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator >&, std::vector<int, std::allocator > const&)' .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)' collect2: error: ld returned 1 exit status make: *** [.build_release/test/test_threshold_layer.testbin] Error 1 ankit@Ankit:~/caffe$

What could possibly be the problem here. Seems like some dependency error or incorrect path.(OpenCV maybe) Thanks! Regards, Ankit

ankitdhall avatar Apr 22 '15 11:04 ankitdhall

is opencv installed?

On Wed, Apr 22, 2015 at 5:01 PM, Ankit Dhall [email protected] wrote:

I ran

cd caffe cp Makefile.config.example Makefile.config make all make test make runtest

as suggested on a website to complete the installation. I am a beginner and have recently installed Ubuntu 14.04 and I am running Caffe without CUDA/GPU. Most of the tests seem to be running without a problem. Help would be greatly appreciated. I encountered the following(seems to show some kind of error):

ankit@Ankit:~/caffe$ make all CXX/LD -o .build_release/tools/convert_imageset.bin .build_release/lib/libcaffe.so: undefined reference to cv::imread(cv::String const&, int)' .build_release/lib/libcaffe.so: undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector >&, std::vector > const&)' .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)' collect2: error: ld returned 1 exit status make: *** [.build_release/tools/convert_imageset.bin] Error 1

ankit@Ankit:~/caffe$ make test CXX/LD -o .build_release/test/test_all.testbin src/caffe/test/test_caffe_main.cpp

LD .build_release/src/caffe/test/test_threshold_layer.o .build_release/lib/libcaffe.so: undefined reference to cv::imread(cv::String const&, int)' .build_release/lib/libcaffe.so: undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector >&, std::vector > const&)' .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)' collect2: error: ld returned 1 exit status make: *** [.build_release/test/test_threshold_layer.testbin] Error 1 ankit@Ankit:~/caffe$

What could possibly be the problem here. Seems like some dependency error or incorrect path.(OpenCV maybe) Thanks! Regards, Ankit

— Reply to this email directly or view it on GitHub https://github.com/BVLC/caffe/issues/2348.

jmozah avatar Apr 22 '15 12:04 jmozah

Yes, it is OpenCV

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler libatlas-base-dev sudo apt-get install python-dev python-pip gfortran

Caffe documentation can be improved.

Later someone will come and say, you should post this in user groups...

StevenLOL avatar Apr 22 '15 12:04 StevenLOL

@jmozah yes OpenCV is installed. @StevenLOL I ran that command and the terminal says all are the newest versions and didn't install anything. Any other suggestions?

ankitdhall avatar Apr 22 '15 12:04 ankitdhall

Not sure about your problem, by the way, I build caffe by

cd caffe cp Makefile.config.example Makefile.config and change setting in Makefile.config mkdir build cd build cmake .. ./configure (??not sure??) make all

without using a build folder, for me there will be linking problem says libcaffe.o cant not find "xxx"

StevenLOL avatar Apr 22 '15 12:04 StevenLOL

i remember my system had some confusion on cv and cv2... forgot what that was,...

On Wed, Apr 22, 2015 at 5:57 PM, Steven [email protected] wrote:

Not sure, your problem, by the way, I build caffe by

cd caffe cp Makefile.config.example Makefile.config mkdir build cd build cmake .. ./configure (??not sure??) make all

without using a build folder, for me there will be linking problem says libcaffe.o cant not find "xxx"

— Reply to this email directly or view it on GitHub https://github.com/BVLC/caffe/issues/2348#issuecomment-95156848.

jmozah avatar Apr 22 '15 12:04 jmozah

@StevenLOL tried your way, not showing errors anymore :) . I'll try to run some sample code and hopefully it should work. Thanks!

ankitdhall avatar Apr 22 '15 16:04 ankitdhall

@ankitdhall I have the same problem, but it is solved after using cmake to configure your project.

zhangtemplar avatar Apr 28 '15 04:04 zhangtemplar

I meet the same problem and make a solution.
add "opencv_imgcodecs" in Makefile.(LIBRARIES += glog gflags protobuf leveldb snappy
lmdb boost_system hdf5_hl hdf5 m
opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs) If you input "make all",the problem is the same again.But if you delete all the file in build(rm -rf ./build/*) before "make all",you will success.I just success

hongzhenwang avatar Apr 28 '15 14:04 hongzhenwang

@hongzhenwang Many thanks! I just made it.

sinb avatar May 05 '15 13:05 sinb

Thanks Alot @StevenLOL it solved my problem and at last I'm done with caffe installation.

ghost avatar May 18 '15 08:05 ghost

@hongzhenwang even after adding those lines to make file it doesnt work. DOes the location in makefile also matter? And I am getting this error when I lay Anconda python paths instead of default python paths in caaffe makefile.

kalyanvasudev avatar Jun 12 '15 06:06 kalyanvasudev

thx @hongzhenwang, your solution works well.

zchengquan avatar Jun 25 '15 02:06 zchengquan

@hongzhenwang 's solution did it for me too.

patsimm avatar Jul 08 '15 21:07 patsimm

Problem with the makefile still missing the opencv_imgcodecs in the library list in the Makefile. This needs to be added to the project. Otherwise, all users who pull down the latest version will have to tread through the issues to find the solution listed here. @hongzhenwang is correct, though I would not follow his exact procedure, use make clean to zap the previous failed build. rm -rf is very dangerous, especially if your a newb and can potentially zap root and what not...

binary42 avatar Aug 28 '15 19:08 binary42

Thanks @hongzhenwang. That helped.

Added LIBRARIES += glog gflags protobuf leveldb snappy \ lmdb boost_system hdf5_hl hdf5 m \ opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs to Makefile.config

I used make clean instead of rm -rf ./build

Then did make all and everything worked fine.

aseempatni avatar Sep 07 '15 03:09 aseempatni

did you install opencv3 ??

zdx3578 avatar Dec 27 '15 07:12 zdx3578

I just installed and went through make all/tests/runtest successfully (only other hitch was a simple export error for the cuda libraries).

Makefile.config has this:

# Uncomment if you're using OpenCV 3
# OPENCV_VERSION := 3

It worked for me on Ubuntu 14.04/OpenCV 3.1/ Cuda 7.5/CuDNN v.3/980 Ti

james1i avatar Dec 31 '15 23:12 james1i

Using wang @hongzhenwang 's solution, I still can't solve this problem. Then I try to create soft links for opencv_imgcodecs using follow commands, it success!

$ sudo cp imgcodecs_c.h /usr/local/include $ sudo cp libopencv_imgcodecs.so /usr/local/lib $ sudo cp libopencv_imgcodecs.so.3.0 /usr/local/lib $ sudo cp libopencv_imgcodecs.so.3.0.0 /usr/local/lib $ sudo ln -sf /usr/local/lib/libopencv_imgcodecs.so.3.0.0 /usr/local/lib/libopencv_imgcodecs.so.3.0 $ sudo ln -sf /usr/local/lib/libopencv_imgcodecs.so.3.0 /usr/local/lib/libopencv_imgcodecs.so $ sudo ldconfig -v

VisionU avatar Feb 19 '16 02:02 VisionU

I got a similar error. Solved by using cmake.

jas0n1ee avatar Mar 21 '16 19:03 jas0n1ee

Thanks @hongzhenwang...It worked for me. However I'd like to point out that if you have openCV 3 installed and have enabled building with the same by using "OPENCV_VERSION := 3" in your makefile.config file, those extra dependencies are automatically added.

yashrahmed avatar Mar 24 '16 08:03 yashrahmed