4
votes

I'm trying to build Bytecoin source on Windows and I'm running into issues with CMake and Boost libraries. First I tried grabbing the Boost 1.55 and compiling it myself. One or two of the libs near the end did not compile for some reason but I thought that CMake would at least identify the compiled libraries. Instead, I get this error when trying to load the CMake project:

Error:Unable to find the requested Boost libraries. Boost version: 1.55.0 Boost include path: C:/Program Files/boost/boost_1_55_0 Could not find the following Boost libraries: boost_system boost_filesystem boost_thread boost_date_time boost_chrono boost_regex
boost_serialization boost_program_options No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.

Then I tried adding a HINT to the find_package(). It tried to parse a weird path, not sure where it's doing this:

CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/FindBoost.cmake:273 (if): Syntax error in cmake code at

C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/FindBoost.cmake:273

when parsing string

${Boost_C:/PROGRAM FILES/BOOST/BOOST_1_55_0_LIBRARY_RELEASE}

Reading some of the SO answers on the matter I added environment variables:

C:\Users\Misha>set

BOOST_INCLUDEDIR=C:\local\boost_1_55_0 BOOST_LIBRARYDIR=C:\local\boost_1_55_0\lib32-msvc-12.0 BOOST_ROOT=C:\local\boost_1_55_0\boost

At this point I tried using the precompiled libs, nothing.

CMkeLists.txt

find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options)
#find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options HINT "C:/Program Files/boost/boost_1_55_0")
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
if (MINGW)
    set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock")
elseif (APPLE)
    set(Boost_LIBRARIES "${Boost_LIBRARIES}")
elseif (NOT MSVC)
    set(Boost_LIBRARIES "${Boost_LIBRARIES};rt")
endif ()

I'm not familiar with CMake, so it is likely a simple fix. I just can't see it.

1
Insert set(Boost_DEBUG on) before find_package() and rerun cmake. In debug mode all searched libraries will be shown. Check that all these libraries exist under the directory you assign to variable BOOST_LIBRARYDIR. HINT option is unrelated to your problem, as it is used for Config mode of find_package, but you use Module mode (FindBoost.cmake).Tsyvarev
@Tsyvarev It looks like boost_serialization is causing problems at least Could not find the following static Boost libraries: boost_serializationMisha Prasolov
@Tsyvarev It appears to be in the directory, so I'm not quite sure why it isn't foundMisha Prasolov
It should be line Searching for <component>_LIBRARY_RELEASE: , where precise filenames are given (component is one which you specify in find_package()).Tsyvarev
The error that mentions BOOST_1_55_0_LIBRARY_RELEASE makes me think that cmake is somehow treating 1.55 as a boost library, as if it were part of the COMPONENTS list. I don't think you're doing anything wrong, but maybe try removing the 1.55 argument from find_package()Stuart Berg

1 Answers

2
votes

I was facing the same error, but resolved it. My BOOST Library was build using Gcc 6.3 on windows 7 (64 Bit).

I set Boost_DEBUG on in CMakeLists.txt and found

-- [ C:/Program Files/CMake/share/cmake-3.9/Modules/FindBoost.cmake:1620 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-mgw63-mt-1_67;libboost_system-mgw63-mt;libboost_system-mt-1_67;libboost_system-mt;libboost_system

That means FindPackage(Boost) is searching for libboost_system-mgw63-mt-1_67 but my library name was libboost_system-mgw63-mt-x64-1_67.

So I removed X64 from all libray names and now it is working properly.