catchorg / catchorg/Catch2

Build issue with clang on MSYS

Open
#2,937 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

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>&, std::__1::basic_string, std::__1::allocator> const&, Catch::StringRef, std::__1::basic_string, std::__1::allocator> const&)

ld.lld: error: undefined symbol: Catch::StringMaker::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>&, std::__1::basic_string, std::__1::allocator> const&, Catch::StringRef, std::__1::basic_string, std::__1::allocator> 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::streamReconstructedExpression(std::__1::basic_ostream>&) const)

ld.lld: error: undefined symbol: Catch::StringMaker::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, std::__1::allocator> Catch::Detail::stringify(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**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.