I'm trying to build a small alpine-based docker container to build c++ app using clang++. Dockerfile
looks like this:
FROM alpine:3.10
RUN apk add --no-cache clang
But when I'm trying to compile a hello world I'm getting the following error:
$ printf '#include <iostream>\nint main(){std::cout<<"Hello"<<std::endl;}' > test.cxx
$ clang++ test.cxx -o test
test.cxx:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~~~
1 error generated.
However, if I'll add a g++
package to this container, this example compiles and works as expected.
It seems that g++
package contains all the c++ headers:
apk info --who-owns /usr/include/c++/9.2.0/iostream
/usr/include/c++/9.2.0/iostream is owned by g++-9.2.0-r3
Is there any way to install c++ headers without installing g++? I'd like to keep my docker image small, and g++ with its dependencies is quite heavy.
libc++
package, but there's no such in alpine repo, andclang
installslibstdc++
as it's dependency – Denis Sheremet Jan 9 '20 at 9:55