Using Clang-18 as recommended by build instructions does not work on Ubuntu 22.04
When using clang-18 provided by llvm as recommended by the build instructions, both by following the exact instructions provided, as well as installing the rest of the clang family (clang-18 clang-tools-18 clang-18-doc libclang-common-18-dev libclang-18-dev libclang1-18 clang-format-18 python3-clang-18 clangd-18 clang-tidy-18) continuously failed with vcpkg failing to compile a demo program using -lstdc++.
Switching to the ppa that provides gcc-13 and g++-13 (ppa:ubuntu-toolchain-r/test) and installing both resolved the issue and I am now currently building ladybird to run.
If it's unable to find libstdc++, that probably means you were missing libstdc++-dev as a package. What distro are you on that that package is not included in build-essential ?
I am using KDE neon 6.0, and libstdc++-dev is a virtual package that is provided by version specific libstdc++-X-dev packages. Specific output of sudo apt install libstdc++-dev is below:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package libstdc++-dev is a virtual package provided by:
libstdc++-13-dev 13.1.0-8ubuntu1~22.04
libstdc++-9-dev 9.5.0-1ubuntu1~22.04
libstdc++-12-dev 12.3.0-1ubuntu1~22.04
libstdc++-10-dev 10.5.0-1ubuntu1~22.04
libstdc++-11-dev 11.4.0-1ubuntu1~22.04
You should explicitly select one to install.
E: Package 'libstdc++-dev' has no installation candidate
Sure, but build-essential should install the default g++ package, which will be a virtual package pointing to some version of g++, which will depend on that version of libstdc++-xx-dev. Which should(?) install an appropriate libstdc++.so.6 shared lib in the usual distro places.
So I guess I'm mostly confused why this didn't happen and you had to install g++ manually :shrug:
I had libstdc++-11-dev installed already, and it works as expected when using g++ to build other projects. The issue specifically rose with the building of Ladybird.
I have the same problem. I installed clang18 from the ppa in Ubuntu 22.04. Also, the program complains about an old cmake. And I highly doubt it will be satisfied with the old Qt 6.2.4. I tried in Mageia Cauldron (testing, like rolling) and the program complained about the old ICU. I understand that the latest libraries are required (not every rolling will fit), then what kind of support for Ubuntu 20.04 and 22.04 can we talk about? Maybe specify the minimum requirements of all dependent libraries, or at least what exactly works.
Most likely the old system libstdc++ is used. Using a new third-party clang18 does not always mean that a new libstdc++ will be used. It's clang18 with old libs.
I ran into this issue when building for the first time on Ubuntu 22.04. The original error message was:
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
This is mentioned in the build instructions, which suggests digging into the logs to find the actual error. In my case I tracked it down:
$ cat ~/projects/ladybird/Build/vcpkg/buildtrees/detect_compiler/config-x64-linux-dynamic-rel-err.log
...
[2/2] : && /usr/bin/clang++-18 -fPIC -Wl,-z,noseparate-code CMakeFiles/cmTC_23a44.dir/testCXXCompiler.cxx.o -o cmTC_23a44 && :
FAILED: cmTC_23a44
: && /usr/bin/clang++-18 -fPIC -Wl,-z,noseparate-code CMakeFiles/cmTC_23a44.dir/testCXXCompiler.cxx.o -o cmTC_23a44 && :
/usr/bin/ld: cannot find -lstdc++: No such file or directory
clang++-18: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Searching for that key phrase:
/usr/bin/ld: cannot find -lstdc++: No such file or directory
..led me to this StackOverflow post, which gives the solution.
sudo apt install libstdc++-12-dev
After that the build script continues successfully.
./Meta/ladybird.sh run
I ran into this issue when building for the first time on Ubuntu 22.04. The original error message was:
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.This is mentioned in the build instructions, which suggests digging into the logs to find the actual error. In my case I tracked it down:
$ cat ~/projects/ladybird/Build/vcpkg/buildtrees/detect_compiler/config-x64-linux-dynamic-rel-err.log ... [2/2] : && /usr/bin/clang++-18 -fPIC -Wl,-z,noseparate-code CMakeFiles/cmTC_23a44.dir/testCXXCompiler.cxx.o -o cmTC_23a44 && : FAILED: cmTC_23a44 : && /usr/bin/clang++-18 -fPIC -Wl,-z,noseparate-code CMakeFiles/cmTC_23a44.dir/testCXXCompiler.cxx.o -o cmTC_23a44 && : /usr/bin/ld: cannot find -lstdc++: No such file or directory clang++-18: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.Searching for that key phrase:
/usr/bin/ld: cannot find -lstdc++: No such file or directory..led me to this StackOverflow post, which gives the solution.
sudo apt install libstdc++-12-dev
After that the build script continues successfully.
./Meta/ladybird.sh run
Wanted to come here and say that this helped and fix my issue, i had "CMake Error: CMake was unable to find a build program corresponding to "Ninja"" error too and
This fixed it! "sudo apt install libstdc++-12-dev"
gonna assume that "sudo apt install libstdc++-14-dev" also works then
Much appreciated
Glad to hear that comment helped.
The cause of the issue, why the linker cannot find libstdc++, is explained in this answer:
https://stackoverflow.com/questions/74543715/usr-bin-ld-cannot-find-lstdc-no-such-file-or-directory-on-running-flutte#answer-77853925
To summarize their reasoning:
- Ubuntu 22.04 uses gcc-11-based toolchain, so that
/usr/bin/gccis a symlink to/usr/bin/gcc-11. - The system-wide shared library is
libstdc++.so.6compiled bygcc 12.3.0provided by thelibstdc++6package (which depends ongcc-12-base). - The default Clang is
clang-14, which depends onlibstdc++-11-dev. However, maybe because of the previous point, it is searching for shared libs in/usr/lib/gcc/x86_64-linux-gnu/12instead of11wheregcc-11compiles to. - Only
gcc-11(which is default on Ubuntu 22.04) passes/usr/lib/gcc/x86_64-linux-gnu/11/to linkerld, so that onlygcc-11will work. - Apparently, an alternative solution to installing
libstdc++-12-devis to create a symlinklibstdc++.soto/usr/lib/x86_64-linux-gnu/libstdc++.so.6under any of the paths searched byldlinker.
I thought I'd post the information here in case it might be useful.