I installed gflags:
$ ls /usr/local/lib/ | grep gflags
libgflags.a
libgflags_nothreads.a
$ ls /usr/local/include/ | grep gflags
gflags
And included <gflags/gflags.h>
#include <gflags/gflags.h>
DEFINE_bool(a, false, "test");
int main(int argc, char **argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
return 0;
}
But i got a linker-error!
$ g++ -lgflags a.cpp
/tmp/cchKYAWZ.o: In function `main':
/home/wonter/gflags-2.2.1/build/a.cpp:6: undefined reference to `google::ParseCommandLineFlags(int*, char***, bool)'
/tmp/cchKYAWZ.o: In function `__static_initialization_and_destruction_0(int, int)':
/home/wonter/gflags-2.2.1/build/a.cpp:3: undefined reference to `google::FlagRegisterer::FlagRegisterer<bool>(char const*, char const*, char const*, bool*, bool*)'
collect2: error: ld returned 1 exit status
I tried $ g++ /usr/local/lib/libgflags.a a.cpp -o test
, but got a same error.
My platform is Ubuntu 17.10
, GCC version is gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3)
Is it because of my GCC version of the problem?