configure: error: Fortran compiler cannot create executables - c++

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

Related

Unable to install elastic beanstalk cli

I'm following the instructions to install the eb cli:
https://github.com/aws/aws-elastic-beanstalk-cli-setup
However, upon running ./bundled_scripts, I'm getting this error:
BUILD FAILED (OS X 11.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/python-build.20210326201347.50053
Results logged to /var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/python-build.20210326201347.50053.log
Last 10 log lines:
checking for python3.7... python3.7
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... clang
checking whether the C compiler works... no
configure: error: in `/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/python-build.20210326201347.50053/Python-3.7.2':
configure: error: C compiler cannot create executables
See `config.log' for more details
Exiting due to failure
Of course I do have a c compiler since gcc --version shows:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin20.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
How do I fix this?

Clang version confusion (OSX and Cmake)

I'm attempting to lock down the compiler version I use (for a number of reasons I won't go into). To do this, I'd like to check the version of the compiler on build using CMAKE_CXX_COMPILER_VERSION and CMAKE_CXX_COMPILER_VERSION.
On OSX CMake reports:
CMAKE_CXX_COMPILER_VERSION 7.0.2.7000181
CMAKE_CXX_COMPILER_ID Clang
CMAKE_CXX_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
However, the version reported via terminal is:
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
This is true of:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ --version
clang --version
gcc --version
g++ --version
Why the discrepancy in version numbers as reported by CMake and the command line (for the same executable)?
And for the purposes of restricting to a particular compiler version, is CMAKE_CXX_COMPILER_VERSION reliable?
Turns out CMake sets the compiler version in CMakeFiles/3.5.0/CmakeCXXCompiler.cmake (for version 3.5.0). Only by deleting this file and re-building is the correct compiler version reported (assuming you had a different one installed at some point).

CUDA 7.0 complains about not supporting gcc 4.9

I have installed gcc-4.7, gcc-4.8, gcc-4.9
When I try to do:
luarocks install cutorch
I get an error:
In file included from /usr/include/cuda_runtime.h:59:0,
from <command-line>:0:
/usr/include/host_config.h:82:2: error: #error -- unsupported GNU version! gcc 4.9 and up are not supported!
#error -- unsupported GNU version! gcc 4.9 and up are not supported!
I found a similar problem
But when I try to run the command:
nvcc --compiler-bindir /usr/bin/gcc-4.7
I get an error:
nvcc fatal: No input files specified; use option --help for more information
I'm new and installed linux day ago. Please help me
Run the following commands before the installation:
export CXX=/usr/bin/g++-4.8
export CC=/usr/bin/gcc-4.8
this should set the compiler to gcc-4.8 for the compilation.

luarocks 'gcc-plugin.h' build error

I am trying to use torch together with the hdf5 package. I am trying to install it via luarocks install hdf5 but during the build phase I get an error regarding the gcc-plugin header. (gcc relies on clang backend). The complete error message is:
luarocks install --local hdf5
Installing https://luarocks.org/hdf5-2.0.0-1.src.rock...
Using https://luarocks.org/hdf5-2.0.0-1.src.rock... switching to 'build' mode
Warning: variable CFLAGS was not passed in build_variables
gcclua-config.h:1:10: fatal error: 'gcc-plugin.h' file not found
#include "gcc-plugin.h"
^
1 error generated.
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -c -o gcclua.o -Iplugin/include -fPIC -O2 -Wall -Wformat-security -I/usr/local/Cellar/lua/5.2.4_3/include gcclua.c
gcclua.c:7:10: fatal error: 'gcc-plugin.h' file not found
#include "gcc-plugin.h"
^
1 error generated.
make[2]: *** [gcclua.o] Error 1
make[1]: *** [gcc] Error 2
make: *** [gcc-lua] Error 2
Just to give more information, I am relying on
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
xcrun: error: couldn't stat toolchain: '/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.11.xctoolchain' (errno=No such file or directory)
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Does anybody has maybe a hint how to fix this issue?
Every help is greatly appreciated!!!
In addition to gcc, you need the headers, which on Linux you can get with sudo apt-get install gcc-4.8-plugin-dev. If you're on a different OS or version of gcc, just substitute the appropriate package manager / gcc version number.
gcc-plugin.h is a part of GCC, so I think you'll really need to install gcc to get that. Clang provides a gcc-compatible front-end script but that merely presents a command-line driver with compatible flags.
You should be able to install GCC using Homebrew: https://apple.stackexchange.com/a/86588
I bet you tried to work on a CS287-16 class :). I have contacted the developer of this library who wasn't that easy to do something to solve the problem. Apparently he has no friends who have a Mac PC... As a workaround I could suggest you to use a Docker container with Linux in it to run Lua scripts. That's what I have ended up with...
Here's the Docker image I was talking about: https://github.com/aoboturov/cs287-16-lua. You could build it yourself and the just run as a Docker container :)

msys and tdm-gcc: configure error - cannot run C compiled programs

so I'm trying to compile a preexisting C++ project with msys and tdm-gcc in Windows. I have done this successfully by installing tdm-gcc (latest version) via the installer, editing MinGW/msys/1.0/etc/fstab to give my tdm-gcc install as the mount location, then running msys to call the configure script, and make.
However, for this project I need to use an old version of tdm-gcc (4.6.1-tdm64-1) for binary compatibility. So I installed the required packages from the tdm-gcc sourceforge site (gcc core, gcc c++, binutils, mingw64-runtime, mingw32-make, libintl, libiconv, all of the version the readme says to use with 4.6.1), extracted to a new directory, and edited fstab to point to their location. Now while executing the configure I get this error: cannot run C compiled programs. The config file reads:
[omitted]
configure:3436: $? = 0
configure:3425: gcc -v >&5
Using built-in specs.
COLLECT_GCC=c:\TDM-GCC-4.6.1-64\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/tdm-gcc-4.6.1-64/bin/../libexec/gcc/x86_64-w64-mingw32/4.6.1/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../src/gcc-4.6.1/configure --build=x86_64-w64-mingw32 --enable- targets=all --enable-languages=c,c++,fortran,objc,obj-c++ --enable-libgomp --enable-lto --enable-libstdcxx-debug --enable-version-specific-runtime-libs --enable-fully-dynamic-string --with-gnu-ld --disable-werror --disable-nls --disable-win32-registry --prefix=/mingw64tdm --with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1 --with-bugurl=http://tdm-gcc.tdragon.net/bugs
Thread model: win32
gcc version 4.6.1 (tdm64-1)
configure:3436: $? = 0
configure:3425: gcc -V >&5
gcc.exe: error: unrecognized option '-V'
gcc.exe: fatal error: no input files
compilation terminated.
configure:3436: $? = 1
configure:3425: gcc -qversion >&5
gcc.exe: error: unrecognized option '-qversion'
gcc.exe: fatal error: no input files
compilation terminated.
configure:3436: $? = 1
configure:3456: checking whether the C compiler works
configure:3478: gcc conftest.c >&5
configure:3482: $? = 0
configure:3530: result: yes
configure:3533: checking for C compiler default output file name
configure:3535: result: a.exe
configure:3541: checking for suffix of executables
configure:3548: gcc -o conftest.exe conftest.c >&5
configure:3552: $? = 0
configure:3574: result: .exe
configure:3596: checking whether we are cross compiling
configure:3604: gcc -o conftest.exe conftest.c >&5
configure:3608: $? = 0
configure:3615: ./conftest.exe
./configure: line 3617: ./conftest.exe: Bad file number
configure:3619: $? = 126
configure:3626: error: in `/c/jagswm':
configure:3628: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
[omitted]
I've tried adding the tdm-gcc bin to my path, although I don't think that should matter if fstab is set.
Any advice would be greatly appreciated, thanks.
Try to disable your antivirus.
Worked for me while compiling GStreamer, probably because Avast was deleting the a.exe file.
Source: http://wiki.openttd.org/Compiling_on_Windows_using_MinGW#Compilation_and_installation_of_the_required_packages