Clang++ cannot compile a C++ program after do-release-upgrade to Jammy
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
clang (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Hi Everyone.
I was running Ubuntu 20.04/Focal x86_64, fully patched. g++ and clang++ were installed and worked as expected. I ran do-release-upgrade to move to Ubuntu 22.04/Jammy. After Jammy g++ works but clang++ does not.
I performed a 'apt-get remove --purge clang*' followed by 'apt-get install clang'. No joy.
I manually installed libc++-abi and then libclang-cpp-dev. Still no joy.
Something is sideways with Clang on Ubuntu 22.04/Jammy. And I'm out of guesses.
-----
Here is the compile error I can't seem to shake - missing C++ headers. It looks like libc++ is not wired up correctly or libstdc++ is not wired up correctly. In either case, clang++ cannot seem to find the standard C++ headers or library.
$ clang++ -c test.cpp
test.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~
1 error generated.
$ cat test.cpp
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
std::string x(argv[0] ? argv[0] : "");
std::cout << x << std::endl;
return 0;
}
-----
And something more verbose:
$ clang++ -v -c test.cpp
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/
Found candidate GCC installation: /usr/bin/
Found candidate GCC installation: /usr/bin/
Selected GCC installation: /usr/bin/
Candidate multilib: .;@m64
Selected multilib: .;@m64
(in-process)
"/usr/
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/
ignoring nonexistent directory "/usr/bin/
ignoring nonexistent directory "/usr/bin/
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/bin/
/usr/lib/
/usr/local/include
/usr/include/
/usr/include
End of search list.
test.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~~~
1 error generated.
-----
$ command -v g++
/usr/bin/g++
$ command -v clang++
/usr/bin/clang++
$ g++ --version
g++ (Ubuntu 11.3.0-
Copyright (C) 2021 Free Software Foundation, Inc.
$ clang++ --version
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
$ apt-cache show clang
Package: clang
Architecture: amd64
Version: 1:14.0-55~exp2
Priority: optional
Section: universe/devel
Source: llvm-defaults (0.55~exp2)
Origin: Ubuntu
Maintainer: Ubuntu Developers <email address hidden>
Original-
Bugs: https:/
Installed-Size: 25
Depends: clang-14 (>= 14~)
Breaks: clang-3.2, clang-3.3, clang-3.4 (<< 1:3.4.2-7~exp1), clang-3.5 (<< 1:3.5~+rc1-3~exp1)
Replaces: clang (<< 3.2-1~exp2), clang-3.2, clang-3.3, clang-3.4 (<< 1:3.4.2-7~exp1), clang-3.5 (<< 1:3.5~+rc1-3~exp1)
Filename: pool/universe/
Size: 3558
MD5sum: 9012efb7d550940
SHA1: a27e72f7f3e0d3b
...
-----
Finally:
$ update-alternatives --list clang++
update-
Status changed to 'Confirmed' because the bug affects multiple users.