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

Compilation error when snappy is already installed #270

Closed
codeadict opened this issue Feb 15, 2023 · 9 comments · Fixed by #272
Closed

Compilation error when snappy is already installed #270

codeadict opened this issue Feb 15, 2023 · 9 comments · Fixed by #272

Comments

@codeadict
Copy link
Contributor

When libsnappy has been already installed via the OS package manager. Compiling eleveldb fails with the following error:

This happens on Ubuntu 22.04 and OTP 25.

===> Linking priv/eleveldb.so
===> sh(cc c_src/eleveldb.o c_src/refobjects.o c_src/workitems.o $LDFLAGS $LDLIBS -shared  -L"/home/il/Erlangs/25.2/lib/erl_interface-5.3/lib" -lei c_src/leveldb/libleveldb.a c_src/system/lib/libsnappy.a -lstdc++ -o priv/eleveldb.so)
failed with return code 1 and the following output:
/usr/bin/ld: c_src/system/lib/libsnappy.a(snappy.cc.o): relocation R_X86_64_PC32 against symbol `_ZTVN6snappy4SinkE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

make: *** [Makefile:22: rel] Error 1
@martinsumner
Copy link
Contributor

I'm out of my depth here when it comes to make scripts.

With a bit of help from google, perhaps adding --with-pic to the ./configure in https://github.com/basho/eleveldb/blob/develop/c_src/Makefile#L36 might work?

Perhaps @hmmr may be able to help

@hmmr
Copy link
Contributor

hmmr commented Feb 16, 2023

When I was preparing #266, I took a conservative approach and left code that downloads snappy and builds it. Now, however, I tend to think it's best to just rely on libsnappy preinstalled.

Regarding this particular error, can there be something in your LDFLAGS that shouldn't be there?

@hmmr
Copy link
Contributor

hmmr commented Feb 16, 2023

Opened #271, to simplify things.

@codeadict
Copy link
Contributor Author

Indeed, if we don't require a specific Snappy version, it might be better to rely on the OS one. @hmmr Thanks so much, I'll try your changes on my m1 mac

@codeadict
Copy link
Contributor Author

@hmmr I've opened #272 on top of your PR and added OSX to CI to ensure it never breaks. I'm still unsure if this works on all OSes until CI runs. I've tested it on my M1 mac and it works fine. @ioolkos If you can please give it a shot on your OS that would be great too.

@ioolkos
Copy link

ioolkos commented Feb 20, 2023

@codeadict #272 builds without issues for me on Ubuntu 20.04 and 22.04 (both with OTP 25)

@codeadict
Copy link
Contributor Author

codeadict commented Feb 21, 2023

@ioolkos It compiles but does not load the nif correctly if you try using eleveldb from the shell. Fails with {error,{load_failed,"Failed to load NIF library: '/home/runner/work/eleveldb/eleveldb/_build/test/lib/eleveldb/priv/eleveldb.so: undefined symbol: _ZN6snappy21GetUncompressedLengthEPKcmPm'"}} which probably indicates it expects snappy 1.1.9 that has a different signature and Ubuntu and Debian systems most have 1.1.8. I'm out of ideas here. So probably downloading and compiling snappy was not a bad idea, its what the erlang_rocksdb library does too but we have to find a way for the package manager installed library to not interfere with compiled one

@ioolkos
Copy link

ioolkos commented Feb 21, 2023

@codeadict hm, you're right, just confirmed this. sorry for not testing properly. I'll try to see whether I can find anything to do about this on Ubuntu.

@codeadict
Copy link
Contributor Author

Here is a job running these tests https://github.com/codeadict/eleveldb/actions/runs/4227609076.

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

Successfully merging a pull request may close this issue.

4 participants