public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@Shaw.ca>
To: cygwin@cygwin.com
Cc: ggl329 <ggl329@gmail.com>
Subject: Re: iostream doesn't work (clang++)
Date: Wed, 5 Jul 2023 17:08:34 -0600	[thread overview]
Message-ID: <dbce604a-f7ac-e30f-19db-609a71d2757e@Shaw.ca> (raw)
In-Reply-To: <3c02f650-248e-9e03-94a8-d508c857474e@gmail.com>

On 2023-07-05 09:54, ggl329 via Cygwin wrote:
> 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++?

Package clang pulls in headers and libraries from libc++-devel libclang8 
libunwind-devel gcc-g++ libstdc++6 gcc-core cygwin-devel so the primary include 
paths should be from:
libc++-devel /usr/include/c++/v1/ for most language and library definitions and 
libraries,
libclang8 /usr/lib/clang/8.0.1/include/ for clang intrinsics and builtins,
libunwind-devel /usr/include/ for exception handling definitions and libraries,
gcc-g++ /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/{x86_64-pc-cygwin/,} and 
libstdc++6 for C++ system dependent and low level definitions and libraries,
gcc-core /usr/lib/gcc/x86_64-pc-cygwin/11/include/ for system dependent and low 
level intrinsics and interfaces, and
cygwin-devel /usr/include/{*/,} for system dependent and low level definitions 
and libraries.

Everything clang should be prioritized over anything gcc to prevent such issues, 
so cygcheck -c clang llvm libc++-devel libclang8 libunwind-devel gcc-g++ 
libstdc++6 gcc-core cygwin-devel to ensure eveything has been installed properly.

Unfortunately clang{,++,-cpp} -print-search-dirs does *NOT* show include paths,
but -v and -### complain about nonexistent /usr/include/c++/11 where 
/usr/include/c++/v1 exists!
It appears the search list ignores the directories populated in libc++-devel:
... -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 ...
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/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/local/include
  /usr/include
  /usr/include/w32api
End of search list.

You may want to try to override the built in includes from -internal-isystem 
with those mentioned above but not built in.

I have no idea why both compilers would include w32api headers as if they were 
building Mingw cross compilers!

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

  reply	other threads:[~2023-07-05 23:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-04 16:48 ggl329
2023-07-04 18:51 ` Mark Geisert
2023-07-05  3:06 ` Mark Geisert
2023-07-05 15:54   ` ggl329
2023-07-05 23:08     ` Brian Inglis [this message]
2023-07-07  8:01       ` Mark Geisert
2023-07-07 15:48       ` Jon Turney
2023-07-07 18:18         ` gs-cygwin.com
2023-07-08  9:12           ` Jon Turney
2023-07-13  5:52     ` Mark Geisert
2023-07-13 16:11       ` ggl329

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dbce604a-f7ac-e30f-19db-609a71d2757e@Shaw.ca \
    --to=brian.inglis@shaw.ca \
    --cc=cygwin@cygwin.com \
    --cc=ggl329@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).