MSYS2 Clang can't find standard headers - c++

I've installed msys/clang using pacman and run it (from the usr/bin bash terminal) on a simple file which only includes iostream:
$ clang++ main.cpp -o prog.exe
main.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~~~
1 error generated.
When I compile with mingw64/clang using the MinG64 terminal, it works. When should the msys/clang be used in such a case, then, and is there a way of making it work?
mingw64/clang --version:
$ clang --version
clang version 11.0.0 (https://github.com/msys2/MINGW-packages f5d4dab9b9db65e8b4eff740629c411ea5e21091)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:\MSYS2\mingw64\bin
usr/bin/clang --version:
$ clang --version
clang version 11.0.0 (https://github.com/msys2/MSYS2-packages dab5c29f1c61a173e404f1fd78f0c6f56441aa9f)
Target: x86_64-pc-windows-msys
Thread model: posix
InstalledDir: /usr/bin

Related

Why do `gcc -v` and `whereis gcc` output different paths?

I get the following output when I run respectively gcc -v and whereis gcc:
Apple clang version 13.1.6 (clang-1316.0.21.2.3)
Target: x86_64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
gcc: /usr/bin/gcc
Does this mean I have multiple installations of gcc on my mac ? If so, how do I uninstall the 'extra/unnecessary' ones ?
Thanks

configure: error: Fortran compiler cannot create executables

I'm trying to install Quantum ESPRESSO on my computer and have run into an issue when using the ./configure command in the unpacked directory.
$ ./configure
checking build system type... x86_64-apple-darwin21.2.0
checking ARCH... mac686
checking setting AR... ... ar
checking setting ARFLAGS... ... ruv
checking for gfortran... gfortran
checking whether the Fortran compiler works... no
configure: error: in `/Users/myname/winter/q-e-qe-6.8':
configure: error: Fortran compiler cannot create executables
See `config.log' for more details
I just updated to macOS Monterey and have GNU Fortran (Homebrew GCC 11.2.0_3) 11.2.0 installed.
When trying to debug this, I looked at the config.log file and looked at similar googled questions. They all point me to updating or reinstalling things, like gcc, which I subsequently did.
Does the problem have to do with this:
$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
I can see that the version is 4.2.1, but I'm unaware of what Apple clang is. Is it a PATH issue?
I'd appreciate any help.
P.S. Please choose to be kind in responses.
Here is part of the config.log:
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Homebrew GCC 11.2.0_3)
configure:2542: $? = 0
configure:2531: gfortran -V >&5
gfortran: error: unrecognized command-line option '-V'
gfortran: fatal error: no input files
compilation terminated.
configure:2542: $? = 1
configure:2531: gfortran -qversion >&5
gfortran: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gfortran: fatal error: no input files
compilation terminated.
configure:2542: $? = 1
configure:2557: checking whether the Fortran compiler works
configure:2579: gfortran conftest.f >&5
clang: error: invalid version number in '-mmacosx-version-min=12.1'
configure:2583: $? = 1
configure:2621: result: no
configure: failed program was:
| program main
For reference:
$ gfortran --version
GNU Fortran (Homebrew GCC 11.2.0_3) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.```
I had the same issue and I solved by doing the following:
Removing the old tools
($ sudo rm -rf /Library/Developer/CommandLineTools).
Installing xcode command line tools again
($ xcode-select --install).
It was retrieved from:
How to update Xcode from command line

Mac gcc/g++/clang++ compilers for programming in c++

I have a programming class that has a requirement for making the code successfully compile on gcc/g++ 4.8.x or clang++. I'm running mac OSX el capitan at the moment.
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --
with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
This is the clang++ output:
$ clang++ --version
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Would this suffice for the requirements for my class? If not how would I go about updating them?
Thank you!

i want to use g++ but my mac uses clang

I want to compile my program which uses OpenMp on mac os Sierra. I have Xcode8. I do it via terminal: g++ -fopenmp -o train train.cpp. The next errors occur:
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
Tell me please how can I solve this problem.
clang --version
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

How to get the gcc version of .so file on OSX 10.11.6

On mac, Enter "gcc -v" in Terminal to get the gcc version as below.
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
How to get the gcc version used to generate the .so file? For example, I want to get the gcc version from a .so file on Mac.