My environment:
macOS 10.14
Clion 2018.1.2
gcc-8.2
I want to use Clion to try the rocksdb. I add a new CMakeLists.txt
file at examples directory.
CMakeLists.txt:
add_subdirectory(examples)
examples/CMakeLists.txt:
add_executable(s_test simple_example.cc)
target_link_libraries(s_test ${LIBS})
But when I build the s_test executable, I get the error as follows.
Linking CXX shared library librocksdb.dylib
Undefined symbols for architecture x86_64:
"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> >*)", referenced from:
__static_initialization_and_destruction_0(int, int) in db_bench_tool.cc.o
__static_initialization_and_destruction_0(int, int) in trace_analyzer_tool.cc.o
"google::SetUsageMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
rocksdb::db_bench_tool(int, char**) in db_bench_tool.cc.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[3]: *** [librocksdb.5.17.0.dylib] Error 1
make[2]: *** [CMakeFiles/rocksdb-shared.dir/all] Error 2
make[1]: *** [examples/CMakeFiles/s_test.dir/rule] Error 2
And I already installed the gflags previously.
ls /usr/local/lib | grep gflags
libgflags.2.2.1.dylib
libgflags.2.2.dylib
libgflags.dylib
libgflags_nothreads.2.2.1.dylib
libgflags_nothreads.2.2.dylib
libgflags_nothreads.dylib
How to solve it? Thank you!