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

How to set BOOST_LIBRARYDIR or BOOST_ROOT? #123

Closed
vonnenaut opened this issue May 9, 2017 · 17 comments
Closed

How to set BOOST_LIBRARYDIR or BOOST_ROOT? #123

vonnenaut opened this issue May 9, 2017 · 17 comments
Labels

Comments

@vonnenaut
Copy link

Hi. I'm getting the following error messages in CMake GUI in Windows 10, when pressing configure. I'd much prefer to use cmake in Cygwin, but that's not working either so at this point anything that works would be great since I just want to learn C++ but can't currently run the tests, unfortunately.

The error message states:
"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."

How do I set BOOST_LIBRARYDIR or BOOST_ROOT?

CMake GUI error:

`CMake Error at C:/Program Files/CMake/share/cmake-3.8/Modules/FindBoost.cmake:1842 (message):
Unable to find the requested Boost libraries.

Boost version: 1.63.0

Boost include path: C:/Program Files/boost/boost_1_63_0

Could not find the following static Boost libraries:

      boost_unit_test_framework
      boost_date_time
      boost_regex

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.
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)

CMake Warning (dev) at CMakeLists.txt:17 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

Quoted variables like "MSVC" will no longer be dereferenced when the policy
is set to NEW. Since the policy is not set the OLD behavior will be used.
This warning is for project developers. Use -Wno-dev to suppress it.

Configuring incomplete, errors occurred!
See also "C:/Program Files/CMake/bin/CMakeFiles/CMakeOutput.log".`

Cygwin error:

$ cmake -G "Unix Makefiles" .. CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred!

And so, additionally, how do I set CMAKE_MAKE_PROGRAM and CMAKE_CXX_COMPILER?

Any help is much appreciated, thanks!

@arcuru
Copy link
Contributor

arcuru commented May 10, 2017

The absolute easiest way to use this on Windows 10 right now is to use the 'Windows Subsystem for Linux'. With the latest Win10 that will give you an install of Ubuntu 16.04, which will work just fine. The only issue you'd hit is if you tried to edit the files using Notepad++ or something, in which case you would need to deal with line-ending issues.

I haven't used Cygwin, so I'm not sure what issue that might be (I'd guess that either you don't have a compiler/make installed or it just didn't set the right environment variables for them. You could fix the latter issue by specifying them when you call cmake, eg cmake -DCMAKE_MAKE_PROGRAM=make, or something like that).

Unfortunately I haven't set this up on Windows for a while but I'll try to give you some pointers that may help (I don't have time soon, but it does look like people hit several issues with the current setup). As far as I recall, specifying the Boost include directory for cmake was enough to set it up correctly. You also need to make sure the Boost version and MS compiler version that you have match up. VS2017 I don't think is supported yet, so you'll probably need the C++ compiler from 2015 (which you can install from the VS2017 installer).

If you have all of that and it's still giving you errors, just go specify the BOOST_LIBRARYDIR variable like any other cmake variable. I assume you can just do it in the gui, but you could also do it on the command line with like so: cmake -DBOOST_LIBRARYDIR:PATH=D:/tmp/boost_1_63_0

@vonnenaut
Copy link
Author

vonnenaut commented May 11, 2017

Ok, I already have Windows Subsystem for Linux installed. I'm not using notepad++ but Sublime and sometimes VS 2017, though I also have VS 2015. I tried the flag you suggested to specify boost library location in cli but it tries to append that path to the current directory and so doesn't find it. The cmake log file from trying to configure via the gui shows no errors. But I'm still getting the red text in the gui output window saying boost libraries can't be found. There is no way in the gui to specify this so I am stuck at a standstill on this.

Here's what I got from running cmake -DBOOST_DEBUG=ON ..
capture

That boost include path is valid, though it doesn't point directly to a directory containing what it's looking for. Only Boost v 1.61 has those files. They're missing in 1.63 and 1.64, but I'm not sure how to specify which version of boost to use.

@jvillasante
Copy link

Yes, just wanted to have fun. It's a pain to configure boost!
Why not ditch all dependencies?
Moving on to HackerRank!

@arcuru
Copy link
Contributor

arcuru commented Sep 3, 2017

@jvillasante It would take a large amount of effort to remove the Boost dependency for very little benefit. Unfortunately there just isn't an extremely simple way to run C++ locally on Windows.

Right now, to run the problem on Windows in Visual Studio, all that's required (outside of configuring the exercism-cli) is:

  1. Install Boost, CMake, and Visual Studio.
  2. Rename a folder (boost\lib32-msvc-14.1 -> boost\lib)
  3. Run a couple commands (that we give you) on the command line for each problem.
  4. Open a file in Visual Studio.

I re-tested that flow today with the latest version of everything (OS, VS, Boost, CMake), and it all worked fine. Issues notwithstanding, removing the Boost dependency would only remove the need to install Boost itself and rename a folder.

@ScottHutchinson
Copy link

ScottHutchinson commented Jan 26, 2018

I followed the steps above, but am still getting a cmake warning: New Boost version may have incorrect or missing dependencies... Maybe cmake or the exercism unit tests are not compatible with the latest version of Boost (1.66.0).

C:\Users\scott\exercism\cpp\sum-of-multiples\build>cmake -G "Visual Studio 15" -BOOST_ROOT:PATH=C:/Users/scott/Programs/boost_1_66_0 -BOOST_INCLUDEDIR:PATH=C:/Users/scott/Programs/boost_1_66_0/boost -BOOST_LIBRARYDIR:PATH=C:/Users/scott/Programs/boost_1_66_0/lib ..
CMake Warning at C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:801 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1542 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:14 (find_package)

CMake Warning at C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:801 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1542 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:14 (find_package)

CMake Warning at C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:801 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1542 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:14 (find_package)

CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1928 (message):
Unable to find the requested Boost libraries.

Boost version: 1.66.0

Boost include path: C:/Users/scott/Programs/boost_1_66_0

Could not find the following static Boost libraries:

      boost_unit_test_framework
      boost_date_time
      boost_regex

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.
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)

CMake Warning (dev) at CMakeLists.txt:17 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

Quoted variables like "MSVC" will no longer be dereferenced when the policy
is set to NEW. Since the policy is not set the OLD behavior will be used.
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!
See also "C:/Users/scott/exercism/cpp/sum-of-multiples/build/CMakeFiles/CMakeOutput.log".

C:\Users\scott\exercism\cpp\sum-of-multiples\build>pause
Press any key to continue . . .

@ScottHutchinson
Copy link

After installing Boost 1.59.0 instead of 1.66.0, I get completely different output, but still not test results in the command prompt window:

C:\Users\scott\exercism\cpp\sum-of-multiples>cd build

C:\Users\scott\exercism\cpp\sum-of-multiples\build>cmake -G "Visual Studio 15" -DBOOST_ROOT:PATH=C:/local/boost_1_59_0 -DBOOST_INCLUDEDIR:PATH=C:/local/boost_1_59_0/boost -DBOOST_LIBRARYDIR:PATH=C:/local/boost_1_59_0/lib ..
-- Boost version: 1.59.0
-- Found the following Boost libraries:
-- unit_test_framework
-- date_time
-- regex
CMake Warning (dev) at CMakeLists.txt:17 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

Quoted variables like "MSVC" will no longer be dereferenced when the policy
is set to NEW. Since the policy is not set the OLD behavior will be used.
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done
CMake Warning (dev) in CMakeLists.txt:
Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_ properties.
Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: C:/Users/scott/exercism/cpp/sum-of-multiples/build

C:\Users\scott\exercism\cpp\sum-of-multiples\build>pause
Press any key to continue . . .

@ScottHutchinson
Copy link

ScottHutchinson commented Jan 26, 2018

Visual Studio 2017 builds "..\exercism\cpp\sum-of-multiples\build\Debug\sum-of-multiples.exe" with 0 errors and 0 warnings. But running that executable seems to do nothing. I created a test.bat file as shown below, and then I finally got test results. The instructions got me nowhere near getting test results. Then I intentionally changed my function to return an incorrect result, and viola, I see I get an error message in the Output window: Severity Code Description Project File Line Suppression State
Error in "sum_to_1_yields_0": critical check 0 == sumOfMultiples({3, 5}, 0) has failed [0 != 42] sum-of-multiples C:\Users\scott\exercism\cpp\sum-of-multiples\sum_of_multiples_test.cpp 7

call "C:\Users\scott\exercism\cpp\sum-of-multiples\build\Debug\sum-of-multiples.exe"
pause

This took me like 3 hours to get this far. I have nearly two years experience with C++ development. It should not be this hard to use Boost Test. And at this point, I still can't make cmake work, but fortunately VS 2017 works. Why is cmake a prerequisite for Windows, if Visual Studio builds and tests without it?? By the way, I love the experience of learning F# on exercism.io; but my initial impression with C++ is just awful, even though I usually enjoy programming in C++.

@lobotomiac
Copy link

Ok I'll just say that at first I renamed the subfolder to lib, and it didn't work.
I restarted the PC and it still didn't work, so I renamed the folder to a random name, restarted and renamed it to lib again and it worked all of a sudden! so stupid that I have to let everyone know!

@Patafikss
Copy link

Patafikss commented Aug 2, 2018

@lobotomiac

I renamed the subfolder to lib

Which subfolder ? /libs ?

@ScottHutchinson
Copy link

@Patafikss He is probably referring to step 2 in #123 (comment)

  1. Rename a folder (boost\lib32-msvc-14.1 -> boost\lib)

@lobotomiac
Copy link

lobotomiac commented Aug 2, 2018

@Patafikss He is probably referring to step 2 in #123 (comment)

Rename a folder (boost\lib32-msvc-14.1 -> boost\lib)

@ScottHutchinson is correct I apologize for not making it clear, but yes that's it.

@cgorshing
Copy link

I've added a comment to #190 (comment), the short of it is if you are on Windows (using Visual Studio), then you need to make sure you are using the correct CMake generator for the architecture version of Boost you downloaded. See the prior link for info.

@Faq
Copy link

Faq commented Aug 12, 2018

Had the same boost warning, but that was because it was just 32bit, got 64bit boost from https://sourceforge.net/projects/boost/files/boost-binaries/

@arcuru arcuru added the boost label Aug 24, 2018
@FirefoxMetzger
Copy link

How do I set BOOST_LIBRARYDIR or BOOST_ROOT?

On Win10 this can be done as environment variables.

  1. windows Key > search: "Edit the system environment Variables" [should open System Properties]
  2. Click Environment Variables ... [opens a new window called Environment Variables]
  3. In the panel "User variables for " select: New...

Here you can create two variables. One called BOOST_ROOT pointing to the directory that contains the "boost" folder, e.g., C:\Program Files\boost\boost_1_68_0 and another called BOOST_LIBRARYDIR pointing to the location of the compiled boost libraries, e.g., C:\Program Files\boost\boost_1_68_0\stage_x64.

Note that BOOST_LIBRARYDIR may vary depending on how you have build / obtained boost. If you build it from source the easiest way is to specify --stagedir=stage_x64, or w/e naming convention makes sense for you, when calling .\b2.

You want to restart any console afterwards to make them pick up the changes to environment variables. You can verify via echo $Env:BOOST_ROOT and echo $Env:BOOST_LIBRARYDIR.

If CMake is up to date, it should pick up these environment variables as hints when searching for boost.
You may also have to set

cmake_policy(SET CMP0074 NEW)

somewhere at the top of the project's CMakeLists.txt, to explicitly allow the use of environment variables as hints.

Hope this helps.

@arcuru
Copy link
Contributor

arcuru commented Apr 20, 2019

We removed the dependency on Boost, see #233. The setup here is no longer necessary. Closing.

@arcuru arcuru closed this as completed Apr 20, 2019
@chris1248
Copy link

Cmake and boost combined is a disaster.

@asheesh1202
Copy link

check with -DBOOST_DEBUG=ON, this will tell you names of the libraries it is looking for. For me due to differences in versions of cmake and boost, it could no recognize the required libraries.

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

Successfully merging a pull request may close this issue.