0

I got an issue when compiling glog by running 'make' after running './configure' Then I got an error:

Undefined symbols for architecture x86_64: "testing::internal::StrStreamToString(std::__1::basic_stringstream, std::__1::allocator >)", referenced from: testing::internal::String testing::internal::StreamableToString(void const const&) in logging_unittest-logging_unittest.o testing::internal::String testing::internal::StreamableToString(int const&) in logging_unittest-logging_unittest.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: * [logging_unittest] Error 1

I am using glog-0.3.3 on Mac OS X. SO how can i turn of testing while compiling glog?

In another context, i installed glog and gflags by using Macport, then i run a small program. It will generate a error : "ERROR: unknown command line flag 'logtostderr'"

I believe that's the problem with linking to gflags. So how can i fix it. Thanks

Phong Nguyen
  • 51
  • 2
  • 8

1 Answers1

1

GLog needs GFlags compiled in the "google" namespace instead of the now default "gflags" namespace.

In order to set this namespace you must compile and install gflags from source and set the GFLAGS_NAMESPACE variable to "google".

Here are the steps I followed in Kubuntu 14.04 and should be similar to what you should do in Mac OSX. These will place the GFlags source in /usr/local/src and install the library in the /usr/local/lib&include directories. The last command (ldconfig) registers the library in the system.

cd /usr/local/src/
cp /path/to/downloaded/gflags-2.1.1.tar.gz .
sudo tar xzf gflags-2.1.1.tar.gz
cd /tmp
mkdir buildgflags
cd buildgflags
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON \
-DGFLAGS_NAMESPACE=google -G"Unix Makefiles" /usr/local/src/gflags-2.1.1/
make
sudo make install
sudo ldconfig

Alternatively you can apply the following patch in the GLog source (attached in the last reply):

https://code.google.com/p/google-glog/issues/detail?id=194

It basically uses the namespace of gflags after the includes on the GLogs unit test source files like so:

#ifdef HAVE_LIB_GFLAGS
#include <gflags/gflags.h>
using namespace gflags;
#endif