You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Reacted by Dimitri Belopopsky, Bhavya Maheshwari and Mike Walker
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. :)
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.
Activity
arcuru commentedon Apr 16, 2017
Thanks, this looks like a good issue to link to from the docs :)
mikewalker commentedon Jul 1, 2018
I was having this exact same issue on Fedora 28, thanks for this at least I can generate the make file now. :)
mikewalker commentedon Jul 27, 2018
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 commentedon 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.