Caffe: Build errors, undefined cv::imread() cv::imencode() ...

Created on 9 Apr 2015  ·  23Comments  ·  Source: BVLC/caffe

Any ideas?

Scotts-iMac:caffe-master scottkrig$ make all
LD -o .build_release/lib/libcaffe.so
clang: warning: argument unused during compilation: '-pthread'
ld: warning: directory not found for option '-L/opt/local/lib'
Undefined symbols for architecture x86_64:
"cv::imread(std::__1::basic_string, std::__1::allocator > const&, int)", referenced from:
caffe::WindowDataLayer::InternalThreadEntry() in window_data_layer.o
caffe::WindowDataLayer::InternalThreadEntry() in window_data_layer.o
caffe::ReadImageToCVMat(std::__1::basic_string, std::__1::allocator > const&, int, int, bool) in io.o
"cv::imencode(std::__1::basic_string, std::__1::allocator > const&, cv::_InputArray const&, std::__1::vector >&, std::__1::vector > const&)", referenced from:
caffe::ReadImageToDatum(std::__1::basic_string, std::__1::allocator > const&, int, int, int, bool, std::__1::basic_string, std::__1::allocator > const&, caffe::Datum_) in io.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *_* [.build_release/lib/libcaffe.so] Error 1
Scotts-iMac:caffe-master scottkrig$ ls /opt/local/lib
ls: /opt/local/lib: No such file or directory
Scotts-iMac:caffe-master scottkrig$ ls /opt/local
ls: /opt/local: No such file or directory
Scotts-iMac:caffe-master scottkrig$

Most helpful comment

change Makefile:
LIBRARIES += glog gflags protobuf leveldb snappy \
lmdb boost_system hdf5_hl hdf5 m \
opencv_core opencv_highgui opencv_imgproc
add :opencv_imgcodecs solve my problem

All 23 comments

See my answer in #2286.
Seems like libc++ related problem.

Please ask on the caffe-users group.

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

.build_release/lib/libcaffe-nv.so: undefined reference to cv::imread(cv::String const&, int)' .build_release/lib/libcaffe-nv.so: undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector >&, std::vector > const&)'
.build_release/lib/libcaffe-nv.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
make: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1

change Makefile:
LIBRARIES += glog gflags protobuf leveldb snappy \
lmdb boost_system hdf5_hl hdf5 m \
opencv_core opencv_highgui opencv_imgproc
add :opencv_imgcodecs solve my problem

@northeastsquare I'm having the same issue. When I add opencv_imgcodec, I get the following error: /usr/bin/ld: warning: libopencv_core.so.3.0, needed by /opt/lib/libopencv_imgcodecs.so, may conflict with libopencv_core.so.2.4

@fabioperez
Had the same issue. For me, uninstalling opencv-3.0.0 (using a make uninstall) and installing opencv-2.4.11, followed by building caffe again worked.

It seems like sticking to opencv-<2.4.11 is a good option for now.

Try to use Cmake build

add opencv_imgcodecs to LIBRARIES in Makefile solved my problems too

@northeastsquare
oh! thank you !! it's work !

i solved this problem by adding -lopencv_imgcodecs to my makefile as follows
OPCV = -L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_features2d -lopencv_flann -lopencv_imgproc -lopencv_imgcodecs

and the $(OPCV) must be placed after the objects needing them

cmake solved it for me!!!

oh sorry.. i'm late

2015-10-22 10:22 GMT+09:00 colek42 [email protected]:

cmake solved it for me!!!


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

@bhack : how does one do it?!

@northeastsquare,Thanks to you,I have solved the problem used your method.

same here! Thanks for the help!

@northeastsquare : thank you. It worked

Hey _make all_ worked fine. But when I ran _make test_ it gave mountain of errors.

..build_release/src/caffe/test/test_image_data_layer.obuild_release/src/caffe/:test/test_layer_factory.o In: functionIn function caffe:caffe:MakeTempDir::(stdLayerFactoryTest_TestCreateLayer_Test:: double>test_image_data_layer.cpp >:(::.TestBodytext._ZN5caffe11MakeTempDirEPSs[()_ZN5caffe11MakeTempDirEPSs':]+
test_layer_factory.cpp0x49):(: .undefined text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIdEEE8TestBodyEvreference [to_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIdEEE8TestBodyEv] boost+0x7eb::):filesystem: undefined:detail reference:: totemp_directory_path(boost:boost::system:filesystem::::error_code_detail:)':temp_directory_path
test_image_data_layer.cpp(boost:(::.text._ZN5caffe11MakeTempDirEPSssystem:[_ZN5caffe11MakeTempDirEPSs:error_code]+_)0x5f)'
: test_layer_factory.cpp:undefined (reference.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIdEEE8TestBodyEv to[ _ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIdEEE8TestBodyEv]boost+0x809::):filesystem: undefined:path reference:: tooperator/=(boost:boost::filesystem:filesystem::::path:path :operatorconst&/=)'
(boosttest_image_data_layer.cpp:::(filesystem:.text._ZN5caffe11MakeTempDirEPSs:path[_ZN5caffe11MakeTempDirEPSs const]+&)0xe4)'
: test_layer_factory.cppundefined :(reference .to text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIdEEE8TestBodyEv[boost_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIdEEE8TestBodyEv::]+filesystem:0x8a7):detail: ::undefined unique_path(reference boost:to :filesystemboost::::path filesystem:const&:detail, ::boost:unique_path(:systemboost::::filesystemerror_code_::)'path
test_image_data_layer.cppconst&:(, .boost:text._ZN5caffe11MakeTempDirEPSs[:system_ZN5caffe11MakeTempDirEPSs]::+0x112error_code_):)' undefined
test_layer_factory.cpp reference:( to. text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIdEEE8TestBodyEvboost:[:_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIdEEE8TestBodyEv]filesystem:+0x8d1:detail)::: undefinedcreate_directory( referenceboost: to:filesystem::boost:path :filesystemconst&::, boostdetail::::create_directorysystem:(boost:error_code::_)filesystem:'
:path.build_release const/src&,/caffe boost/test::/test_image_data_layer.osystem:: :error_codeIn )function '
caffe.build_release::/srcMakeTempFilename(/caffestd:/test:string/test_layer_factory.o_): ':In test_image_data_layer.cppfunction :(caffe.text._ZN5caffe16MakeTempFilenameEPSs::[_ZN5caffe16MakeTempFilenameEPSsLayerFactoryTest_TestCreateLayer_Test<]+caffe:0x87):GPUDevice: boost)'::: test_layer_factory.cppfilesystem::(:path.::text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIfEEE8TestBodyEvcodecvt([)_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIfEEE8TestBodyEv]' +0x7ebtest_image_data_layer.cpp:):(. undefinedtext._ZN5caffe16MakeTempFilenameEPSs[ reference_ZN5caffe16MakeTempFilenameEPSs to]+0x334)boost:: :filesystemundefined ::reference detail:to :temp_directory_pathboost(boost::::filesystem:system::path:error_code::_)operator/' =(test_layer_factory.cppboost::(:filesystem.::text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIfEEE8TestBodyEv[path _ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIfEEE8TestBodyEvconst&]+)'0x809) : undefined reference toboost::filesystem::path::operator/=(boost::filesystem::path const&)'
test_layer_factory.cpp:(.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIfEEE8TestBodyEv[_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIfEEE8TestBodyEv]+0x8a7): undefined reference toboost::filesystem::detail::unique_path(boost::filesystem::path const&, boost::system::error_code_)' test_layer_factory.cpp:(.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIfEEE8TestBodyEv[_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9GPUDeviceIfEEE8TestBodyEv]+0x8d1): undefined reference toboost::filesystem::detail::create_directory(boost::filesystem::path const&, boost::system::error_code
)'
.build_release/src/caffe/test/test_layer_factory.o: In functioncaffe::LayerFactoryTest_TestCreateLayer_Testcaffe::CPUDevice<double >::TestBody()': test_layer_factory.cpp:(.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIdEEE8TestBodyEv[_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIdEEE8TestBodyEv]+0x7eb): undefined reference toboost::filesystem::detail::temp_directory_path(boost::system::error_code)'
test_layer_factory.cpp:(.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIdEEE8TestBodyEv[_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIdEEE8TestBodyEv]+0x809): undefined reference toboost::filesystem::path::operator/=(boost::filesystem::path const&)' test_layer_factory.cpp:(.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIdEEE8TestBodyEv[_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIdEEE8TestBodyEv]+0x8a7): undefined reference toboost::filesystem::detail::unique_path(boost::filesystem::path const&, boost::system::error_code
)'
test_layer_factory.cpp:(.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIdEEE8TestBodyEv[_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIdEEE8TestBodyEv]+0x8d1): undefined reference toboost::filesystem::detail::create_directory(boost::filesystem::path const&, boost::system::error_code_)' .build_release/src/caffe/test/test_layer_factory.o: In functioncaffe::LayerFactoryTest_TestCreateLayer_Test >::TestBody()':
test_layer_factory.cpp:(.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIfEEE8TestBodyEv[_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIfEEE8TestBodyEv]+0x7eb): undefined reference toboost::filesystem::detail::temp_directory_path(boost::system::error_code_)' test_layer_factory.cpp:(.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIfEEE8TestBodyEv[_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIfEEE8TestBodyEv]+0x809): undefined reference toboost::filesystem::path::operator/=(boost::filesystem::path const&)'
test_layer_factory.cpp:(.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIfEEE8TestBodyEv[_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIfEEE8TestBodyEv]+0x8a7): undefined reference toboost::filesystem::detail::unique_path(boost::filesystem::path const&, boost::system::error_code_)' test_layer_factory.cpp:(.text._ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIfEEE8TestBodyEv[_ZN5caffe37LayerFactoryTest_TestCreateLayer_TestINS_9CPUDeviceIfEEE8TestBodyEv]+0x8d1): undefined reference toboost::filesystem::detail::create_directory(boost::filesystem::path const&, boost::system::error_code_)'
collect2: error: ld returned 1 exit status
LD .build_release/src/caffe/test/test_protobuf.o
LD .build_release/src/caffe/test/test_random_number_generator.o
collect2: error: ld returned 1 exit status
LD .build_release/src/caffe/test/test_pooling_layer.o
LD .build_release/src/caffe/test/test_threshold_layer.o
make: ** [.build_release/test/test_image_data_layer.testbin] Error 1
make: *
* Waiting for unfinished jobs....
make: *** [.build_release/test/test_layer_factory.testbin] Error 1

Please ask installation queries on caffe-users.

It looks like you don't have boost linked. Try reinstalling boost and linking it again.

I had to link boost_filesystem in the libraries in make file. Now its working.
Thank you

Good nice work = )

2016-08-30 13:47 GMT+09:00 Harish Kumar [email protected]:

I had to link boost_filesystem in the libraries in make file. Now its
working.
Thank you


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/BVLC/caffe/issues/2288#issuecomment-243331904, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AM54JsLHT8JLgxO3B35z65TPwkwIdIYgks5qk7XdgaJpZM4D86JJ
.

By setting OPENCV_VERSION := 3 can also solve this problem.

Hey @Greencurity, where should i write this? Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

malreddysid picture malreddysid  ·  3Comments

OpenHero picture OpenHero  ·  3Comments

shiorioxy picture shiorioxy  ·  3Comments

vladislavdonchev picture vladislavdonchev  ·  3Comments

inferrna picture inferrna  ·  3Comments