iostream doesn't work (clang++)
ggl329
ggl329@gmail.com
Wed Jul 5 15:54:31 GMT 2023
Hi Mark,
On 2023/07/05 12:06, Mark Geisert via Cygwin wrote:
> My previous reply addressed the specific error reported by your testcase.
> But I am unable to make progress on the root cause because I can't reproduce your report.
Hm, it seems to be difficult to track down the root cause...
> On my system I try the compilation and see:
> ~ clang++ sample.cc
> sample.cc:1:10: fatal error: 'iostream' file not found
> #include <iostream>
> ^~~~~~~~~~
> 1 error generated.
I tried with clang++ --verbose, and the log showed search paths for #include.
iostream is at /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/iostream.
Can you find it? It comes from gcc-g++.
Or the search path includes /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++?
$ clang++ sample.cc --verbose
clang version 8.0.1 (tags/RELEASE_801/final)
Target: x86_64-unknown-windows-cygnus
Thread model: posix
InstalledDir: /usr/bin
"/usr/bin/clang-8" -cc1 -triple x86_64-unknown-windows-cygnus -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name sample.cc -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -v -resource-dir /usr/lib/clang/8.0.1 -internal-isystem /usr/x86_64-pc-cygwin/include/c++ -internal-isystem /usr/x86_64-pc-cygwin/include/c++/x86_64-pc-cygwin -internal-isystem /usr/x86_64-pc-cygwin/include/c++/backward -internal-isystem /usr/x86_64-pc-cygwin/include/c++/11 -internal-isystem /usr/x86_64-pc-cygwin/include/c++/11/x86_64-pc-cygwin -internal-isystem /usr/x86_64-pc-cygwin/include/c++/11/backward -internal-isystem /usr/include/c++/11 -internal-isystem /usr/include/c++/11/x86_64-pc-cygwin -internal-isystem /usr/include/c++/11/backward -internal-isystem /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++ -internal-isystem /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/x86_64-pc-cygwin -internal-isystem /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/backward -internal-isystem /usr/lib/clang/8.0.1/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/clang/8.0.1/include -internal-isystem /usr/x86_64-pc-cygwin/include -internal-isystem /usr/include -internal-isystem /usr/include/w32api -fdeprecated-macro -fdebug-compilation-dir /home/ggl329/tmp -ferror-limit 19 -fmessage-length 120 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fseh-exceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/sample-76ab2a.o -x c++ sample.cc -faddrsig
clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-unknown-cygwin
ignoring nonexistent directory "/usr/x86_64-pc-cygwin/include/c++"
ignoring nonexistent directory "/usr/x86_64-pc-cygwin/include/c++/x86_64-pc-cygwin"
ignoring nonexistent directory "/usr/x86_64-pc-cygwin/include/c++/backward"
ignoring nonexistent directory "/usr/x86_64-pc-cygwin/include/c++/11"
ignoring nonexistent directory "/usr/x86_64-pc-cygwin/include/c++/11/x86_64-pc-cygwin"
ignoring nonexistent directory "/usr/x86_64-pc-cygwin/include/c++/11/backward"
ignoring nonexistent directory "/usr/include/c++/11"
ignoring nonexistent directory "/usr/include/c++/11/x86_64-pc-cygwin"
ignoring nonexistent directory "/usr/include/c++/11/backward"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/x86_64-pc-cygwin/include"
ignoring duplicate directory "/usr/lib/clang/8.0.1/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/x86_64-pc-cygwin
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/backward
/usr/lib/clang/8.0.1/include
/usr/include
/usr/include/w32api
End of search list.
In file included from sample.cc:1:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/iostream:39:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ostream:38:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ios:42:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/ios_base.h:39:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ext/atomicity.h:35:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/x86_64-pc-cygwin/bits/gthr.h:148:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/x86_64-pc-cygwin/bits/gthr-default.h:35:
In file included from /usr/include/pthread.h:11:
In file included from /usr/include/sys/types.h:221:
In file included from /usr/include/sys/_pthreadtypes.h:12:
/usr/include/sys/cpuset.h:45:24: error: use of undeclared identifier '__builtin_malloc'; did you mean
'__builtin_alloca'?
return (cpu_set_t *) __builtin_malloc (CPU_ALLOC_SIZE(num));
^
/usr/include/sys/cpuset.h:45:24: note: '__builtin_alloca' declared here
/usr/include/sys/cpuset.h:52:3: error: use of undeclared identifier '__builtin_free'
__builtin_free (set);
^
2 errors generated.
> My list of possibly related package versions looks very similar to yours:
In my environment, all the packages and versions you listed are installed.
> I'm not a clang user so there might be something fundamentally wrong with
> my setup that I don't see. Also, do you have a CFLAGS or other environment
> string(s) that would possibly be passed to clang as it would to gcc?
> Has "clang++" been aliased to something else, perhaps passing options
> that way? Also, do you happen to have any of the boost libraries installed?
I also use gcc mainly. I use clang just for bug check and coding completion.
So, I'm not familiar with clang's behavior either.
CFLAGS, CXXFLAGS and such other environment variables are not set.
/usr/bin/clang++ is linked to clang-8.exe, and /usr/bin/clang-8.exe is
executed as in the log shown above.
Only libboost_regex1.66 is installed from boost.
$ printenv | grep include
(no output)
$ printenv | grep -i flag
(no output)
$ type clang++
clang++ is /usr/bin/clang++
$ ls -o /usr/bin/clang++
lrwxrwxrwx 1 root 11 Jan 8 16:08 /usr/bin/clang++ -> clang-8.exe
$ cygcheck -dc | grep boost
libboost_regex1.66 1.66.0-1
Thanks,
ggl329
More information about the Cygwin
mailing list