Repository: facebookarchive/caffe2

Issue #1980: Errors including std::__cxx11 or [abi:cxx11] or Linux with Anaconda
Created: 2018-02-16T23:36:58Z
This is an issue to track solutions and updates to these common errors encountered when installing Caffe2 with Anaconda on some Linux distros:
undefined reference to `google::protobuf::internal::AssignDescriptors(std::__cxx11::basic_string
undefined reference to `leveldb::Status::ToString[abi:cxx11]()
Undefined reference to google::protobuf::internal::empty_string_[abi:cxx11]

These problems most commonly arise when using Anaconda's versions of protobuf, leveldb, or opencv.
These are all caused by this https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html . Basically, default Ubuntu ships with gcc 4.8.5 , but a lot of Anaconda libraries have been built with gcc 5+ . Libraries compiled with gcc > 5 are not compatible with those compiled with gcc < 5, due to changes in std::string and std::list; see the earlier link for details. What this means is that you must ensure that all of the libraries that Caffe2 is built against have the same ABI version, either all built with gcc < 5 or all built with gcc > 5.
If you encounter any of these errors that have [abi:cxx11] or std::__cxx11:: in them, then try one of the following options:

If you don't need to change Caffe2's source code, then just install our pre-built binary with conda install -c caffe2 caffe2 (or if you want CUDA, then conda install -c caffe2 caffe2-cuda9.0-cudnn7)

If you need to build from source:

Try adding -DCMAKE_CXX_FLAGS=-D__GLIBCXX_USE_CXX11_ABI=0 to your cmake call. If you are installing with conda-build, then your cmake call will be in either conda/cuda/build.sh conda/no_cuda/build.sh.
Use system versions of protobuf, opencv, or leveldb (try installing with apt-get). Uninstall these libraries from Anaconda and try to build again.
In both of these cases, remember to delete your build folder to remove any caching effects.

We will work on automatic detection of the gcc ABI version so that we can detect these problems and warn about them before they happen. A solution to allow seamless installs from source on Ubuntu machines with Anaconda packages may be very difficult, and we are open to suggestions.
UPDATE:
There are now gcc4.8 compatible conda packages available. You can install them like
conda install -c caffe2 caffe2-gcc4.8 or conda install -c caffe2-cuda9.0-cudnn7-gcc4.8
If you want to build Caffe2 from source but still want to use Anaconda and would like to avoid any gcc mismatch problems, then use https://github.com/caffe2/caffe2/blob/master/scripts/build_anaconda.sh , which can help adapt the conda-build process based on your gcc version.
For example, you can run
CONDA_INSTALL_LOCALLY=1 scripts/build_anaconda.sh
to build Caffe2 and install into the current conda environment or
CONDA_INSTALL_LOCALLY=1 BUILD_ENVIRONMENT=-cuda- scripts/build_anaconda.sh
to build Caffe2 with CUDA support and install into the current conda environment.

Duplicate issue #491: Executable linker error: undefined reference to google::FlagRegisterer::FlagRegisterer
Created: 2017-05-03T09:25:55Z
Hi everyone,
when building Caffe2 I get linker erros of the following kind:
CMakeFiles/make_cifar_db.dir/binaries/make_cifar_db.cc.o: In function __static_initialization_and_destruction_0(int, int): /src/Caffe2/caffe2/binaries/make_cifar_db.cc:20: undefined reference to google::FlagRegisterer::FlagRegisterer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(char const*, char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)
The same errors occur for all executables that are linked. I attached the full output. Any idea what might be causing this?
Cheers,
Peter
Caffe2Errors.log.zip

Closing comment (2018-02-16T23:50:01Z): I think this error is the same as #1980