bytedance / terarkdb

A RocksDB compatible KV storage engine with better performance
Apache License 2.0
2.05k stars 202 forks source link

undefined reference error when linking #168

Closed orca-zhang closed 2 years ago

orca-zhang commented 2 years ago

[BUG]

Expected behavior

build pass

Actual behavior

linking error

/usr/bin/ld: $WORK/b001/_x017.o: in function `_cgo_3def89031119_Cfunc_rocksdb_options_set_fifo_compaction_options':
options.cgo2.c:(.text+0x9d4): undefined reference to `rocksdb_options_set_fifo_compaction_options'
/usr/bin/ld: $WORK/b001/_x017.o: in function `_cgo_3def89031119_Cfunc_rocksdb_options_set_inplace_update_support':
options.cgo2.c:(.text+0xb54): undefined reference to `rocksdb_options_set_inplace_update_support'
collect2: error: ld returned 1 exit status

Steps to reproduce the behavior

sudo apt-get install libaio-dev -y
cmake ../ -DCMAKE_INSTALL_PREFIX=output -DCMAKE_BUILD_TYPE=Release -DWITH_TESTS=OFF -DWITH_TERARK_ZIP=OFF
make -j $(nproc)
make install

cp output/lib/libterarkdb.a lib/librocksdb.a

export CGO_CFLAGS="-I$PWD/third-party/terarkdb/output/output/include"
export CGO_LDFLAGS="-L$PWD/third-party/terarkdb/output/lib -Wl,-Bstatic -lrocksdb -lbz2 -ljemalloc -llz4 -lsnappy -lz -lzstd -Wl,-Bdynamic -lstdc++ -lm -pthread -lgomp -lrt -ldl -laio"

go get github.com/tecbot/gorocksdb

[Enhancement]

Problem

undefined reference error when linking

Solution

make-up the functions left behind