pingcap / go-ycsb

A Go port of Yahoo! Cloud Serving Benchmark (YCSB)
Apache License 2.0
602 stars 244 forks source link

`CGO_LDFLAGS` miss in Makefile #218

Open chenlx0 opened 2 years ago

chenlx0 commented 2 years ago

Hi, I have installed rocksdb static library on my machine. And I try to compile go-ycsb with rocksdb support, but it fails when linking.

/data/clx_work/rocksdb/./util/compression.h:608: undefined reference to `snappy::RawCompress(char const*, unsigned long, char*, unsigned long*)'
/usr/local/lib/gcc/x86_64-pc-linux-gnu/9.4.0/../../../librocksdb.a(blob_file_builder.o): In function `rocksdb::BZip2_Compress(rocksdb::CompressionInfo const&, unsigned int, char const*, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
/data/clx_work/rocksdb/./util/compression.h:886: undefined reference to `BZ2_bzCompressInit'
/data/clx_work/rocksdb/./util/compression.h:900: undefined reference to `BZ2_bzCompress'
/data/clx_work/rocksdb/./util/compression.h:909: undefined reference to `BZ2_bzCompressEnd'
/usr/local/lib/gcc/x86_64-pc-linux-gnu/9.4.0/../../../librocksdb.a(blob_file_builder.o): In function `rocksdb::Zlib_Compress(rocksdb::CompressionInfo const&, unsigned int, char const*, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
/data/clx_work/rocksdb/./util/compression.h:705: undefined reference to `deflateInit2_'
/data/clx_work/rocksdb/./util/compression.h:714: undefined reference to `deflateSetDictionary'
/data/clx_work/rocksdb/./util/compression.h:732: undefined reference to `deflate'
/data/clx_work/rocksdb/./util/compression.h:741: undefined reference to `deflateEnd'
...

According to gorocksdb README.md, CGO_LDFLAGS is required when compiling with rocksdb static library. And this environment variable is missing in our Makefile.

CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd"

57 said that it is better to pass CGO_LDFLAGS outside the Makefile manually, I think it is better to mention this in readme.md to make this project more user-friendly.