ladybird icon indicating copy to clipboard operation
ladybird copied to clipboard

Using Clang-18 as recommended by build instructions does not work on Ubuntu 22.04

Open AlekEagle opened this issue 1 year ago • 6 comments

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.

AlekEagle avatar Jul 08 '24 17:07 AlekEagle

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 ?

ADKaster avatar Jul 08 '24 17:07 ADKaster

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

AlekEagle avatar Jul 08 '24 17:07 AlekEagle

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:

ADKaster avatar Jul 08 '24 17:07 ADKaster

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.

AlekEagle avatar Jul 08 '24 17:07 AlekEagle

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.

artenax avatar Jul 10 '24 09:07 artenax

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

eliot-akira avatar May 24 '25 02:05 eliot-akira

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

OMGhixD-OG avatar Jun 07 '25 11:06 OMGhixD-OG

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/gcc is a symlink to /usr/bin/gcc-11.
  • The system-wide shared library is libstdc++.so.6 compiled by gcc 12.3.0 provided by the libstdc++6 package (which depends on gcc-12-base).
  • The default Clang is clang-14, which depends on libstdc++-11-dev. However, maybe because of the previous point, it is searching for shared libs in /usr/lib/gcc/x86_64-linux-gnu/12 instead of 11 where gcc-11 compiles to.
  • Only gcc-11 (which is default on Ubuntu 22.04) passes /usr/lib/gcc/x86_64-linux-gnu/11/ to linker ld, so that only gcc-11 will work.
  • Apparently, an alternative solution to installing libstdc++-12-dev is to create a symlink libstdc++.so to /usr/lib/x86_64-linux-gnu/libstdc++.so.6 under any of the paths searched by ld linker.

I thought I'd post the information here in case it might be useful.

eliot-akira avatar Jun 07 '25 14:06 eliot-akira