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

caffe-builder finds already installed boost version #5

Open
willyd opened this issue Aug 12, 2015 · 5 comments
Open

caffe-builder finds already installed boost version #5

willyd opened this issue Aug 12, 2015 · 5 comments
Labels

Comments

@willyd
Copy link
Owner

willyd commented Aug 12, 2015

As reported in Caffe #15 by @lunzueta.

@willyd I've tested your Caffe version, but I'm getting a couple of build failures that I don't know how to fix. The first one is related to the VS project "leveldb". The compiler tells me:

2> Boost include path: (MY_PATH)/boost_1_56_0
2>

2> Could not find the following static Boost libraries:
2>

2> boost_date_time
2> boost_filesystem
2> boost_system
2>

2> No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
2> directory containing Boost libraries or BOOST_ROOT to the location of
2> Boost.

The strange thing is that as far as I understand from your CMake builder, it's downloading Boost (version 1_58_0) to the folder "(MY_BUILD_PATH)\install\lib", which I guess should be used, but then it's not pointing at it. Nevertheless, those specific Boost libraries that the compiler is looking for aren't downloaded, but others which begin with "libboost_" instead of "boost_". I already had another version of Boost installed (version 1_56_0 mentioned by the compiler) and it seems the compiler is pointing at it, which I don't understand how, as I can't see any reference to it at the "leveldb" VS project preferences (not sure if this is something related to how CMake generates the VS project).

The other failure I get is related to the "OpenCV" VS project. As I'd like to use OpenCV 3.0 (instead of the included v2.4.10) I changed the download path in your OpenCV.cmake file. Then, when compiling I get the following error (which I don't get when compiling OpenCV 3.0 out of this Caffe version):

3>LINK : fatal error LNK1104: cannot open file 'python27_d.lib' [(MY_BUILD_PATH)\OpenCV-prefix\src\OpenCV-build\modules\python2\opencv_python2.vcxproj]

Strangely, this linking error also happens when compiling in "Release" mode (where I guess python27_d.lib shouldn't be linked at all).

Any hint of what to do to fix this?

@willyd
Copy link
Owner Author

willyd commented Aug 12, 2015

The strange thing is that as far as I understand from your CMake builder, it's downloading Boost (version 1_58_0) to the folder "(MY_BUILD_PATH)\install\lib", which I guess should be used, but then it's not pointing at it. Nevertheless, those specific Boost libraries that the compiler is looking for aren't downloaded, but others which begin with "libboost_" instead of "boost_". I already had another version of Boost installed (version 1_56_0 mentioned by the compiler) and it seems the compiler is pointing at it, which I don't understand how, as I can't see any reference to it at the "leveldb" VS project preferences (not sure if this is something related to how CMake generates the VS project).

You are right that caffe-builder downloads boost and builds boost. Boost prefixes the static library names with lib. caffe-builder relies on CMake find_package to find Boost (and only looks for the static variant). Your install of boost probably only has the dynamic variants so BOOST_INCLUDE_DIR is correctly found but no libraries are found. I forgot to configure LevelDB so that it finds the caffe-builder built Boost. Please try the following change:

set(leveldb_CMAKE_ARGS 
    -DBUILD_SHARED_LIBS=OFF
    -DCMAKE_DEBUG_POSTFIX=d
   ####################################################
    # add this line
    -DBOOST_ROOT=${CMAKE_INSTALL_PREFIX}
   # or add those two
    -DBOOST_LIBRARYDIR=${CMAKE_INSTALL_PREFIX}/lib
    -DBOOST_INCLUDEDIR=${CMAKE_INSTALL_PREFIX}/include
  ###################################################
    -DBoost_USE_STATIC_LIBS=ON
    -DBoost_USE_MULTITHREAD=ON
    -DBoost_USE_STATIC_RUNTIME=OFF   
    )

Apply the same change to every project that has a dependency on Boost. For OpenCV 3.x support please use this branch opencv3-support as reported in #1.

@lunzueta
Copy link

Thanks @willyd. With your changes and suggestions now I can compile the "leveldb" project correctly, both in Debug and Release. However, this time I'm getting other two errors; one linking error in the "Caffe" project with "python27.lib" (both in Debug and Release), and a CMake error in the "OpenCV" project which appears when compiling (only in Release, not in Debug):

2> CMake Error at cmake/OpenCVDetectPython.cmake:78 (if):
2> if given arguments:
2>
2> "NOT" "optimized" "C:/Anaconda/libs/python27.lib" "debug" "C:/Anaconda/libs/python27_d.lib" "EQUAL" ""
2>
2> Unknown arguments specified
2> Call Stack (most recent call first):
2> cmake/OpenCVDetectPython.cmake:219 (find_python)
2> CMakeLists.txt:551 (include)
2>
2>
2> -- Configuring incomplete, errors occurred!

As you can see both are related to Python. I already had Python libraries installed from Anaconda (http://continuum.io/downloads), but as before, I'm not sure how to make your CMake files find it and link those projects to it. Any suggestion, please?

@willyd
Copy link
Owner Author

willyd commented Aug 12, 2015

AFAIK Anaconda does not come with the python debug library. Did you mess with your python install by copying the release lib and renaming it to python27_d.lib?

I also have anaconda and do not have any of the problems you reported.

@lunzueta
Copy link

@willyd

Yes, you're right. I tried that "trick", but without success, so it wasn't a good idea. Just in case, I've removed that file again and I've restarted the whole process, but again without success. Then, I've checked what was being done at line 78 of OpenCVDetectPython.cmake (as pointed by the compiler&CMake) and it seems that it was checking if I had an environment variable with the path to the libraries of Python (which I didn't have), so I've added the environment variable PYTHONHOME (mentioned here: https://docs.python.org/2/using/cmdline.html#envvar-PYTHONHOME) with the value "C:\Anaconda", and now I've been able to compile everything correctly both in Debug and Release :-D

Many thanks for this great Windows version of Caffe and for your assistance @willyd!

Just to comment, I've tested all this using Visual Studio 2013 with a 64-bit build in Windows 10.

@willyd
Copy link
Owner Author

willyd commented Aug 13, 2015

@lunzueta Great! Good to hear that you succeeded.

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

No branches or pull requests

2 participants