2

I have two 16.04 systems with gcc (5.4.0 and 6.0.0) and clang 3.8 (1:3.8-33ubuntu3.1). On the first system, clang succeeds compiling C++ code; with adding -v, essential output parts are:

Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/6.0.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.0.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0
[...]
#include <...> search starts here:
 /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0
 /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0
 /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/backward
 /usr/local/include
 /usr/lib/llvm-3.8/bin/../lib/clang/3.8.0/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.

But, on another system, it fails; verbose output shows

Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/6.0.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.0.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.0.0

But GCC6 in this version doesn't contain headers, so compilation fails:

#include <...> search starts here:
 /usr/bin/../lib/gcc/x86_64-linux-gnu/6.0.0/../../../../include/c++
 /usr/local/include
 /usr/lib/llvm-3.8/bin/../lib/clang/3.8.0/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
In file included from TimeHelper.cc:1:
./TimeHelper.hh:4:10: fatal error: 'cstdint' file not found
#include <cstdint>

The header is present in /usr/include/c++/5/ but this path is not listed here. (libstdc++-5-dev is installed.)

Systems are not identical but both brand fresh (updated today).

How to find out what is the issue source?

Is the preferred toolchain hardwired or suggested in a config file?

NB attempt to explicitly specify --gcc-toolchain to a value like /usr/lib/gcc/x86-64-linux-gnu/5 fails: it seems clang doesn't recognize the directory as a GCC installation path. Unlike it, to specify target directory of a manual GCC build succeeds (but I want to see it working by default).

  • Wondering whether this is really a question for a C/C++ forum as opposed to for AskUbuntu? – Juan Antonio Mar 29 '17 at 11:42
  • @JuanAntonio I don't think so. Neither my system (FreeBSD, CentOS) has such issue, it seems to be very specific to Ubuntu build of clang. – Netch Mar 29 '17 at 12:34
  • @JuanAntonio no, this is fine here. It isn't really about C itself, but about compiling something on Ubuntu. – terdon Mar 30 '17 at 7:51
1

Fixed after installing clang 4.0 (this didn't fix the issue by itself), removing rests of clang 3.8, gccgo, and reinstalling GCC 5 from the same packages. Now it selects the proper version.

Due to lack of select algorithm details I can't say exactly what of them caused this result. Anyway, it works.

| improve this answer | |
0

On the machine that works:

$ find /usr/include/c++/ -name cstdint
/usr/include/c++/5/tr1/cstdint
/usr/include/c++/5/cstdint
$ dpkg -S /usr/include/c++/5/cstdint
libstdc++-5-dev:amd64: /usr/include/c++/5/cstdint

So it's in libstdc++-5-dev.

http://packages.ubuntu.com/xenial/libstdc++-5-dev

http://packages.ubuntu.com/xenial/amd64/libstdc++-5-dev/filelist

Let's look into libstdc++-6-dev then:

http://packages.ubuntu.com/zesty/libstdc++-6-dev

http://packages.ubuntu.com/zesty/arm64/libstdc++-6-dev/filelist

...
/usr/include/c++/6/cstdint
...
...
/usr/include/c++/6/tr1/cstdint
...
| improve this answer | |
  • yep, libstdc++-5-dev installed on both hosts. I don't treat installing packages from a newer flavor as a solution. – Netch Mar 29 '17 at 12:33
  • So why do you have packages from a newer flavor on the second machine? – Velkan Mar 29 '17 at 12:42
  • I haven't. There is no libstdc++-6-dev. There are gcc-6-base:{amd64,i386} that are stock in xenial. – Netch Mar 29 '17 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.