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

Created on 27 Mar 2017  ·  10Comments  ·  Source: BVLC/caffe

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 tocaffe::BlockingQueue >::push(boost::shared_ptr const&)'
.build_release/lib/libcaffe.so: undefined reference to caffe::BlockingQueue<caffe::Datum*>::push(caffe::Datum* const&)' .build_release/lib/libcaffe.so: undefined reference tocaffe::BlockingQueue::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 tocaffe::BlockingQueue::pop(std::__cxx11::basic_string, 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 tocaffe::BlockingQueue >::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.

Most helpful comment

Try adding
"
template class BlockingQueue;
template class BlockingQueue >;
"
to file src/caffe/util/blocking_queue.cpp
After
(line 89)"template class BlockingQueue*>;"

All 10 comments

Try adding
"
template class BlockingQueue;
template class BlockingQueue >;
"
to file src/caffe/util/blocking_queue.cpp
After
(line 89)"template class BlockingQueue*>;"

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 ; )

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

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

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 >;
^
src/caffe/util/blocking_queue.cpp:93:62: error: template argument 1 is invalid
template class BlockingQueue >;
^
src/caffe/util/blocking_queue.cpp:93:64: error: template argument 1 is invalid
template class BlockingQueue >;
^
make: * [.build_release/src/caffe/util/blocking_queue.o] Error 1_

@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 ; )

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.
https://github.com/djangogo/caffe_train/commit/0cba003cb8c912c36fbb6672c4355dc0ba867925

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

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 tocudnnCreateActivationDescriptor'
.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

Was this page helpful?
0 / 5 - 0 ratings