Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compile rocksdb with lz4 support? #814

Closed
guileen opened this issue Nov 3, 2015 · 9 comments
Closed

How to compile rocksdb with lz4 support? #814

guileen opened this issue Nov 3, 2015 · 9 comments
Assignees
Labels

Comments

@guileen
Copy link

guileen commented Nov 3, 2015

There is no document for how to compile rocksdb with lz4 support, I work on it for whole afternoon, failed.

@igorcanadi
Copy link
Collaborator

You just have to install it on your system -- our compile process detects this automatically: https://github.com/facebook/rocksdb/blob/master/build_tools/build_detect_platform#L263

@guileen
Copy link
Author

guileen commented Nov 4, 2015

Thanks, I get it. But I got another issue with how to link librocksdb.a.

I use gorocks, is a golang module. It should compile with cgo.

Command:

CGO_CFLAGS="-I../rocksdb/include" CGO_LDFLAGS="-L../rocksdb" go install ./

Error:

VERY LONG TEXT ABOVE
....
std::__1::future<rocksdb::BackupEngineImpl::CopyResult>::future(std::__1::__assoc_state<rocksdb::BackupEngineImpl::CopyResult>*) in librocksdb.a(backupable_db.o)
      rocksdb::(anonymous namespace)::ParseCompressionType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in librocksdb.a(options_helper.o)
      rocksdb::(anonymous namespace)::ParseOptionHelper(char*, rocksdb::OptionType const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in librocksdb.a(options_helper.o)
      ...
  "___dynamic_cast", referenced from:
      rocksdb::ParseColumnFamilyOption(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rocksdb::ColumnFamilyOptions*) in librocksdb.a(options_helper.o)
      void std::__1::__sort<rocksdb::(anonymous namespace)::CompareLogByPointer&, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*>(std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, rocksdb::(anonymous namespace)::CompareLogByPointer&) in librocksdb.a(wal_manager.o)
      unsigned int std::__1::__sort3<rocksdb::(anonymous namespace)::CompareLogByPointer&, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*>(std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, rocksdb::(anonymous namespace)::CompareLogByPointer&) in librocksdb.a(wal_manager.o)
      unsigned int std::__1::__sort4<rocksdb::(anonymous namespace)::CompareLogByPointer&, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*>(std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, rocksdb::(anonymous namespace)::CompareLogByPointer&) in librocksdb.a(wal_manager.o)
      unsigned int std::__1::__sort5<rocksdb::(anonymous namespace)::CompareLogByPointer&, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*>(std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, rocksdb::(anonymous namespace)::CompareLogByPointer&) in librocksdb.a(wal_manager.o)
      bool std::__1::__insertion_sort_incomplete<rocksdb::(anonymous namespace)::CompareLogByPointer&, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*>(std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, rocksdb::(anonymous namespace)::CompareLogByPointer&) in librocksdb.a(wal_manager.o)
  "___gxx_personality_v0", referenced from:
      _rocksdb_open in librocksdb.a(c.o)
      _rocksdb_open_for_read_only in librocksdb.a(c.o)
      _rocksdb_backup_engine_open in librocksdb.a(c.o)
      _rocksdb_backup_engine_create_new_backup in librocksdb.a(c.o)
      _rocksdb_backup_engine_restore_db_from_latest_backup in librocksdb.a(c.o)
      _rocksdb_open_column_families in librocksdb.a(c.o)
      _rocksdb_open_for_read_only_column_families in librocksdb.a(c.o)
      ...
  "_deflate", referenced from:
      rocksdb::BlockBasedTableBuilder::WriteBlock(rocksdb::Slice const&, rocksdb::BlockHandle*) in librocksdb.a(block_based_table_builder.o)
  "_deflateEnd", referenced from:
      rocksdb::BlockBasedTableBuilder::WriteBlock(rocksdb::Slice const&, rocksdb::BlockHandle*) in librocksdb.a(block_based_table_builder.o)
  "_deflateInit2_", referenced from:
      rocksdb::BlockBasedTableBuilder::WriteBlock(rocksdb::Slice const&, rocksdb::BlockHandle*) in librocksdb.a(block_based_table_builder.o)
  "_inflate", referenced from:
      rocksdb::Zlib_Uncompress(char const*, unsigned long, int*, unsigned int, int) in librocksdb.a(format.o)
  "_inflateEnd", referenced from:
      rocksdb::Zlib_Uncompress(char const*, unsigned long, int*, unsigned int, int) in librocksdb.a(format.o)
  "_inflateInit2_", referenced from:
      rocksdb::Zlib_Uncompress(char const*, unsigned long, int*, unsigned int, int) in librocksdb.a(format.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@guileen
Copy link
Author

guileen commented Nov 4, 2015

I change my install command, add -lz flag

CGO_CFLAGS="-I../rocksdb/include" CGO_LDFLAGS="-L../rocksdb -lz" go install ./

The error become:

VERY LONG TEXT ABOVE
...
(options_helper.o)
      ...
  "___dynamic_cast", referenced from:
      rocksdb::ParseColumnFamilyOption(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rocksdb::ColumnFamilyOptions*) in librocksdb.a(options_helper.o)
      void std::__1::__sort<rocksdb::(anonymous namespace)::CompareLogByPointer&, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*>(std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, rocksdb::(anonymous namespace)::CompareLogByPointer&) in librocksdb.a(wal_manager.o)
      unsigned int std::__1::__sort3<rocksdb::(anonymous namespace)::CompareLogByPointer&, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*>(std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, rocksdb::(anonymous namespace)::CompareLogByPointer&) in librocksdb.a(wal_manager.o)
      unsigned int std::__1::__sort4<rocksdb::(anonymous namespace)::CompareLogByPointer&, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*>(std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, rocksdb::(anonymous namespace)::CompareLogByPointer&) in librocksdb.a(wal_manager.o)
      unsigned int std::__1::__sort5<rocksdb::(anonymous namespace)::CompareLogByPointer&, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*>(std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, rocksdb::(anonymous namespace)::CompareLogByPointer&) in librocksdb.a(wal_manager.o)
      bool std::__1::__insertion_sort_incomplete<rocksdb::(anonymous namespace)::CompareLogByPointer&, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*>(std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, std::__1::unique_ptr<rocksdb::LogFile, std::__1::default_delete<rocksdb::LogFile> >*, rocksdb::(anonymous namespace)::CompareLogByPointer&) in librocksdb.a(wal_manager.o)
  "___gxx_personality_v0", referenced from:
      _rocksdb_open in librocksdb.a(c.o)
      _rocksdb_open_for_read_only in librocksdb.a(c.o)
      _rocksdb_backup_engine_open in librocksdb.a(c.o)
      _rocksdb_backup_engine_create_new_backup in librocksdb.a(c.o)
      _rocksdb_backup_engine_restore_db_from_latest_backup in librocksdb.a(c.o)
      _rocksdb_open_column_families in librocksdb.a(c.o)
      _rocksdb_open_for_read_only_column_families in librocksdb.a(c.o)
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@igorcanadi
Copy link
Collaborator

This looks like some library wasn't linked properly. Quick google search led me to this: http://stackoverflow.com/questions/16368480/xcode-when-i-have-a-library-that-is-using-c-why-must-i-use-compile-as-object

@guileen
Copy link
Author

guileen commented Nov 4, 2015

I want to make a golang rocksdb server, link all required libraries inside on folder, without any dependencies with system environment.

/project/vendor/include
     |- rocksdb/c.h ...
/project/vendor/lib
     |- librocksdb.a
     |- liblz4.a
/project/gofiles
     |- *.go

LD_LIBRARY_PATH=vendor/lib CGO_CFLAGS="-Ivendor/include" CGO_LDFLAGS="-Lvendor/lib -lz -llz4 -lrocksdb" go install ./

gorocks only depends on rocksdb, but rocksdb seems depends on other libraries, I think I need all the list of rocksdb depends libraries on compile time.

@guileen
Copy link
Author

guileen commented Nov 4, 2015

I solved this eventually. Mac OS use DYLD_LIBRARY_PATH instead of LD_LIBRARY_PATH.

DYLD_LIBRARY_PATH=/path/to/rocksdb

Every thing works well.

@guileen guileen closed this as completed Nov 4, 2015
@guileen
Copy link
Author

guileen commented Nov 4, 2015

I still can't compile rocksdb with lz4 support on mac OSX. it just not show any errors.

Are there any way I can force the compile script force compile with lz4, so I can see any error exists.

@guileen guileen reopened this Nov 4, 2015
@adamretter adamretter added the mac label Oct 10, 2016
@zengqingfu1442
Copy link

I have installed these on my system with yum,
[dzeng@dzeng rocksdb-master]$ rpm -qa | grep lz4
lz4-1.7.3-1.el7.x86_64
lz4-devel-1.7.3-1.el7.x86_64
[dzeng@dzeng rocksdb-master]$ rpm -qa | grep zstd
libzstd-devel-1.3.1-1.el7.x86_64
libzstd-1.3.1-1.el7.x86_64
zstd-1.3.1-1.el7.x86_64
[dzeng@dzeng rocksdb-master]$ rpm -qa | grep snappy
snappy-devel-1.1.0-3.el7.x86_64
snappy-1.1.0-3.el7.x86_64
[dzeng@dzeng rocksdb-master]$ rpm -qa | grep zlib
zlib-1.2.7-17.el7.x86_64
zlib-1.2.7-17.el7.i686
zlib-devel-1.2.7-17.el7.x86_64

Then I compile rocksdb using "make release", the tool db_sanity_test can also link to the so file,
[dzeng@dzeng rocksdb-master]$ ldd db_sanity_test
linux-vdso.so.1 => (0x00007ffe8ffe8000)
libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007f8107418000)
librt.so.1 => /usr/lib64/librt.so.1 (0x00007f810720f000)
libsnappy.so.1 => /usr/lib64/libsnappy.so.1 (0x00007f8107009000)
libgflags.so.2.1 => /usr/lib64/libgflags.so.2.1 (0x00007f8106de8000)
libz.so.1 => /usr/lib64/libz.so.1 (0x00007f8106bd1000)
libcssz.so => /usr/lib64/libcssz.so (0x00007f8106929000)
libbz2.so.1 => /usr/lib64/libbz2.so.1 (0x00007f8106719000)
liblz4.so.1 => /usr/lib64/liblz4.so.1 (0x00007f8106505000)
libzstd.so.1 => /usr/lib64/libzstd.so.1 (0x00007f81062a6000)
libnuma.so.1 => /usr/lib64/libnuma.so.1 (0x00007f810609a000)
libtbb.so.2 => /usr/lib64/libtbb.so.2 (0x00007f8105e64000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f8105b5c000)
libm.so.6 => /usr/lib64/libm.so.6 (0x00007f810585a000)
libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007f8105643000)
libc.so.6 => /usr/lib64/libc.so.6 (0x00007f8105280000)
/lib64/ld-linux-x86-64.so.2 (0x0000561a0cb8c000)
libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007f810507b000)

But it can't support lz4 compression,
[dzeng@dzeng rocksdb-master]$ ./db_sanity_test /mnt/sfx-card-root/rocksdb570/ create
Creating...
Basic -- OK
SpecialComparator -- OK
ZlibCompression -- OK
ZlibCompressionVersion2 -- OK
CSSZlibCompression -- OK
CSSZlibCompressionVersion2 -- OK
LZ4Compression -- Corruption: LZ4 not supported or corrupted LZ4 compressed block contents
FAIL
LZ4HCCompression -- Corruption: LZ4HC not supported or corrupted LZ4HC compressed block contents
FAIL
ZSTDCompression -- OK
PlainTable -- OK
BloomFilter -- OK

@gfosco
Copy link
Contributor

gfosco commented Feb 22, 2018

I cloned lz4/lz4 from GitHub and ran make && sudo make install, was able to compile rocksdb with lz4 enabled on macOS:

[$] ~/git/rocksdb [master]: ./db_sanity_test /tmp/s create
Creating...
Basic -- OK
SpecialComparator -- OK
ZlibCompression -- OK
ZlibCompressionVersion2 -- OK
LZ4Compression -- OK
LZ4HCCompression -- OK
ZSTDCompression -- Invalid argument: Compression type ZSTD is not linked with the binary.
FAIL
PlainTable -- OK
BloomFilter -- OK
[$] ~/git/rocksdb [master]: otool -L db_sanity_test
db_sanity_test:
	/usr/local/opt/gflags/lib/libgflags.2.2.dylib (compatibility version 2.2.0, current version 2.2.1)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
	/usr/local/lib/liblz4.1.dylib (compatibility version 1.0.0, current version 1.8.1)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants
@guileen @gfosco @igorcanadi @adamretter @zengqingfu1442 @anand1976 and others