Build issue with clang on MSYS
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cmake, cpp
- Domain
- build-system, testing-qa
Research direction
Start by reproducing the Clang 18 build using the minimal test in tests/objects/gain.cpp. Inspect the generated CMake link command and Catch2 targets, especially the Catch2Main and Catch2 libraries shown in the failure. Done means the test_gain executable links and builds successfully with Clang as it does with GCC.
Written by the indexing model from the issue text.
Description
Describe the bug
When building on ubuntu with clang-18:
ld.lld: error: undefined symbol: Catch::ReusableStringStream::str() const
ld.lld: error: undefined symbol: Catch::formatReconstructedExpression(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, Catch::StringRef, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
ld.lld: error: undefined symbol: Catch::StringMaker<double, void>::convert(double)
CI failure: https://github.com/celtera/avendish/actions/runs/11863814439/job/33065997014?pr=42
Here are my complete build flags - I can see that Catch2 is correctly linked:
[ 97%] Building CXX object CMakeFiles/test_gain.dir/tests/objects/gain.cpp.o
/usr/bin/clang++-18 -DDEVELOPMENT -DFMT_HEADER_ONLY=1 -I/home/runner/work/avendish/avendish/build-debug -I/home/runner/work/avendish/avendish -I/home/runner/work/avendish/avendish/build-debug/_deps/qlibs_reflect-src -I/home/runner/work/avendish/avendish/score/3rdparty/vst3 -I/home/runner/work/avendish/avendish/include -I/home/runner/work/avendish/avendish/build-debug/_deps/fmt-src/include -I/home/runner/work/avendish/avendish/build-debug/_deps/magic_enum-src/include -I/home/runner/work/avendish/avendish/build-debug/_deps/catch2-src/src/catch2/.. -I/home/runner/work/avendish/avendish/build-debug/_deps/catch2-build/generated-includes -isystem /opt/ossia-sdk/boost/include -Wno-non-virtual-dtor -g -std=gnu++23 -fPIE -fvisibility=internal -fvisibility-inlines-hidden -fno-semantic-interposition -fPIC -stdlib=libc++ -fno-stack-protector -fno-ident -fno-plt -ffunction-sections -fdata-sections -MD -MT CMakeFiles/test_gain.dir/tests/objects/gain.cpp.o -MF CMakeFiles/test_gain.dir/tests/objects/gain.cpp.o.d -o CMakeFiles/test_gain.dir/tests/objects/gain.cpp.o -c /home/runner/work/avendish/avendish/tests/objects/gain.cpp
[ 97%] Linking CXX executable test_gain
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/test_gain.dir/link.txt --verbose=1
ld.lld: error: undefined symbol: Catch::ReusableStringStream::str() const
>>> referenced by gain.cpp:7 (/home/runner/work/avendish/avendish/tests/objects/gain.cpp:7)
>>> CMakeFiles/test_gain.dir/tests/objects/gain.cpp.o:(CATCH2_INTERNAL_TEST_0())
>>> referenced by gain.cpp:11 (/home/runner/work/avendish/avendish/tests/objects/gain.cpp:11)
>>> CMakeFiles/test_gain.dir/tests/objects/gain.cpp.o:(CATCH2_INTERNAL_TEST_0())
ld.lld: error: undefined symbol: Catch::formatReconstructedExpression(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, Catch::StringRef, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
>>> referenced by catch_decomposer.hpp:79 (_deps/catch2-src/src/catch2/../catch2/internal/catch_decomposer.hpp:79)
>>> CMakeFiles/test_gain.dir/tests/objects/gain.cpp.o:(Catch::BinaryExpr<double, double>::streamReconstructedExpression(std::__1::basic_ostream<char, std::__1::char_traits<char>>&) const)
ld.lld: error: undefined symbol: Catch::StringMaker<double, void>::convert(double)
>>> referenced by catch_tostring.hpp:150 (_deps/catch2-src/src/catch2/../catch2/catch_tostring.hpp:150)
>>> CMakeFiles/test_gain.dir/tests/objects/gain.cpp.o:(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> Catch::Detail::stringify<double>(double const&))
clang++-18: error: linker command failed with exit code 1 (use -v to see invocation)
/usr/bin/clang++-18 -Wno-non-virtual-dtor -g -fuse-ld=lld -Xlinker --dependency-file -Xlinker CMakeFiles/test_gain.dir/link.d CMakeFiles/test_gain.dir/tests/objects/gain.cpp.o -o test_gain _deps/fmt-build/libfmtd.a -Wl,--gc-sections -lc++ -Bsymbolic _deps/catch2-build/src/libCatch2Maind.a _deps/catch2-build/src/libCatch2d.a
gmake[2]: *** [CMakeFiles/test_gain.dir/build.make:104: test_gain] Error 1
And the very minimal test file causing the failure: https://github.com/celtera/avendish/blob/feature/catch2/tests/objects/gain.cpp
It works fine with gcc on the same platform.
Expected behavior
Build succeeds
Platform information:
- OS: Ubuntu 24.04 as provided by GH actions
- Compiler+version: Clang 18 as provided by apt.llvm.org
- Catch version: current HEAD
- Dominant language
- C++
- Stars
- 21.6k
- Forks
- 3.4k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from catchorg/Catch2
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 2 days
-
catch_discover_tests passes all EXTRA_ARGS as one argumentPossibly taken @CyberKun claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
catchorg/Catch2#3239 · 1 comment ·
Maintainers usually reply within 2 days
-
Not seeing some error messages from fakeit in jetbrains riderPossibly taken @Amanpal9 claimed this 21 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
catchorg/Catch2#3228 · 1 comment ·
Maintainers usually reply within 2 days
-
catch_discover_tests fails for Emscripten/WASM tests since v3.16.0Possibly taken @nafiurahman00 claimed this 8 days ago. OpenExtras
Difficulty 3/5 1-2 days Newbie friendliness 72/100
catchorg/Catch2#3241 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cp-algorithms/cp-algorithms#1774 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
telefonicaid/fiware-orion#4836 ·
Maintainers usually reply within 1 day
-
nixd exits at startup when its parent process belongs to another userPossibly taken @conao3 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nix-community/nixd#930 ·
Maintainers usually reply within 2 days
-
refactor topic-ui topic-weather
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Command-Install Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
microsoft/winget-cli#6718 ·
Maintainers usually reply within 2 days