willyd / caffe-builder

CMake build scripts to automate building the Caffe library and its dependencies.
BSD 2-Clause "Simplified" License
186 stars 116 forks source link

Installing leveldb failed #12

Open davidshen84 opened 9 years ago

davidshen84 commented 9 years ago

I know it is not your fault. When I execute

pip install -r requirements.txt

in the python directory, I got error that leveldb failed to install. But I saw in the ./install/bin directory that I have:

So, maybe I do not need to use pip to install leveldb again? Care to comment on this?

willyd commented 9 years ago

Depends on what you want. LevelDB python bindings are not installed by caffe-builder. The exe you mention are there because caffe requires leveldb c++ and pycaffe requires both leveldb c++ and pyleveldb. Please see https://github.com/BVLC/caffe/issues/15 and/or ask @lunzueta or @happynear for help on getting pyleveldb installed.

davidshen84 commented 9 years ago

Building leveldb.lib is easy, as there are many resources. However, I could not find any reference on building the python binding.

On Tue, Sep 15, 2015 at 11:36 PM Guillaume Dumont notifications@github.com wrote:

Depends on what you want. LevelDB python bindings are not installed by caffe-builder. The exe you mention are there because caffe requires leveldb c++ and pycaffe requires both leveldb c++ and pyleveldb. Please see BVLC/caffe#15 https://github.com/BVLC/caffe/issues/15 and/or ask @lunzueta https://github.com/lunzueta or @happynear https://github.com/happynear for help on getting pyleveldb installed.

— Reply to this email directly or view it on GitHub https://github.com/willyd/caffe-builder/issues/12#issuecomment-140434630 .

Regards, David

happynear commented 9 years ago

@davidshen84 I guess you can read Mandarin from your name. Here is a blog describes how to build leveldb.pyd: http://blog.csdn.net/toontong/article/details/8442995

If you cannot read it. Try this repository: https://github.com/chirino/leveldb/blob/master/WINDOWS.md

davidshen84 commented 9 years ago

@happynear I have build leveldb from @chirino 's repository, and got the lib files. The code snippet in that blog seems very old. I will try if it still applies. Thanks.

davidshen84 commented 9 years ago

My working environment is Windows 8 64 bit, VS 2012, leveldb 0.193. I added these lines to the setup.py file in leveldb:

else:
  #print >>sys.stderr, "Don't know how to compile leveldb for %s!" % system
  #sys.exit(0)
  extra_compile_args = common_flags + [
      '-fPIC',
      '-Wall',
      '-g2',
      '-D_GNU_SOURCE',
      '-O2',
      '-DNDEBUG',
      '-DLEVELDB_PLATFORM_WINDOWS',
      ]
  extra_link_args = ['shlwapi.lib', 'snappy.lib','leveldb.lib',]

And made some other changed by following the blog. The error message I got was:

running build
running build_ext
building 'leveldb' extension
error: [Error 2] ???????????

The ? are literal...so I have no idea what it is.

happynear commented 9 years ago

@davidshen84 I have just created a new repository https://github.com/happynear/py-leveldb-windows . Sorry that I am not familiar with cmake, so I just created a VS project. May it help.

davidshen84 commented 9 years ago

Indeed it helps. Thanks a lot!

On Wed, Sep 16, 2015 at 5:26 PM Feng Wang notifications@github.com wrote:

@davidshen84 https://github.com/davidshen84 I have just created a new repository https://github.com/happynear/py-leveldb-windows . Sorry that I am not familiar with cmake, so I just created a VS project. May it help.

— Reply to this email directly or view it on GitHub https://github.com/willyd/caffe-builder/issues/12#issuecomment-140684290 .

Regards, David

vfdev-5 commented 9 years ago

A CMake version to compile python leveldb wrapper under Windows using Caffe-builder dependencies: https://github.com/vfdev-5/py-leveldb-windows

happynear commented 9 years ago

@vfdev-5 Thanks for your work.

willyd commented 9 years ago

@vfdev-5 Thanks. I might consider integrating this in caffe-builder at some point.

davidshen84 commented 8 years ago

@willyd I am trying to integrate @vfdev-5 's work into caffe-builder, but I am stuck at setting the build type. LevelDB python build need to link with python library files. But I don't have the debug version of the python.lib file, and I think most people will not have it either. So only the Release could success.

Now I could not find a way to pass some arguments to your buildem_cmake_recipe macro to only build Release build for this project.

Please kindly advice.

Thanks, David

vfdev-5 commented 8 years ago

If you modify the file cmake/packages/leveldb.cmake

set(leveldb_CMAKE_ARGS 
    -DBUILD_SHARED_LIBS=OFF
    -DCMAKE_DEBUG_POSTFIX=d

    -DCMAKE_BUILD_TYPE=Release

    -DBoost_USE_STATIC_LIBS=ON
    -DBoost_USE_MULTITHREAD=ON
    -DBoost_USE_STATIC_RUNTIME=OFF   
    )

it does not work ?

davidshen84 commented 8 years ago

@vfdev-5 MSVC does not accept build type in configuration, it has to be specified at build type. So I guess it won't work.

But I saw you were using nmake. Maybe it works with nmake. But I will have to find a way to let nmake build in 32/64 bit mode.

vfdev-5 commented 8 years ago

The way to choose 32 or 64 bit mode can be defined, for example, with vcvarsall.bat (https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx). Somewhere in Visual Studio folder you, probably, have a folder with .bat files which define an environment to compile in a chosen mode. E.g C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat Hope it helps

On Mon, Dec 28, 2015 at 1:32 PM, Xi Shen notifications@github.com wrote:

@vfdev-5 https://github.com/vfdev-5 MSVC does not accept build type in configuration, it has to be specified at build type. So I guess it won't work.

But I saw you were using nmake. Maybe it works with nmake. But I will have to find a way to let nmake build in 32/64 bit mode.

— Reply to this email directly or view it on GitHub https://github.com/willyd/caffe-builder/issues/12#issuecomment-167562113 .

davidshen84 commented 8 years ago

But I prefer not to relay on the .bat file. I want to integrate the py-leveldb into the caffe-builder.

On Mon, Dec 28, 2015 at 10:15 PM vfdev notifications@github.com wrote:

The way to choose 32 or 64 bit mode can be defined, for example, with vcvarsall.bat (https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx). Somewhere in Visual Studio folder you, probably, have a folder with .bat files which define an environment to compile in a chosen mode. E.g C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat Hope it helps

On Mon, Dec 28, 2015 at 1:32 PM, Xi Shen notifications@github.com wrote:

@vfdev-5 https://github.com/vfdev-5 MSVC does not accept build type in configuration, it has to be specified at build type. So I guess it won't work.

But I saw you were using nmake. Maybe it works with nmake. But I will have to find a way to let nmake build in 32/64 bit mode.

— Reply to this email directly or view it on GitHub < https://github.com/willyd/caffe-builder/issues/12#issuecomment-167562113> .

— Reply to this email directly or view it on GitHub https://github.com/willyd/caffe-builder/issues/12#issuecomment-167578495 .

Regards, David

davidshen84 commented 8 years ago

@vfdev-5 do you know why we want to enforce build a Debug version? I am trying to find a way to only build a Release version for my pyleveldb project, without changing https://github.com/willyd/caffe-builder/blob/master/cmake/buildem_cmake_recipe.cmake#L36.

willyd commented 8 years ago

Hi @davidshen84 why not add an option like this:

option(BUILD_DEBUG_AND_RELEASE "Build debug and release simultaneously" ON)
    if(MSVC AND BUILD_DEBUG_AND_RELEASE)        

        externalproject_add_step(${_name} BuildOtherConfig
                            COMMAND ${CMAKE_COMMAND} --build ${BINARY_DIR} --config "$<$<CONFIG:Debug>:Release>$<$<CONFIG:Release>:Debug>" --target INSTALL
                            DEPENDEES install
                            )
    endif()

and then you can disable this option on the command-line how does that sound?

davidshen84 commented 8 years ago

Hi @guillaume,

I see. I will try that out.

Thanks, David

On Mon, Jan 4, 2016 at 11:32 PM Guillaume Dumont notifications@github.com wrote:

Hi @davidshen84 https://github.com/davidshen84 why not add an option like this:

option(BUILD_DEBUG_AND_RELEASE "Build debug and release simultaneously" ON) if(MSVC AND BUILD_DEBUG_AND_RELEASE)

    externalproject_add_step(${_name} BuildOtherConfig
                        COMMAND ${CMAKE_COMMAND} --build ${BINARY_DIR} --config "$<$<CONFIG:Debug>:Release>$<$<CONFIG:Release>:Debug>" --target INSTALL
                        DEPENDEES install
                        )
endif()

and then you can disable this option on the command-line how does that sound?

— Reply to this email directly or view it on GitHub https://github.com/willyd/caffe-builder/issues/12#issuecomment-168707526 .

Regards, David