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 · 55 comments

Comments

@snavavf
Copy link

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

This comment has been minimized.

Copy link

commented Sep 9, 2015

If you are using Ubuntu, maybe this will help:

sudo apt-get install libprotobuf-dev protobuf-compiler
@snavavf

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

commented Sep 9, 2015

Perhaps add -pthread -lprotobuf -lpthread will do.

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

commented Sep 10, 2015

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

@cwlseu

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Author

commented Oct 8, 2015

Thanks @howtobeahacker !
That works.

@snavavf snavavf closed this Oct 8, 2015

@hevy-CC4477

This comment has been minimized.

Copy link

commented Oct 14, 2015

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

@tinoue

This comment has been minimized.

Copy link

commented Nov 25, 2015

@ferrouswheel

This comment has been minimized.

Copy link

commented Dec 5, 2015

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

This comment has been minimized.

Copy link

commented Jan 26, 2016

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

@jay-to-the-dee

This comment has been minimized.

Copy link

commented Feb 29, 2016

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented May 1, 2016

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

@antran89

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link

commented May 3, 2016

@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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jun 18, 2016

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

@wenwei202

This comment has been minimized.

Copy link

commented Jul 12, 2016

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
@adam-erickson

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Sep 24, 2016

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

@hjc1028

This comment has been minimized.

Copy link

commented Sep 24, 2016

@wenwei202 It works

@bragilee

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

commented Oct 25, 2016

@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

This comment has been minimized.

Copy link

commented Oct 26, 2016

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

@ma-al

This comment has been minimized.

Copy link

commented Dec 7, 2016

Hi. Just sharing. I successfully compiled within Miniconda by doing:

conda uninstall protobuf

conda install protobuf==2.6.1
# NOTE: Do not use 2.5.0 or 3.0.0

This was in an Ubuntu 14.04.3 LTS machine, where the native protobuf versions were 2.5.0-9. Compiling against that results in:

CXX src/caffe/layers/infogain_loss_layer.cpp
In file included from ./include/caffe/util/cudnn.hpp:8:0,
                 from src/caffe/util/cudnn.cpp:2:
.build_release/src/caffe/proto/caffe.pb.h:17:2: error: This file was generated by an older version of protoc which is incompatible with your Protocol Buffer headers. Please regenerate this file with a newer version of protoc.

On the flip side, if you use the very latest, i.e., conda install protobuf==3.0.0, you'll get:

CXX/LD -o .build_release/examples/mnist/convert_mnist_data.bin
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'

Hopefully this helps the next guy that Google redirects here :bowtie:

Correction

Above is wrong. I confused the paths for includes and python with the conda ones. Long story short:

  1. compile caffe outside of your conda environment
  2. compile pycaffe inside your conda env (with appropriate changes to your Makefile.config
  3. then do conda install protobuf (so you can run caffe in python)
  • For step 1 above, you could also compile within a conda environment. Either make sure you don't have protobuf in there, or be careful with your include and libs environment variables
@seindlut

This comment has been minimized.

Copy link

commented Jan 18, 2017

Thanks @groakat
Deleting anaconda lib manually solved my problem.
For me, my situation is Ubuntu 16.04 + caffe + CUDA 8.0. Have to compile and install glog, gflag, protobuf and leveldb by myself. And manually remove the installed lib or anaconda lib confilcts.

@samarth-robo

This comment has been minimized.

Copy link

commented Jan 25, 2017

For anyone using Ubuntu 16.04 + Anaconda + Caffe, I was able to compile caffe without deleting Anaconda libs/files:

  • Remove all references to Anaconda in system path variables
  • run ccmake .. in caffe/build
  • hit t to toggle into advanced cmake mode where more variables are displayed
  • hit c couple of times to configure all library locations to system libraries
  • manually point PYTHON_EXECUTABLE to anaconda2/bin/python2.7, PYTHON_INCLUDE_DIR to anaconda2/include/python2.7 and PYTHON_LIBRARY to anaconda2/lib/libpython2.7.so
  • hit c again and then g to generate cmake files
  • make all -j8
  • Remember to prepend anaconda2/bin to system variable PATH again so that you are using Anaconda executables for python
@njbittner

This comment has been minimized.

Copy link

commented Mar 6, 2017

@samarth-robo, Great idea. Successful compilation for me, but fails on make runtest. You didn't run into that error at all?

@ssulun

This comment has been minimized.

Copy link

commented Apr 21, 2017

Regarding the first comment of Antran89

It's my stupidity for not noticing the thumbs down, but I follewed his advice and broke my system, now doing a reinstall, DO NOT REMOVE THE LIBRARY FILES.

@zchrissirhcz

This comment has been minimized.

Copy link

commented May 16, 2017

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.

@wang3t

This comment has been minimized.

Copy link

commented May 23, 2017

I ran into this similar issue on MacOS Sierra during installing caffe
$ make pycaffe -j8

ERROR:
.build_release/src/caffe/proto/caffe.pb.h:17:2: error: This file was generated by an older version of protoc

Finding:
I found the issue was "proton --version" was 3.0.0 from anaconda/bin,
but i had another protoc (3.1.0) in /usr/local/bin,

Solution:
Adding the following to my .profile
export PATH="/usr/local/bin:/anaconda/bin:$PATH"

HTH.

@selinachenxi

This comment has been minimized.

Copy link

commented Jun 16, 2017

@zchrissirhcz I have met the same problem, and by following your comments updating gcc from 4.9 to 5, the problem solved. Thank you so much.

@samuelcesc

This comment has been minimized.

Copy link

commented Jul 20, 2017

Had the same problem. Was using 2.6.1 through sudo apt-get while conda install had 3.2.

Just used conda remove libprotobuf to get rid of the Anaconda install and viola! it works!

@Anymake

This comment has been minimized.

Copy link

commented Dec 20, 2017

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

@huzqujm

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jan 11, 2018

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

@Laowai01

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Mar 25, 2018

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented May 31, 2018

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

@amitfishy

This comment has been minimized.

Copy link

commented Jun 15, 2018

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

This comment has been minimized.

Copy link

commented Jun 26, 2018

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

This comment has been minimized.

Copy link

commented Sep 25, 2018

If you are using Ubuntu, maybe this will help:

sudo apt-get install libprotobuf-dev protobuf-compiler

it can't help

@tonyhu20116543

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Mar 29, 2019

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

This comment has been minimized.

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.