1

I am trying to compile file which have GFLAGS inside. My compiling command :

g++ -I ../eigen-eigen-b9cd8366d4e8/ -I/caffe_path/distribute/include  my_file.cpp -std=c++0x   -lpthread -lglog -lboost_system -DUSE_OPENCV 

My error message is:

/usr/bin/ld: /tmp/ccv5GAaZ.o: undefined reference to symbol '_ZN6google26ShowUsageWithFlagsRestrictEPKcS1_'
//usr/lib/x86_64-linux-gnu/libgflags.so.2: error adding symbols: DSO missing from command line

It is my first time working with Gflags. Based on the suggestion on internet i tried to comment lines with#ifndef and #endif in the following lines but it did not help.

#ifndef GFLAGS_GFLAGS_H_
  namespace gflags = google;
#endif

I also tried suggestions on this thread , but it did not fix anything.

MIRMIX
  • 1,052
  • 2
  • 14
  • 40
  • 1
    When I hit an error of this type, it turned out to be an inconsistency in the library versions I was loading. Check your LDD_LIBRARY_PATH to make sure you're getting the correct versions of each module. You might also try `ldd` on some useful objects. Check your overall environment for inconsistencies, and make sure that you've `source`d the proper *vars.sh files. – Prune Jun 08 '17 at 15:26
  • I download my OS (Ubuntu 16.04) and install all libraries recently. So i dont much think that there can be some inconsistencies regarding obsolete libraries. May be as you said there is still some inconsistencies because of some other reason. What you mean by LDD_LIBRARY_PATH & proper *vars.sh file. – MIRMIX Jun 08 '17 at 15:35
  • 1
    I put an extra 'D' in that; it should be `LD_LIBRARY_PATH`. It's a standard environment variable, controlling library load preference. Some tools have a script in their $_HOME/bin directory named `vars.sh`; for those tools, you (or a build script) need to source the file to set the path variables properly. For instance, MKL (Intel's Math Kernel Library) has one. – Prune Jun 08 '17 at 15:43
  • when i command this `echo $LD_LIBRARY_PATH` it prints nothing – MIRMIX Jun 08 '17 at 15:51
  • 1
    That worries me -- but I work in a more populated environment. I don't know what you're *supposed* to have, since I don't know what you already have; I'm just trying to gather info for someone who knows your Caffe's internals better than I do. – Prune Jun 08 '17 at 16:14

1 Answers1

1

The gflags installed inside the caffe and seperately were somehow causing conflict. Uninstalling any of them did not help. Solution for me was uninstallation (all) of the whole caffe and gflags (internals and externals) solved the problem. When I was sure that there is no trace of gflags/glogs and caffe on my system I was able to install caffe again.

MIRMIX
  • 1,052
  • 2
  • 14
  • 40