stephan-hof / pyrocksdb

Python bindings for RocksDB
BSD 3-Clause "New" or "Revised" License
150 stars 169 forks source link

Build problem on mac osx and python3 #28

Closed gra-moore closed 9 years ago

gra-moore commented 9 years ago

Hi,

On mac osx (Yosemite 10.10.3) with gcc:

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin14.3.0 Thread model: posix

And Clang

Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin14.3.0 Thread model: posix

I am able to build and test pyrocksdb with python 2.7 but when attempting:

sudo python setup.py install with python3.4 I get the following error:

running install running bdist_egg running egg_info writing dependency_links to pyrocksdb.egg-info/dependency_links.txt writing pyrocksdb.egg-info/PKG-INFO writing top-level names to pyrocksdb.egg-info/top_level.txt writing requirements to pyrocksdb.egg-info/requires.txt reading manifest file 'pyrocksdb.egg-info/SOURCES.txt' writing manifest file 'pyrocksdb.egg-info/SOURCES.txt' installing library code to build/bdist.macosx-10.6-intel/egg running install_lib running build_py running build_ext building 'rocksdb._rocksdb' extension /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -c rocksdb/_rocksdb.cpp -o build/temp.macosx-10.6-intel-3.4/rocksdb/_rocksdb.o -std=gnu++11 -O3 -Wall -Wextra -Wconversion -fno-strict-aliasing In file included from rocksdb/_rocksdb.cpp:298: /usr/local/include/rocksdb/env.h:43:12: error: no member named 'unique_ptr' in namespace 'std' using std::unique_ptr;



Followed by other errors due to this one and other missing stuff from std lib in c++11.

However, if i run the above clang command in the terminal it succeeds. 

I have tried this on a second mac and had exactly the same problem. I have been looking around for what the issue might be but come up blank. I realize this is not a issue with pyrocksdb itself but I hoped that someone might have had this problem, or something similar, and dealt with it already.

Thanks
gra-moore commented 9 years ago

Further googling and trying different options led me to try the following options in setup.py:

    '-std=c++0x',
    '-stdlib=libc++',
    '-mmacosx-version-min=10.10',

And now the build succeeds. But I would still like to know if this is a problem with this setup script when used with python3 or something with the way I am building it.

stephan-hof commented 9 years ago

I think it is not related to python3. I think it has to do with telling the compiler to use c++11 features. std::unique_ptr came with c++11 so you have to tell the compiler to allow c++11.

In g++ it is done by -std=c++11 or -std=gnu++11, pyrocksdb uses -std=gnu++11 which probably does not work under clang. Could you change setup.py like this and see if its working then:

diff --git a/setup.py b/setup.py
index be20354..eccd388 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ from Cython.Build import cythonize

 extension_defaults = {
     'extra_compile_args': [
-        '-std=gnu++11',
+        '-std=c++11',
         '-O3',
         '-Wall',
         '-Wextra',

If so that would be pretty nice, because then I could use the same flag for different compilers.

I have no MAC available. To make pyrocksdb running there I'm not a big help :( If somebody comes up with necessary changes in setup.py I'm happy to integrate them. As long as it does not break the linux build, so maybe we need something like sys.platform == ?

gra-moore commented 9 years ago

Did you see my comment above regarding what I found that worked?

I agree this is a clang c++ issue, but strange that I don't need to change the arguments when using python2.

gra-moore commented 9 years ago

I tried again with just c++11 as you suggested and that also seems works for me for python2 and python3.

stephan-hof commented 9 years ago

Cool that this simple change is working. I committed it here https://github.com/stephan-hof/pyrocksdb/commit/a670ec2aa1f136155d483cb8697f0613962e604a

schmidtc commented 8 years ago

The above fix didn't work for me (python2, osx 10.10). I had to add

'-stdlib=libc++',
'-mmacosx-version-min=10.10',

to setup.py as mentioned above by @gra-moore

However this issue didn't come up in my research, so I had to figure this out the hard way. Might be able to save some folks a lot of time if this was improved.

ceronman commented 8 years ago

Please re open this ticket.

I confirm the same issue with 10.10.5 and Python 3.5. The fix mentioned by @schmidtc worked for me. Thanks!