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

Error .build_release/lib/libcaffe.so: undefined reference to `caffe::BlockingQueue #5451

Closed
ShirleyGuo opened this issue Mar 27, 2017 · 10 comments

Comments

@ShirleyGuo
Copy link

hello, I want to run the fixed point caffe by JiannhuiWang on my desktop, and when compiling the /tools/ristretto.cpp, it has a problem as follows:
CXX/LD -o .build_release/tools/ristretto.bin
.build_release/lib/libcaffe.so: undefined reference to caffe::BlockingQueue<boost::shared_ptr<caffe::DataReader::QueuePair> >::size() const' .build_release/lib/libcaffe.so: undefined reference to caffe::BlockingQueue<boost::shared_ptrcaffe::DataReader::QueuePair >::push(boost::shared_ptrcaffe::DataReader::QueuePair const&)'
.build_release/lib/libcaffe.so: undefined reference to caffe::BlockingQueue<caffe::Datum*>::push(caffe::Datum* const&)' .build_release/lib/libcaffe.so: undefined reference to caffe::BlockingQueuecaffe::Datum*::BlockingQueue()'
.build_release/lib/libcaffe.so: undefined reference to caffe::BlockingQueue<boost::shared_ptr<caffe::DataReader::QueuePair> >::pop(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' .build_release/lib/libcaffe.so: undefined reference to caffe::BlockingQueuecaffe::Datum*::pop(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'
.build_release/lib/libcaffe.so: undefined reference to caffe::BlockingQueue<caffe::Datum*>::try_pop(caffe::Datum**)' .build_release/lib/libcaffe.so: undefined reference to caffe::BlockingQueue<boost::shared_ptrcaffe::DataReader::QueuePair >::BlockingQueue()'
collect2: error: ld returned 1 exit status
Makefile:625: recipe for target '.build_release/tools/ristretto.bin' failed
make: *** [.build_release/tools/ristretto.bin] Error 1
I have compiled all the other related files with no errors.

@Laser-Cat
Copy link

Try adding
"
template class BlockingQueue<Datum*>;
template class BlockingQueue<shared_ptrDataReader::QueuePair >;
"
to file src/caffe/util/blocking_queue.cpp
After
(line 89)"template class BlockingQueue<Batch*>;"

@Hanqing-Sun
Copy link

thanks, @Laser-Cat , almost solve my problem!
But could u please tell me why that works? I saw someone just refactor those lines in some recent commit. Thanks in advance.
@ShirleyGuo It's

template class BlockingQueue<Datum*>;
template class BlockingQueue<shared_ptr<DataReader::QueuePair> >;

to file src/caffe/util/blocking_queue.cpp
After
line 89: template class BlockingQueue<Batch...*>;
Laser-Cat just missed a '<>' in his code ; )

@Laser-Cat
Copy link

I guess you may hold caffe code from earlier version.

More details:

3ba2054
http://stackoverflow.com/questions/5888099/c-specifying-a-base-class-for-a-template-parameter

@Hanqing-Sun
Copy link

My bad. I've just messed up my local repo. Thanks for your reply.

@ouceduxzk
Copy link

What if I want to use the latest caffe and how to solve this problem? Any suggestions

@ghost
Copy link

ghost commented Jul 23, 2017

I meet a bug after the adding proposed by @Laser-Cat and @DefineFC .
‘DataReader’ was not declared ?

CXX src/caffe/util/blocking_queue.cpp
src/caffe/util/blocking_queue.cpp:93:41: error: ‘DataReader’ was not declared in this scope
template class BlockingQueue<shared_ptrDataReader::QueuePair >;
^
src/caffe/util/blocking_queue.cpp:93:62: error: template argument 1 is invalid
template class BlockingQueue<shared_ptrDataReader::QueuePair >;
^
src/caffe/util/blocking_queue.cpp:93:64: error: template argument 1 is invalid
template class BlockingQueue<shared_ptrDataReader::QueuePair >;
^
make: *** [.build_release/src/caffe/util/blocking_queue.o] Error 1

@Hanqing-Sun
Copy link

Hanqing-Sun commented Jul 23, 2017

@bzqsmmzh see my last post, will that help?

template class BlockingQueue<Datum*>;
template class BlockingQueue<shared_ptr<DataReader::QueuePair> >;

to file src/caffe/util/blocking_queue.cpp
After
line 89: template class BlockingQueue<Batch...*>;
Laser-Cat just missed a '<>' in his code ; )

@xizero00
Copy link

Hi @bzqsmmzh

First you have to add two header files to file src/caffe/util/blocking_queue.cpp

#include "caffe/data_reader.hpp"
#include "caffe/proto/caffe.pb.h"

and then you can add the following code

template class BlockingQueue<Datum*>;
template class BlockingQueue<shared_ptr<DataReader::QueuePair> >;

to file src/caffe/util/blocking_queue.cpp
After
line 89: template class BlockingQueue<Batch...*>;

The following commit will tell you what exactly you can do.
xizero00/caffe_train@0cba003

@ghost
Copy link

ghost commented Jul 27, 2017

@DefineFC @djangogo
Thank you for your answer and help. I missed the “include”.

@shilpi2015
Copy link

I am getting following error for ~/caffe$ sudo make all
...
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
CXX tools/finetune_net.cpp
CXX/LD -o .build_release/tools/finetune_net.bin
CXX tools/upgrade_net_proto_binary.cpp
CXX/LD -o .build_release/tools/upgrade_net_proto_binary.bin
.build_release/lib/libcaffe.so: undefined reference to cudnnSetActivationDescriptor' .build_release/lib/libcaffe.so: undefined reference to cudnnCreateActivationDescriptor'
.build_release/lib/libcaffe.so: undefined reference to `cudnnDestroyActivationDescriptor'
collect2: error: ld returned 1 exit status
make: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1

Anyone pl help how to resolve it

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

7 participants