Search code examples
caffegflags

Compiling caffe causing undefined references with google namespace


I had problems with my code which was causing errors because of gflags. So i decided to play with gflags repositories and linkings manually which seems that was a bad idea. Now I even cannot compile caffe.

While making it all this following command

make all -j $(($(nproc) + 1))

I am getting following error message.

.build_release/tools/convert_imageset.o: In function `_GLOBAL__sub_I_convert_imageset.cpp':
convert_imageset.cpp:(.text.startup+0x74): undefined reference to `google::FlagRegisterer::FlagRegisterer<bool>(char const*, char const*, char const*, bool*, bool*)'
convert_imageset.cpp:(.text.startup+0xa3): undefined reference to `google::FlagRegisterer::FlagRegisterer<bool>(char const*, char const*, char const*, bool*, bool*)'
convert_imageset.cpp:(.text.startup+0x117): 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> >*)'

I looked through Internet for some possible solutions in some git threads and some other threads . Nothing working. Any kind of help or suggestion will be highly appreciated.


Solution

  • The problem is solved by downloading gflags package and installing it manually. Using following commands:

    $ tar xzf gflags-$version-source.tar.gz
    $ cd gflags-$version
    $ mkdir build && cd build
    $ ccmake ..
    
      - Press 'c' to configure the build system and 'e' to ignore warnings.
      - Set CMAKE_INSTALL_PREFIX and other CMake variables and options.
      - Continue pressing 'c' until the option 'g' is available.
      - Then press 'g' to generate the configuration files for GNU Make.
    
    $ sudo make -j4
    $ sudo make test    -j4 
    $ sudo make install -j4