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

Undefined reference to google protobuf #3046

Closed
snavavf opened this issue Sep 9, 2015 · 64 comments
Closed

Undefined reference to google protobuf #3046

snavavf opened this issue Sep 9, 2015 · 64 comments

Comments

@snavavf
Copy link

snavavf commented Sep 9, 2015

I got these errors saying there are undefined reference to google protobuf when make all in caffe dir.
I wonder which file (like the Makefile?) I should modify, or where I should set up in my system.

I've already installed protobuf as the command provided in the link, and installed libprotobuf-dev and protobuf-compiler on my Ubuntu 14.04.

CXX/LD -o .build_release/tools/convert_imageset.bin
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteVarint64ToArray(unsigned long long, unsigned char*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteInt64(int, long long, google::protobuf::io::CodedOutputStream*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::UnknownFieldSet::AddVarint(int, unsigned long long)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::VarintSize64(unsigned long long)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteVarint64(unsigned long long)'
collect2: error: ld returned 1 exit status
make: *** [.build_release/tools/convert_imageset.bin] Error 1
@shibuyanorailgun
Copy link

If you are using Ubuntu, maybe this will help:

sudo apt-get install libprotobuf-dev protobuf-compiler

@snavavf
Copy link
Author

snavavf commented Sep 9, 2015

I have already installed libprotobuf-dev and protobuf-compiler on my Ubuntu 14.04 yet still get those error messages.

@shibuyanorailgun
Copy link

Perhaps add -pthread -lprotobuf -lpthread will do.

nr@linux ~ % pkg-config --libs protobuf
-pthread -lprotobuf -lpthread

@snavavf
Copy link
Author

snavavf commented Sep 10, 2015

@shibuyanorailgun I don't quite understand...
I think -lprotobuf is already handled at line 172 and line 364 at Makefile,

LIBRARIES += glog gflags protobuf leveldb snappy \
    lmdb boost_system hdf5_hl hdf5 m \
    opencv_core opencv_highgui opencv_imgproc
LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_CONFIG) \
        $(foreach library,$(LIBRARIES),-l$(library))

and -pthread is handled at line 352.

CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)

I tried to edit line 172 to

LIBRARIES += glog gflags protobuf leveldb snappy \
    lmdb boost_system hdf5_hl hdf5 m \
    opencv_core opencv_highgui opencv_imgproc pthread

but that doesn't help.

I don't know much about Makefile, so maybe I misunderstood. Could you explain more about how to compile it right?

@shibuyanorailgun
Copy link

= =, I'm sorry I can't figure out what happend.

@cwlseu
Copy link

cwlseu commented Sep 22, 2015

I encountered trouble alike
I encountered trouble alike, see buildlog as follow:
PROTOC src/caffe/proto/caffe.proto
make: protoc: Command not found
make: *** [.build_release/src/caffe/proto/caffe.pb.h] Error 127

thanks for your answer @shibuyanorailgun

@antran89
Copy link
Contributor

antran89 commented Oct 5, 2015

Hi @snavavf, @cwlseu,
[UPDATED, DO NOT TRY THIS]Please try to remove the os versions of protobuf in /usr/lib/x86_64-linux-gnu. (Something like libprotobuf.*, libprotobuf-lite.*, libprotoc.*). There are two versions of protobuf will cause conflicts when compiling.
Then try to install newest version of protobuf.

Better versions: [UPDATED, TRY THIS] Instead of my bad advice on deleting with system files, we can remove development files of libprotobuf but still keep library files in /usr/lib/x86_64-linux-gnu by this command

apt-get remove libprotobuf-dev

Then try to install newest version of protobuf.

@snavavf
Copy link
Author

snavavf commented Oct 8, 2015

Thanks @howtobeahacker !
That works.

@snavavf snavavf closed this as completed Oct 8, 2015
@afarbos
Copy link

afarbos commented Oct 14, 2015

Can you explain me the solution? I am not sure to understand and I have a similar problem.

@tinoue
Copy link

tinoue commented Nov 25, 2015

FYI: This seems to be a perfect solution for me.
http://stackoverflow.com/questions/10404027/cant-compile-example-from-google-protocol-buffers

@ferrouswheel
Copy link

Advising people to delete system libraries isn't an ideal solution.

I tried to remove protobuf-lite in ubuntu 15.10 with sudo apt-get remove libprotobuf-lite9v5 (because I don't want to break my system) but it tries to remove 205 other packages (including my desktop).

Googling about this reminded me that I had previously tryed to make CUDA work by changing to gcc 4.9. Unfortunately the c++ ABI changed so compiling stuff with 4.9 and trying to link to system libraries built with gcc 5 won't work.

On the mailing list people are suggesting to remove the gcc 5 error from the CUDA header /usr/local/cuda/include/host_config.h.

@wadefelix
Copy link

remove the gcc 5 error from the CUDA header host_config.h
it works!

@jay-to-the-dee
Copy link

This appears to be a prevalent issue ob Ubuntu 15.10! Caffe used to work fine on 15.04! Also I'm using CUDA 7.5 so in theory I should be fine for the GCC version issue!

@netom
Copy link

netom commented Mar 8, 2016

Hi, Ubuntu 15.10 user here. Had the same issue, solved by patching CUDA (/usr/local/cuda/include/host_config.h).

Diff:

< #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9)
---
> //#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9)
115c115
< #error -- unsupported GNU version! gcc versions later than 4.9 are not supported!
---
> //#error -- unsupported GNU version! gcc versions later than 4.9 are not supported!
117c117
< #endif /* __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9) */
---
> //#endif /* __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9) */

@michaeljs1990
Copy link

apparently someone called hottobeahacker solved this but i don't see that user or comment anymore. Could anyone enlighten me?

@antran89
Copy link
Contributor

antran89 commented May 3, 2016

@michaeljs1990 It's me, I just changed my name. See my first comment in the thread, it might help you avoid the problem.

@michaeljs1990
Copy link

@antran89 thanks for the response. Unfortunately I have to use protoc 2.5 with my project so that is a no go for me. It seems that this library no longer works with the stock ubuntu 14.04 packages and the website contains incorrect information for building this package as well.

@muzhi93
Copy link

muzhi93 commented May 10, 2016

@antran89 Hi,following your guidance,I've successfully compiled Caffe,but there is another problem arising:when I reboot my machine,the leftside toolbar of my ubuntu 14.04 desktop is gone,then I typed ccsm in the command window,which reported an error,ImportError: libprotobuf.so.8: cannot open shared object file: No such file or directory.I wonder whether it is because I deleted the OS's protobuf file that lead to the breakdown of my desktop?

@Holdlen2DH
Copy link

I encounter this problem too, but don't how to fix it

@wenwei202
Copy link

This one works for me, in Ubuntu 16.04:

  1. Configure /usr/local/cuda/include/host_config.h as suggested.
  2. sudo apt-get autoremove libprotobuf-dev protobuf-compiler
  3. then compile the protobuf-2.5.0 from src and install
    Please config the gcc when you compile protobuf
    ./configure --prefix=/usr/local/ CC=/usr/bin/gcc

@admercs
Copy link

admercs commented Jul 29, 2016

This still fails to link to protobuf on the latest Ubuntu 16.04 LTS with gcc-4.9 (apt-get install gcc-4.9 g++-4.9) and many versions of protobuf tried.

@groakat
Copy link

groakat commented Aug 19, 2016

for me this problem was caused because I had protobuf installed in anaconda. If you have protobuf installed in your anaconda environment, you have to remove all files by hand, as conda uninstall protobuf does not remove all the library files.

@hjc1028
Copy link

hjc1028 commented Sep 24, 2016

@antran89 删了libprotobuf-lite.so 之后进不了桌面,这个问题弄了三天

@hjc1028
Copy link

hjc1028 commented Sep 24, 2016

@wenwei202 It works

@bragilee
Copy link

bragilee commented Oct 14, 2016

@antran89 Hi, I recently moved on the caffe. I encountered this problem on the ArchLinux. I am not quite familiar with caffe and protobuf so I do not quite understand how this problem happens. Could you help me? Thank you so much.

@antran89
Copy link
Contributor

@bragilee Sorry, I do not know how to fix safely. Some distributions of Linux have two version of Protobuf. You should figure out how to make Caffe only recognize one version of Protobuf. Sorry, my recommendations are not good. Please try out the methods of other people. Now it works fine for me all the time. I also do not know why they have this problem.

@bragilee
Copy link

@antran89 Thank you so much for your help. I will seek other methods. :)

@Anymake
Copy link

Anymake commented Dec 20, 2017

@samuelcesc thank you , “conda remove libprotobuf” is the right solution!

@huzqujm
Copy link

huzqujm commented Dec 29, 2017

To me, install protobuf from source and copy its library to anaconda can solver this problem. [Notice: keep two protobuf version the same]
I install protobuf from source and keep its version the same as anaconda's protobuf. But I still get thiss error message. If I remove ptotobuf which installed by me and It still return this message. I cannot remove anaconda's protobuf. So I copy system's protobuf(compiled and installed from source) to anaconda's lib and it works...

I fell confused. Anaconda's protobuf is not a complete version of protobuf? I forgot to compare two protobuf versions' file size...

update:

huzhan@huzhan  ~/package  ll /usr/local/lib | grep protobuf
-rw-r--r-- 1 root root 72664964 Dec 29 19:19 libprotobuf.a
-rwxr-xr-x 1 root root 971 Dec 29 19:19 libprotobuf.la*
-rw-r--r-- 1 root root 8276882 Dec 29 19:19 libprotobuf-lite.a
-rwxr-xr-x 1 root root 1006 Dec 29 19:19 libprotobuf-lite.la*
lrwxrwxrwx 1 root root 26 Dec 29 19:19 libprotobuf-lite.so -> libprotobuf-lite.so.14.0.0*
lrwxrwxrwx 1 root root 26 Dec 29 19:19 libprotobuf-lite.so.14 -> libprotobuf-lite.so.14.0.0*
-rwxr-xr-x 1 root root 3382056 Dec 29 19:19 libprotobuf-lite.so.14.0.0*
lrwxrwxrwx 1 root root 21 Dec 29 19:19 libprotobuf.so -> libprotobuf.so.14.0.0*
lrwxrwxrwx 1 root root 21 Dec 29 19:19 libprotobuf.so.14 -> libprotobuf.so.14.0.0*
-rwxr-xr-x 1 root root 27738776 Dec 29 19:19 libprotobuf.so.14.0.0*
huzhan@huzhan  ~/package  ll ~/anaconda2/lib | grep protobuf
-rw-rw-r-- 2 huzhan huzhan 5478328 Nov 16 05:44 libprotobuf.a
-rwxrwxr-x 1 huzhan huzhan 1012 Dec 30 01:02 libprotobuf.la*
-rw-rw-r-- 2 huzhan huzhan 689960 Nov 16 05:44 libprotobuf-lite.a
-rwxrwxr-x 1 huzhan huzhan 1047 Dec 30 01:02 libprotobuf-lite.la*
lrwxrwxrwx 1 huzhan huzhan 26 Dec 30 01:02 libprotobuf-lite.so -> libprotobuf-lite.so.14.0.0*
lrwxrwxrwx 1 huzhan huzhan 26 Dec 30 01:02 libprotobuf-lite.so.14 -> libprotobuf-lite.so.14.0.0*
-rwxrwxr-x 2 huzhan huzhan 422392 Nov 16 05:44 libprotobuf-lite.so.14.0.0*
lrwxrwxrwx 1 huzhan huzhan 21 Dec 30 01:02 libprotobuf.so -> libprotobuf.so.14.0.0*
lrwxrwxrwx 1 huzhan huzhan 21 Dec 30 01:02 libprotobuf.so.14 -> libprotobuf.so.14.0.0*
-rwxrwxr-x 2 huzhan huzhan 3126080 Nov 16 05:44 libprotobuf.so.14.0.0*

These two libs are not the same one even if they are the same version..
anaconda's protobuf will not work after copy system's lib to anaconda

@YerongLi
Copy link

YerongLi commented Jan 8, 2018

Actually I think all the undefined error has something to do with the gcc/g++ version on ubuntu side, simple test can be done on the protobuf(https://github.com/google/protobuf/tree/master/src)
If we build protobuf with g++4.7 then caffe with g++5.4, and then caffe cannot find protobuf as a result.
And building protobuf with g++4.7 then caffe with g++4.7, and then caffe can at leat find protobuf...

I am not sure whether downgrading gcc/g++4.7 beforehand is a good option for build caffe.

@yinyanting
Copy link

@zchrissirhcz
I change gcc from 4.9 to 5, and I can build caffe successfully. I have same ubuntu,gcc,and cuda

@ZubairKhan001
Copy link

ZubairKhan001 commented Feb 9, 2018

i have compiled caffe on Ubuntu 16.04 LTS both with python 2 and python, it is really a hectic process for beginners, for caffe with python 2.7 make sure that your /.local/lib/python2.7/site-packages only contains a version same as you protoc version. protoc version can be checked by entering
protoc --version
for me i got problems with python 2.7 because by mistake i installed protbuf 3.0 alpha in python 2.7 site packages, so there was a protobuf error after removing it from python 2.7 site packages everything worked fine
also install python-dev version
apt-get install the python3.x-dev
and for python 3.5 make sure you have python 3.0 alpha, if you have both python 2.7 and python 3.x in the system use pip3 otherwise use pip

pip3 install protobuf==3.0.0-alpha-3

or another protobuf such as 3.5 version of protobuf.
also do this
pip3 install python-dateutil --upgrade
after that do
make clean
make all
make runtest
make pycaffe
after performing make all make runtest steps don't forget to do that
sudo ldconfig

hope everything works OK for you.

1 similar comment
@ZubairKhan001
Copy link

ZubairKhan001 commented Feb 9, 2018

i have compiled caffe on Ubuntu 16.04 LTS both with python 2 and python, it is really a hectic process for beginners, for caffe with python 2.7 make sure that your /.local/lib/python2.7/site-packages only contains a version same as you protoc version. protoc version can be checked by entering
protoc --version
for me i got problems with python 2.7 because by mistake i installed protbuf 3.0 alpha in python 2.7 site packages, so there was a protobuf error after removing it from python 2.7 site packages everything worked fine
also install python-dev version
apt-get install the python3.x-dev
and for python 3.5 make sure you have python 3.0 alpha, if you have both python 2.7 and python 3.x in the system use pip3 otherwise use pip

pip3 install protobuf==3.0.0-alpha-3

or another protobuf such as 3.5 version of protobuf.
also do this
pip3 install python-dateutil --upgrade
after that do
make clean
make all
make runtest
make pycaffe
after performing make all make runtest steps don't forget to do that
sudo ldconfig

hope everything works OK for you.

@AustinVan
Copy link

My solution is to change the INCLUDE_DIRS and LIBRARY_DIRS in Makefile.config.
Note that the detailed protoc path is necessary.

In my case,
protoc lib path is : /home/tools/protobuf.3.4/lib (change according to your location)
protoc include path is : /home/tools/protobuf.3.4/include (change according to your location)

After my modification, my makefile is:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /home/tools/protobuf.3.4/include /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /home/tools/protobuf.3.4/lib /usr/local/lib /usr/lib

Note that the protoc need to be in front of the default paths

@hana9090
Copy link

hana9090 commented Apr 10, 2018

For UBUNTU 17.10, CUDA 8 and cUDNN 5 what is the best solution for the same error :(
protoc --version : libprotoc 3.5.1
Which one should I follow?

@cuixiaodao
Copy link

ubuntu 16.04, problem solved by compiling protobuf 2.5.0 using gcc-4.8.

@amitfishy
Copy link

I was able to install and run on Cuda 9.0 with protobuf 3.5.1.
The following worked for me:
Installed protobuf following this
This stored my proto.so files in /usr/local/lib
I followed the instructions here after that for using it on python

I still got the undefined reference error. On looking further there were some old proto.so files in /usr/lib/x86_64-linux-gnu which were present there from before using the deb installation. The problem was that it was picking up these files during the caffe build as opposed to the .so files that I had installed from source.
Do not delete the older .so files (my PC wouldn't reboot when I did so), instead in the makefile.config, put the directory which contains your source based .so files (/usr/local/lib in my case - default for source installation) in the beginning so it will take that and build with that instead of your older proto file location (/usr/lib/x86_64-linux-gnu - which I put in $PYTHON_LIB).

LIBRARY_DIRS := /usr/local/lib $(PYTHON_LIB) /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial

Doing so removed the undefined reference error for me. It is mot likely due to conflict in existing version of protobuf that you have in your system.
One of the other major issues I encountered while trying protobuf v3.5.1 was related to c++11, which I was able to fix following this.

@g10guang
Copy link

gcc `pkg-config --libs --clfags protobuf` you command

@kongcong
Copy link

If you are using Ubuntu, maybe this will help:

sudo apt-get install libprotobuf-dev protobuf-compiler

it can't help

@stonyhu
Copy link

stonyhu commented Nov 27, 2018

@groakat Exactly! It works! This error is indeed caused by the conflict of anaconda installed libprotobuf and apt installed libprotobuf. So the final solution is that you need to uninstall all libprotobuf of anaconda, and then installed libprotobuf-dev and protobuf-compiler by apt!

@tulha
Copy link

tulha commented Nov 30, 2018

I encounter same problem.

System: ubuntu16.04
cuda: 8.0.44
gcc: 4.9

I have installed matlab2016b, which contains a libprotobuf.so.8, while I use apt-get install libprotobuf-dev gives libprotobuf.so.9, maybe this is the source of conflict. However, when I remove all the libprotobuf.so files under MATLAB installation folder, I do make clean; make -j8 still gives same problem.

Finally, I change gcc from 4.9 to 5, and this time I can build caffe successfully. Just don't sure if I dont't remove Matlab folders' libprotobu.so files can Caffe be build successuflly.

I have MATLAB installed as well and the libprotobuf.so.9 files are present in the MATLAB folder for me too. However, I can confirm that the source of conflict is not this. Changing the gcc version from 4.9 to 5 solved the problem for me! (Y)

@northeastsquare
Copy link

northeastsquare commented Mar 19, 2019

in caffe makefile line 262:
ifeq ($(LINUX), 1)
CXX ?= /usr/bin/g++
GCCVERSION := $(shell $(CXX) -dumpversion | cut -f1,2 -d.)
# older versions of gcc are too dumb to build boost with -Wuninitalized
ifeq ($(shell echo | awk '{exit $(GCCVERSION) < 4.6;}'), 1)
WARNINGS += -Wno-uninitialized
endif
# boost::thread is reasonably called boost_thread (compare OS X)
# We will also explicitly add stdc++ to the link target.
LIBRARIES += boost_thread stdc++
VERSIONFLAGS += -Wl,-soname,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../lib
endif

but I compile protobuf with /usr/local/bin/g++
Also, recompile gflags, glog

@sunshuhuai
Copy link

libprotobuf.so

I encounter same problem.

System: ubuntu16.04
cuda: 8.0.44
gcc: 4.9

I have installed matlab2016b, which contains a libprotobuf.so.8, while I use apt-get install libprotobuf-dev gives libprotobuf.so.9, maybe this is the source of conflict. However, when I remove all the libprotobuf.so files under MATLAB installation folder, I do make clean; make -j8 still gives same problem.

Finally, I change gcc from 4.9 to 5, and this time I can build caffe successfully. Just don't sure if I dont't remove Matlab folders' libprotobu.so files can Caffe be build successuflly.

I have the same situation as you.I tried a lot of methods, and finally I uninstalled gcc directly and then reinstalled it.

sudo apt-get build-dep gcc
sudo apt-get remove gcc

@charles-loomai
Copy link

charles-loomai commented May 7, 2019

Tried almost all the answers above.
The best is @zchrissirhcz, very convenient, wont remove anything, wont break anything, only need to install gcc-5 via apt install gcc-5 g++-5

  1. switching to gcc-5 via ln -sf /usr/bin/gcc-5 /usr/bin/gcc and ln -sf /usr/bin/g++-5 /usr/bin/g++,
  2. then run make clean, make -j10.
  3. [optional] switching back to your previous gcc

my OS is ubuntu 18.04(Linux Mint19.1), cuda9.0, cudnn7.0, RTX2080 Ti
cheers

@amolkumarpatil
Copy link

Tried almost all the answers above.
The best is @zchrissirhcz, very convenient, wont remove anything, wont break anything, only need to install gcc-5 via apt install gcc-5 g++-5

  1. switching to gcc-5 via ln -sf /usr/bin/gcc-5 /usr/bin/gcc and ln -sf /usr/bin/g++-5 /usr/bin/g++,
  2. then run make clean, make -j10.
  3. [optional] switching back to your previous gcc

my OS is ubuntu 18.04(Linux Mint19.1), cuda9.0, cudnn7.0, RTX2080 Ti
cheers

Works for ubuntu 18.04 [confirmed]

@gongshichina
Copy link

A small tip may help you :)
Confirm that your lib and include file for protobuf correspond, in Makefile.config
INCLUDE_DIRS := $(PYTHON_INCLUDE) $HOME/anaconda3/include /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) $HOME/anaconda3/lib /usr/local/lib /usr/lib

That is to say, if your google/protobuf/include comes from $HOME/anaconda3/include, then .so/.a files must comes from $HOME/anaconda3/lib , keeping both version correspond.

@cannguyen275
Copy link

Tried almost all the answers above.
The best is @zchrissirhcz, very convenient, wont remove anything, wont break anything, only need to install gcc-5 via apt install gcc-5 g++-5

  1. switching to gcc-5 via ln -sf /usr/bin/gcc-5 /usr/bin/gcc and ln -sf /usr/bin/g++-5 /usr/bin/g++,
  2. then run make clean, make -j10.
  3. [optional] switching back to your previous gcc

my OS is ubuntu 18.04(Linux Mint19.1), cuda9.0, cudnn7.0, RTX2080 Ti
cheers

Ubuntu 18.04, too. But this solution doesn't work.
I'm using gcc/g++ 7.4.0, anaconda3 environment. This gcc version seems to bring me further than gcc 5, gcc5 end up with error in the very first of the installation process.
Here is the error with gcc/g++ 7.4.0:

[ 65%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/hdf5.cpp.o
[ 65%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/im2col.cpp.o
[ 67%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/im_transforms.cpp.o
[ 67%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/insert_splits.cpp.o
[ 68%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/io.cpp.o
[ 68%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/math_functions.cpp.o
[ 70%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/sampler.cpp.o
[ 70%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/signal_handler.cpp.o
[ 70%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/upgrade_proto.cpp.o
[ 71%] Linking CXX shared library ../../lib/libcaffe.so
[ 71%] Built target caffe
Scanning dependencies of target convert_imageset
[ 71%] Building CXX object tools/CMakeFiles/convert_imageset.dir/convert_imageset.cpp.o
[ 73%] Linking CXX executable convert_imageset
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `google::protobuf::RepeatedField<float>::Add(float const&)'
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)'
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `google::protobuf::RepeatedField<unsigned int>::~RepeatedField()'
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `google::protobuf::internal::WireFormatLite::UInt32Size(google::protobuf::RepeatedField<unsigned int> const&)'
....I remove because it's too long :))
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::~RepeatedPtrField()'
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)'
collect2: error: ld returned 1 exit status
tools/CMakeFiles/convert_imageset.dir/build.make:135: recipe for target 'tools/convert_imageset' failed
make[2]: *** [tools/convert_imageset] Error 1
CMakeFiles/Makefile2:441: recipe for target 'tools/CMakeFiles/convert_imageset.dir/all' failed
make[1]: *** [tools/CMakeFiles/convert_imageset.dir/all] Error 2
Makefile:129: recipe for target 'all' failed

@anushreehede
Copy link

I am struggling with similar errors as @cannguyen275 . Could someone please help out with this issue? I need it to work a bit urgently. I'm working with Debian 9. Would really appreciate the help!

@leondgarse
Copy link

I solved my problem by compiling and installing the corresponding protobuf version with anaconda one from protobuf releases.

$ locate libprotobuf  # List only those matters
# /opt/anaconda3/pkgs/libprotobuf-3.11.4-hd408876_0/lib/libprotobuf.so
# /opt/anaconda3/lib/libprotobuf.so.22
# /usr/local/lib/libprotobuf.so
# /usr/local/lib/libprotobuf.so.22

$ ls /usr/local/lib/libprotobuf.so -l
# /usr/local/lib/libprotobuf.so -> libprotobuf.so.22.0.4
  • When set using anaconda in Makefile.config, libprotobuf version in system should match with anaconda one.
  • Download the matched protobuf release protobuf-cpp-xxx.tar.gz / protobuf-cpp-xxx.zip from protobuf releases.
  • Extract and compile.
cd protobuf-3.11.4
./autogen.sh
./configure
make
make check
sudo make install
sudo ldconfig
pkg-config --cflags --libs protobuf

I have my own compiling caffe on Ubuntu 20.04, python3.8 issues summary here.

@aabolfazl
Copy link

Cmake link command

target_link_libraries(protoTest LINK_PUBLIC -pthread -lprotobuf -lpthread)

@enternityFan
Copy link

apt-get remove libprotobuf-dev

thank u very much!!!!!!!!!!it 's very very helpful for me!

1 similar comment
@enternityFan
Copy link

apt-get remove libprotobuf-dev

thank u very much!!!!!!!!!!it 's very very helpful for me!

@dragonQian
Copy link

dragonQian commented Apr 10, 2023 via email

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