ldb: Build failed on Ubuntu 14.04

Just build as mentioned in Readme.

g++ -o ldb ldb.cc ./lib/.cc -I./deps/leveldb/include -std=gnu++11 -lpthread -L/usr/local/include ./deps/leveldb/out-static/libleveldb.a linenoise.o ./deps/leveldb/out-static/libleveldb.a(table_builder.o): In function leveldb::TableBuilder::WriteBlock(leveldb::BlockBuilder_, leveldb::BlockHandle_)': table_builder.cc:(.text+0x92f): undefined reference to snappy::MaxCompressedLength(unsigned long)’ table_builder.cc:(.text+0x96d): undefined reference tosnappy::RawCompress(char const_, unsigned long, char_, unsigned long_)' ./deps/leveldb/out-static/libleveldb.a(format.o): In function leveldb::ReadBlock(leveldb::RandomAccessFile*, leveldb::ReadOptions const&, leveldb::BlockHandle const&, leveldb::BlockContents*)': format.cc:(.text+0x4d9): undefined reference tosnappy::GetUncompressedLength(char const_, unsigned long, unsigned long_)' format.cc:(.text+0x5ae): undefined reference to snappy::RawUncompress(char const, unsigned long, char_)’ collect2: error: ld returned 1 exit status make: *** [ldb] Error 1

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (3 by maintainers)

Commits related to this issue

Most upvoted comments

FYI There’s nowhere in the Makefile that adds -lsnappy. I just hacked it onto the end of the line 31, and it works. Probably should be added to the DEPS variable or something?

I successfully compiled on Ubuntu 14.04 with the following steps:

sudo apt-get autoremove libsnappy-dev
cd ./deps/leveldb
make clean && make
cd ../../
make

the error will disappear.Infact there’s no need to install libsnappy-dev on Ubuntu14.04 to compile ldb.