[cfe-users] help with linux setup and clang-6

Milan Andric via cfe-users cfe-users at lists.llvm.org
Fri Aug 31 16:11:42 PDT 2018


I am trying to compile some software that uses `std::optional`, which from
reading a few sites means I need a compiler that supports "C++17" or ISO
C++ 2017 standard.  So I installed clang-6.0 on a clean install of
ubuntu/xenial using the packages from llvm.org, but no luck.  I am guessing
I am using clang incorrectly or there is something wrong with my setup.  In
general is the easiest way at the moment to get a working Clang "C++17" dev
environment running on Linxu/Ubuntu?  Apologies if this is an FAQ, but
searching through the archive I could not find a simple answer.


"You can use Clang in C++17 mode with the -std=c++17 option (use -std=c++1z
in Clang 4 and earlier)."

Test program:

#include <optional>
int main()
    std::optional<int> o1;

Error I am having below. I tried with a few different flags but always with
the same failure.

$ clang++-6.0 -std=c++17 -o test.o test.cpp
test.cpp:1:10: fatal error: 'optional' file not found
#include <optional>
1 error generated.

Clang version and linkage info.

$ clang++-6.0 --version
clang version 6.0.1-svn334776-1~exp1~20180826122732.96 (branches/release_60)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ ldd /usr/bin/clang++-6.0
linux-vdso.so.1 =>  (0x00007fff2fd42000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
libLLVM-6.0.so.1 => /usr/lib/x86_64-linux-gnu/libLLVM-6.0.so.1
libjsoncpp.so.1 => /usr/lib/x86_64-linux-gnu/libjsoncpp.so.1
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff4ffaa9000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff4ff893000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff4ff4c9000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff5040b6000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007ff4ff2c1000)
libedit.so.2 => /usr/lib/x86_64-linux-gnu/libedit.so.2 (0x00007ff4ff089000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff4fee6f000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff4fec6b000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007ff4fea42000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007ff4fe82d000)

Package source:

# install latest clang version (currently 6.0)
curl -L https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/xenial/
llvm-toolchain-xenial-6.0 main"
sudo apt-get update
sudo apt-get install -y clang-6.0

Thank you for any hints!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20180831/544287d7/attachment.html>

More information about the cfe-users mailing list