Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find -lcaffe when run make_deep_image_analogy.sh #26

Open
taneta opened this issue Oct 27, 2017 · 7 comments
Open

cannot find -lcaffe when run make_deep_image_analogy.sh #26

taneta opened this issue Oct 27, 2017 · 7 comments

Comments

@taneta
Copy link

taneta commented Oct 27, 2017

I already have preinstalled caffe docker bvlc/caffe and trying to make the project, but get this error:

deep_image_analogy/source/lbfgs.cu:17:9: warning: #pragma once in main file
 #pragma once
         ^
/usr/bin/ld: cannot find -lcaffe
collect2: error: ld returned 1 exit status

How can I fix it? I have caffe path exported to LD.

@taneta
Copy link
Author

taneta commented Oct 27, 2017

When I change the line:
-lcaffe \
in make_deep_image_analogy.sh to:
-L/opt/caffe/python \
it returns:

/tmp/tmpxft_000005d7_00000000-29_Classifier.o: In function `Classifier::Classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
Classifier.cpp:(.text+0xa8): undefined reference to `caffe::Net<float>::Net(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, caffe::Phase, int, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const*, caffe::Net<float> const*)'
Classifier.cpp:(.text+0xe1): undefined reference to `caffe::Net<float>::CopyTrainedLayersFrom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/tmp/tmpxft_000005d7_00000000-29_Classifier.o: In function `Classifier::Predict(cv::Mat const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::vector<float*, std::allocator<float*> >&, std::vector<float*, std::allocator<float*> >&, std::vector<Dim, std::allocator<Dim> >&)':
Classifier.cpp:(.text+0x50d): undefined reference to `caffe::Blob<float>::Reshape(int, int, int, int)'
Classifier.cpp:(.text+0x51f): undefined reference to `caffe::Net<float>::Reshape()'
Classifier.cpp:(.text+0x575): undefined reference to `caffe::Net<float>::Forward(float*)'
Classifier.cpp:(.text+0x5d3): undefined reference to `caffe::Net<float>::blob_by_name(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
Classifier.cpp:(.text+0x6e1): undefined reference to `caffe::Blob<float>::gpu_data() const'
Classifier.cpp:(.text+0x741): undefined reference to `caffe::Blob<float>::mutable_gpu_data()'
/tmp/tmpxft_000005d7_00000000-29_Classifier.o: In function `Classifier::WrapInputLayer(std::vector<cv::Mat, std::allocator<cv::Mat> >*)':
Classifier.cpp:(.text+0x83f): undefined reference to `caffe::Blob<float>::mutable_cpu_data()'
/tmp/tmpxft_000005d7_00000000-29_Classifier.o: In function `Classifier::Preprocess(cv::Mat const&, std::vector<cv::Mat, std::allocator<cv::Mat> >*)':
Classifier.cpp:(.text+0xd2c): undefined reference to `caffe::Blob<float>::cpu_data() const'
/tmp/tmpxft_000005d7_00000000-29_Classifier.o: In function `caffe::Caffe::set_mode(caffe::Caffe::Brew)':
Classifier.cpp:(.text._ZN5caffe5Caffe8set_modeENS0_4BrewE[_ZN5caffe5Caffe8set_modeENS0_4BrewE]+0xc): undefined reference to `caffe::Caffe::Get()'
/tmp/tmpxft_000005d7_00000000-30_Deconv.o: In function `my_cost_function::f_gradf(float const*, float*, float*)':
Deconv.cpp:(.text+0x5c): undefined reference to `caffe::Net<float>::ForwardFromTo(int, int)'
Deconv.cpp:(.text+0x7e): undefined reference to `caffe::Net<float>::blob_by_name(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
Deconv.cpp:(.text+0x92): undefined reference to `caffe::Blob<float>::gpu_data() const'
Deconv.cpp:(.text+0xc4): undefined reference to `caffe::Net<float>::blob_by_name(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
Deconv.cpp:(.text+0xd8): undefined reference to `caffe::Blob<float>::mutable_gpu_diff()'
Deconv.cpp:(.text+0x106): undefined reference to `void caffe::caffe_gpu_sub<float>(int, float const*, float const*, float*)'
Deconv.cpp:(.text+0x140): undefined reference to `void caffe::caffe_gpu_mul<float>(int, float const*, float const*, float*)'
Deconv.cpp:(.text+0x159): undefined reference to `void caffe::caffe_gpu_asum<float>(int, float const*, float*)'
Deconv.cpp:(.text+0x17f): undefined reference to `caffe::Net<float>::BackwardFromTo(int, int)'
Deconv.cpp:(.text+0x1b2): undefined reference to `caffe::Net<float>::blob_by_name(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
Deconv.cpp:(.text+0x1c6): undefined reference to `caffe::Blob<float>::gpu_diff() const'
/tmp/tmpxft_000005d7_00000000-30_Deconv.o: In function `deconv(Classifier*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, float*, Dim, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, float*, Dim)':
Deconv.cpp:(.text+0x803): undefined reference to `caffe::Net<float>::ForwardFromTo(int, int)'
/tmp/tmpxft_000005d7_00000000-30_Deconv.o: In function `caffe::Caffe::cublas_handle()':
Deconv.cpp:(.text._ZN5caffe5Caffe13cublas_handleEv[_ZN5caffe5Caffe13cublas_handleEv]+0x5): undefined reference to `caffe::Caffe::Get()'
/tmp/tmpxft_000005d7_00000000-41_DeepAnalogy.o: In function `norm(float*&, float*, float*, Dim)':
tmpxft_000005d7_00000000-4_DeepAnalogy.cudafe1.cpp:(.text+0x93): undefined reference to `void caffe::caffe_gpu_mul<float>(int, float const*, float const*, float*)'
tmpxft_000005d7_00000000-4_DeepAnalogy.cudafe1.cpp:(.text+0xf8): undefined reference to `void caffe::caffe_gpu_set<float>(int, float, float*)'
tmpxft_000005d7_00000000-4_DeepAnalogy.cudafe1.cpp:(.text+0x139): undefined reference to `void caffe::caffe_gpu_gemv<float>(CBLAS_TRANSPOSE, int, int, float, float const*, float const*, float, float*)'
tmpxft_000005d7_00000000-4_DeepAnalogy.cudafe1.cpp:(.text+0x18e): undefined reference to `void caffe::caffe_gpu_powx<float>(int, float const*, float, float*)'
tmpxft_000005d7_00000000-4_DeepAnalogy.cudafe1.cpp:(.text+0x2ba): undefined reference to `void caffe::caffe_gpu_add_scalar<float>(int, float, float*)'
tmpxft_000005d7_00000000-4_DeepAnalogy.cudafe1.cpp:(.text+0x2f6): undefined reference to `void caffe::caffe_gpu_scal<float>(int, float, float*)'
tmpxft_000005d7_00000000-4_DeepAnalogy.cudafe1.cpp:(.text+0x343): undefined reference to `void caffe::caffe_gpu_gemm<float>(CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, float, float const*, float const*, float, float*)'
tmpxft_000005d7_00000000-4_DeepAnalogy.cudafe1.cpp:(.text+0x360): undefined reference to `void caffe::caffe_gpu_div<float>(int, float const*, float const*, float*)'
collect2: error: ld returned 1 exit status

@zhengziqiang
Copy link

ln -s /caffe/build/lib/libcaffe.so /usr/lib/libcaffe.so

It works for me

@tisawe
Copy link

tisawe commented Nov 11, 2017

@zhengziqiang
Linking the library failed to work for me. I no longer get the /usr/bin/ld: cannot find -lcaffe error message, but now this is returned:
/tmp/tmpxft_00001281_00000000-29_Classifier.o: In function `Classifier::Classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': Classifier.cpp:(.text+0xa8): undefined reference to `caffe::Net<float>::Net(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, caffe::Phase, int, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const*, caffe::Net<float> const*)' collect2: error: ld returned 1 exit status

I do not know how to comprehend that. What I can tell you is that I did not make Caffe from the build provided in this repository since its an older build without compatibility for CUDNN > v5.1, rather I compiled Caffe from BVLC's master repository. Also, I do have a previous build of Deep Image Analogy, which runs successfully on this same machine, but it is from otrimegistro's fork (https://github.com/otrimegistro/Deep-Image-Analogy#deep-image-analogy) for Linux support. I also built Caffe from that fork when I only had CUDNN v5.1 installed, which is supported in that build of Caffe.

Are there dependencies for this project included in this repository that is not included in BVLS's master repository of Caffe?

@tisawe
Copy link

tisawe commented Dec 3, 2017

I successfully made the project by installing the master branch of Caffe and copying the specific files for this project into my directory of Caffe's master branch. Added '~/caffe/build/lib' to my 'LD_LIBRARY_PATH' and edited the scripts documented in the readme to work with my environment. Then I ran 'config_deep_image_analogy.sh' and 'make_deep_image_analogy.sh', and a working executable was made.

@brainstormapps
Copy link

Hi I have the same issue
I downloaded and compiled caffe successfully
No when I try to compile the project I got the following error
/usr/bin/ld: cannot find -lcaffe
as you mentioned LD_LIBRARY_PATH
my source path is /root/deeplearnng/Deep-Image-Analogy-linux
and my caffe path is /root/deeplearning/caffe-rc5/.build_release/lib
how can I set LD_LIBRARY_PATH
thanks and regards

@yunyunhello
Copy link

@tisawe
I tried your copy methods and build deep-image-analogy in the master branch of Caffe. However, I still got the same error as before.

/tmp/tmpxft_00005a96_00000000-29_Classifier.o:In function ‘Classifier::Classifier(std::string const&, std::string const&)’:
Classifier.cpp:(.text+0xa2):undefined reference to ‘caffe::Net::Net(std::string const&, caffe::Phase, int, std::vector<std::string, std::allocatorstd::string > const*)’
Classifier.cpp:(.text+0xe1):undefined reference to ‘caffe::Net::CopyTrainedLayersFrom(std::string)’
/tmp/tmpxft_00005a96_00000000-29_Classifier.o:In function ‘Classifier::Predict(cv::Mat const&, std::vector<std::string, std::allocatorstd::string >&, std::vector<float*, std::allocator<float*> >&, std::vector<float*, std::allocator<float*> >&, std::vector<Dim, std::allocator >&)’:
Classifier.cpp:(.text+0x5b5):undefined reference to ‘caffe::Net::blob_by_name(std::string const&) const’
/tmp/tmpxft_00005a96_00000000-29_Classifier.o:In function ‘std::string* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)’:
Classifier.cpp:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x7b):undefined reference to ‘google::base::CheckOpMessageBuilder::NewString()’
/tmp/tmpxft_00005a96_00000000-30_Deconv.o:In function ‘my_cost_function::f_gradf(float const*, float*, float*)’:
Deconv.cpp:(.text+0x7e):undefined reference to ‘caffe::Net::blob_by_name(std::string const&) const’
Deconv.cpp:(.text+0xc4):undefined reference to ‘caffe::Net::blob_by_name(std::string const&) const’
Deconv.cpp:(.text+0x1b2):undefined reference to ‘caffe::Net::blob_by_name(std::string const&) const’

Could you give me more suggestions or details about how you solved this problem?
Thanks a lot!

@LemonMi
Copy link

LemonMi commented Apr 4, 2018

@taneta Have you solved your problems now?And how do you solve it?I meet the same problem with you.Could you help me?Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants