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

Boost unit tests on Fedora #116

Closed
vlisivka opened this issue Apr 4, 2017 · 4 comments
Closed

Boost unit tests on Fedora #116

vlisivka opened this issue Apr 4, 2017 · 4 comments

Comments

@vlisivka
Copy link

vlisivka commented Apr 4, 2017

I had problems with Boost on Fedora and these exercises: by default, boost libraries are installed as shared libraries, because of Fedora policy, so static linking is not working. I wrote small script to fix annoying problems with exercises:

#!/bin/bash
set -ue
project="${1:?ERROR: Name of directory with exercism CPP project code is required.}"

project_name="${project//-/_}"

cd "$project"

# Create empty .cpp and .h files
touch "$project_name."{cpp,h}

# Turn off static (.a) linking for boost libraries, because only dynamic (.so) libraries are available
sed -i 's/set(Boost_USE_STATIC_LIBS ON)/set(Boost_USE_STATIC_LIBS OFF)/' CMakeLists.txt

# Add def BOOST_TEST_DYN_LINK to *_test.cpp, to generate main()
fgrep -q '#define BOOST_TEST_DYN_LINK' "${project_name}_test.cpp" || {
  sed -i '/#define BOOST_TEST_MAIN/ a#define BOOST_TEST_DYN_LINK' "${project_name}_test.cpp"
}

# Enable all test cases and generate Makefile
cmake -DEXERCISM_RUN_ALL_TESTS=yes .

# Build project
make

IMHO, this script can be recommended in section about setup of C++ exercises on (Fedora) Linux.

@arcuru
Copy link
Contributor

arcuru commented Apr 16, 2017

Thanks, this looks like a good issue to link to from the docs :)

@mikewalker
Copy link

I was having this exact same issue on Fedora 28, thanks for this at least I can generate the make file now. :)

@mikewalker
Copy link

Just found another solution / workaround for this. The script does work by turning off static libs in the CMakeLists.txt but there is an alternative. I just installed boost-static via

sudo dnf install boost-static.x86_64

After installing this package you no longer have to disable static via the script posted above. It might be worth mentioning in the docs somewhere if its not already. Just wanted to post this to help anyone else running fedora that runs into the same problem. :)

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

arcuru commented Apr 20, 2019

Thanks for this. We've removed Boost because of the difficulty in supporting different platforms with these kinds of issues, see #233. Closing this as it should no longer affect the track.

@arcuru arcuru closed this as completed Apr 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants