basho / eleveldb

Erlang LevelDB API
263 stars 176 forks source link

Cannot compile on Mac OS #252

Closed roynalnaruto closed 5 years ago

roynalnaruto commented 5 years ago

I am facing compilation errors in the eleveldb dependency. A complete report of the log, I have posted here: https://gist.github.com/roynalnaruto/0dab850266367d7e99e4787a98ef355f

Any help regarding this would be appreciated

ergl commented 5 years ago

Getting the same issue, was fixed with PR #245. It would be good to get a new version on hex that contains this fix.

EDIT: In the meantime, you might try adding that flag manually yourself during compilation. If you're using make, simply do:

make CFLAGS+="-stdlib=libc++" \
    CXXFLAGS+="-stdlib=libc++" \
    DRV_CFLAGS+="-stdlib=libc++" \
    DRV_LDFLAGS+="-stdlib=libc++"
roynalnaruto commented 5 years ago

@ergl thanks! It worked, yes it would be helpful to get a bumped version on hex

binarytemple commented 5 years ago

@erlg thanks for taking the time to post your fix - wasted half of yesterday on this (missed the DRV_ vars

bryanhuntesl commented 5 years ago

Worth mentioning this fix doesn't work unless you build from the 'develop' branch as it has this https://github.com/basho/eleveldb/pull/245 PR applied

ergl commented 5 years ago

@bryanhuntesl if you're already depending on develop, I don't think you should have any problems compiling, since the fix is already there. The solution I posted above is doing the same as #245, but at the Makefile level.

The upside of #245 is that it adds the flags only at the eleveldb dependency level, whereas what I posted will apply to the same project.

jvf commented 4 years ago

Building on macOS did not work for me with the only the changes from #245, it failed as follows:

$ mix deps.compile eleveldb
===> Compiling eleveldb
...
/Library/Developer/CommandLineTools/usr/bin/make  all-am
/bin/sh ./libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.     -g -O2 -MT snappy.lo -MD -MP -MF .deps/snappy.Tpo -c -o snappy.lo snappy.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -g -O2 -MT snappy.lo -MD -MP -MF .deps/snappy.Tpo -c snappy.cc  -fno-common -DPIC -o snappy.o
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from snappy.cc:29:
./snappy.h:43:10: fatal error: 'string' file not found
#include <string>
         ^~~~~~~~
1 warning and 1 error generated.
make[1]: *** [snappy.lo] Error 1
make: *** [all] Error 2
===> Hook for compile failed!

** (Mix) Could not compile dependency :eleveldb, "/Users/jvf/.mix/rebar3 bare compile --paths "/Users/jvf/repos/sonnen/vpp/_build/dev/lib/*/ebin"" command failed. You can recompile this dependency with "mix deps.compile eleveldb", update it with "mix deps.update eleveldb" or clean it with "mix deps.clean eleveldb"

As you can see the problem is with building Snappy, I created #258 to fix this.