Skip to content

Boost unit tests on Fedora #116

Closed
Closed

Description

@vlisivka

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.

Activity

  1. arcuru commented on Apr 16, 2017

    @arcuru
    Contributor

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

  2. mikewalker commented on Jul 1, 2018

    @mikewalker

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

  3. mikewalker commented on Jul 27, 2018

    @mikewalker

    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. :)

  4. arcuru commented on Apr 20, 2019

    @arcuru
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions