Note: Please use Issues only for bug reports. For questions, discussions, feature requests, etc. post to dev group: https://www.facebook.com/groups/rocksdb.dev
g++ -O0 -rdynamic -g3 -ggdb -pedantic -Wno-unused-value -Wno-variadic-macros -Wno-deprecated -c -fmessage-length=0 --static -w -Wcast-align -Wall -Werror -std=c++11 -I../test/include/ -c test.cpp -o test.o
g++ -L../libs -o test -Xlinker '-(' -llz4 -luuid -lz -ljsoncpp -lssl -lrt -lmsgpackc -lrocksdb -lgnutls -lnettle -largon2 -lopendht -lsnappy -lbz2 -lzstd -luv -lxbase -lxutl -lxcrypto -ldl -lgcc -std=c++11 -lstdc++ -lpthread test.o -Xlinker '-)'
build success
but when I change O0 to O2 or O3,it build failed. and I try to change rocksdb to v5.14.2,it is also failed。
test.o:(.rodata._ZTIN7rocksdb11StackableDBE[_ZTIN7rocksdb11StackableDBE]+0x10):undefined reference to `typeinfo for rocksdb::DB'
collect2: error: ld returned 1 exit status
I build rocksdb with(PORTABLE=1 make static_lib)。 google this error , can only find https://gitlab.cern.ch/eos/quarkdb/-/jobs/646549, but no Solution。
Just a guess - it may be because we use -fno-rtti compiler flag. You can set the environment variable USE_RTTI=1 for your make command to change this behavior.
If that doesn't work, it'd be helpful to provide some details on what "test.cpp" does. I tried using your build commands with a simple test file that just calls DB::Open, but the problem didn't reproduce (tried both -O2 and -O3 as well).
@ajkr Thanks,it really works.
Most helpful comment
Just a guess - it may be because we use
-fno-rtticompiler flag. You can set the environment variableUSE_RTTI=1for your make command to change this behavior.If that doesn't work, it'd be helpful to provide some details on what "test.cpp" does. I tried using your build commands with a simple test file that just calls
DB::Open, but the problem didn't reproduce (tried both-O2and-O3as well).