caffe icon indicating copy to clipboard operation
caffe copied to clipboard

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

Open sakrig opened this issue 11 years ago • 23 comments

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<char, std::__1::char_traits, 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<char, std::__1::char_traits, std::__1::allocator > const&, int, int, bool) in io.o "cv::imencode(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, cv::InputArray const&, std::__1::vector<unsigned char, std::__1::allocator >&, std::__1::vector<int, std::__1::allocator > const&)", referenced from: caffe::ReadImageToDatum(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, int, int, int, bool, std::__1::basic_string<char, std::__1::char_traits, 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$

sakrig avatar Apr 09 '15 01:04 sakrig

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

tnarihi avatar Apr 09 '15 02:04 tnarihi

Please ask on the caffe-users group.

shelhamer avatar Apr 27 '15 08:04 shelhamer

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

zhangtemplar avatar Apr 28 '15 04:04 zhangtemplar

.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<unsigned char, std::allocator >&, std::vector<int, std::allocator > 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

northeastsquare avatar May 16 '15 11:05 northeastsquare

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 avatar May 16 '15 11:05 northeastsquare

@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 avatar Jun 09 '15 16:06 fabioperez

@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.

pranavmaneriker avatar Jul 05 '15 19:07 pranavmaneriker

Try to use Cmake build

bhack avatar Jul 05 '15 20:07 bhack

add opencv_imgcodecs to LIBRARIES in Makefile solved my problems too

wlike avatar Aug 01 '15 02:08 wlike

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

hi-one-gg avatar Aug 02 '15 10:08 hi-one-gg

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

abouzahir avatar Sep 13 '15 12:09 abouzahir

cmake solved it for me!!!

colek42 avatar Oct 22 '15 01:10 colek42

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.

hi-one-gg avatar Nov 05 '15 05:11 hi-one-gg

@bhack : how does one do it?!

Coderx7 avatar Feb 22 '16 16:02 Coderx7

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

mai00dou avatar May 23 '16 16:05 mai00dou

same here! Thanks for the help!

Elpidam avatar May 24 '16 09:05 Elpidam

@northeastsquare : thank you. It worked

aharishkumar avatar Aug 29 '16 12:08 aharishkumar

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::<caffestring*::)'GPUDevice<: 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: reference >::to TestBody(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 to boost::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 to boost::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 to boost::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 to boost::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 function caffe::LayerFactoryTest_TestCreateLayer_Test<caffe::CPUDevice >::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 to boost::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 to boost::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

aharishkumar avatar Aug 29 '16 12:08 aharishkumar

Please ask installation queries on caffe-users.

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

abhimanyudubey avatar Aug 29 '16 13:08 abhimanyudubey

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

aharishkumar avatar Aug 30 '16 04:08 aharishkumar