heapwolf / ldb

A C++ REPL / CLI for LevelDB
MIT License
201 stars 23 forks source link

Build failed on Ubuntu 14.04 #48

Closed xuanzhaopeng closed 6 years ago

xuanzhaopeng commented 8 years ago

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(tablebuilder.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

danielepolencic commented 7 years ago

same issue for me on ubuntu 14.04

ghost commented 7 years ago

+1

harmeetsingh0013 commented 7 years ago

Same issue for me on Ubuntu 16.04.

What is the alternate for using ldb?

feifei435 commented 7 years ago

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.

franksunjin commented 7 years ago

I tried osx/ubuntu/rhel/centos, nothing works, also clib

heapwolf commented 7 years ago

osx works fine for me, but i'm getting an error with linenoise, looking into it.

heapwolf commented 7 years ago

@franksunjin would you mind posting the errors you are getting?

franksunjin commented 7 years ago

Mac:ldb$ git diff diff --git a/Makefile b/Makefile index f506b17..46f7150 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ deps/snappy: git clone --depth 1 git://github.com/0x00A/snappy.git ./deps/snappy

deps/docopt:

Also it failed to download and build snappy somehow, I need to manually link snappy from my local

franksunjin commented 7 years ago

I think the issue of xuanzhaopeng@ is make failed to link snappy

heapwolf commented 7 years ago

@franksunjin can you post the output of the errors though? That looks like the diff of my last fix for the issue where cloning required authentication.

gumb0 commented 7 years ago

@0x00A Here's what I'm getting on Ubuntu 14.04: https://gist.github.com/gumb0/f6651a3c1872ea9c5bbf31523b18fb47

Also installing with clib gives:

$ clib install hij1nx/ldb
       fetch : hij1nx/ldb:package.json

gzip: ldb-2.0.0.tar.gz: not in gzip format
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
mhirsch commented 7 years ago

I get the same error on Fedora 24:

$ make
make -C ./deps/leveldb
make[1]: Entering directory '/home/mhirsch/ldb/deps/leveldb'
make[1]: Nothing to be done for 'default'.
make[1]: Leaving directory '/home/mhirsch/ldb/deps/leveldb'
g++ -o ldb ldb.cc ./lib/*.cc ./deps/docopt/docopt.cpp -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+0x730): undefined reference to `snappy::MaxCompressedLength(unsigned long)'
table_builder.cc:(.text+0x75d): undefined reference to `snappy::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+0x4c2): undefined reference to `snappy::GetUncompressedLength(char const*, unsigned long, unsigned long*)'
format.cc:(.text+0x570): undefined reference to `snappy::RawUncompress(char const*, unsigned long, char*)'
collect2: error: ld returned 1 exit status
Makefile:31: recipe for target 'ldb' failed
make: *** [ldb] Error 1
$ rpm -ql snappy-devel
/usr/include/snappy-c.h
/usr/include/snappy-sinksource.h
/usr/include/snappy-stubs-public.h
/usr/include/snappy.h
/usr/lib64/libsnappy.so
/usr/share/doc/snappy-devel
/usr/share/doc/snappy-devel/format_description.txt
/usr/share/doc/snappy-devel/framing_format.txt
mhirsch commented 7 years ago

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?

liyongming1982 commented 6 years ago

I just move "-lsnappy" to the last and it works in ubuntu: $(BIN): $(DEPS) $(LIBPATH)/*.cc deps/docopt $(CXX) -o $(BIN) $(SRC) $(CXXFLAGS) -lpthread -L/usr/local/lib $(LIBLEVELDB) $(DEPS) -lsnappy

maxkerp commented 6 years ago

I ran into some build errors myself.

First of all, deps/leveldb/ has no Makefile. It needs to be created by cmake. If you run ubuntu 16.04, you need to compile cmake from source, since leveldb requires a newer version than the one that comes with 16.04. Ones you ran cmake in deps/leveldb/ you can run make in deps/leveldb/. (Maybe this Makefile could be modified to do this for you)

To successfully run make install for ldb I needed to change two things in the Makefile.

diff --git a/Makefile b/Makefile
index a4d308b..d8f1c35 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ LIBPATH ?= ./lib
 SRC = ldb.cc $(LIBPATH)/*.cc ./deps/docopt/docopt.cpp
 PREFIX ?= /usr/local
 LEVELDBPATH ?= ./deps/leveldb
-LIBLEVELDB ?= $(LEVELDBPATH)/out-static/libleveldb.a
+LIBLEVELDB ?= $(LEVELDBPATH)/libleveldb.a
 LIBSNAPPY ?= ./deps/snappy
 CXXFLAGS += -I$(LEVELDBPATH)/include -std=gnu++11

@@ -28,7 +28,7 @@ leveldb: $(LEVELDBPATH)
        make -C $(LEVELDBPATH)

 $(BIN): $(DEPS) $(LIBPATH)/*.cc deps/docopt
-       $(CXX) -o $(BIN) $(SRC) $(CXXFLAGS) -lpthread -L/usr/local/lib -lsnappy $(LIBLEVELDB) $(DEPS)
+       $(CXX) -o $(BIN) $(SRC) $(CXXFLAGS) -lpthread -L/usr/local/lib $(LIBLEVELDB) $(DEPS) -lsnappy

 deps/snappy:
        git clone --depth 1 https://github.com/0x00A/snappy ./deps/snappy

The libleveldb.a-file moved to the deps/leveldb root directory and linking snappy not at the end of the compiler statement gave me a linker error. Thanks a lot to @liyongming1982. I would have been lost without your comment and given up.

But after these modifications make install run through just fine. Using ldb without problems so far. Thanks a lot @0x00A :+1: