Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

ubuntu 20.04, configure netcdf-fortran-4.5.2=> error: "C compiler cannot create executables"

mcanonic

New member
Hi,
this commad:
./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared
generates some error that can be seen in the configure.log file like:

configure:3922: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files

configure:3922: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files

configure:3975: gcc -I/home/cc/Build_WRF/LIBRARIES/grib2/include -L/home/cc/Build_WRF/LIBRARIES/grib2/lib conftest.c -lnetcdf -lz >&5
/usr/bin/ld: cannot find -lnetcdf
collect2: error: ld returned 1 exit status

I followed all the steps mentioned before without any error. What is weird is the fact that "-V" option in gcc in not working even in my fedora machine.
Could you please help me?
I've searched in the forum with no luck.

Best,
M
 

qhuwindsim

New member
I got the similar error, the config.log shows error after this command "./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared"
============================================================
gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)
... rest of stderr output deleted ...
configure:3939: $? = 0
configure:3928: gcc -V >&5
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
compilation terminated.

configure:3939: $? = 1
configure:3928: gcc -qversion >&5
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.

configure:3939: $? = 1
configure:3959: checking whether the C compiler works
configure:3981: gcc -I/home/alex/Build_WRF/LIBRARIES/grib2/include -L/home/alex/Build_WRF/LIBRARIES/grib2/lib conftest.c -lnetcdf -lz >&5
/usr/bin/ld: cannot find -lnetcdf: No such file or directory
collect2: error: ld returned 1 exit status
configure:3985: $? = 1
configure:4023: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "netCDF-Fortran"
| #define PACKAGE_TARNAME "netcdf-fortran"
| #define PACKAGE_VERSION "4.5.2"
| #define PACKAGE_STRING "netCDF-Fortran 4.5.2"
| #define PACKAGE_BUGREPORT "support-netcdf@unidata.ucar.edu"
| #define PACKAGE_URL ""
| #define PACKAGE "netcdf-fortran"
| #define VERSION "4.5.2"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:4028: error: in `/home/alex/Build_WRF/LIBRARIES/netcdf-fortran-4.5.2':
configure:4030: error: C compiler cannot create executables
See `config.log' for more details

========================================================================

Please help me, Thank you!
 

kwerner

Administrator
Staff member
Hi,
This is regarding installation of NetCDF, and unfortunately we are unable to support installation of libraries. I would recommend contacting a systems administrator at your institution or perhaps a support person with NetCDF. If you figure out the issue and don't mind, let us know the result so it may help other users in the future.
 

junius.Wang

New member
Hi, I met this problem too, but i solve it by link the lnetcdf, you may find it with command: locate libnetcdf.so , then you can link the file to the path which should be for the compilation.

I don't why we met these problems , I think the netcdf code which tutorials offered is not complete, I find the lnetcdf under anaconda. Maybe all of you could have a try.

And if you met another problem same as me
please let me know, and if you have any solution , please share with me .

Best Regards,
Junius
 

MLandreau

Member
Hi mcanonic, I faced the same issue and solved it following these steps :

### Step 1 :
After untar the netcdf-fortran-4.5.2.tar.gz, the WRF tutorial tell you to run configure. This could result in an error because he think gcc doesn't work. If you look at the configure log file, you might notice that the error comes from the command "gcc -V". This command has been replaced in later version of gcc by "gcc -v" (I am using v11.3). Then you need to modify the configure file. Just type this command line from the LIBRARIES folder :

```
sed -i "s/$CC -V/$CC -v/g" netcdf-fortran-4.5.2/configure
```
This line just replace all occurrence of "$CC -V" by "$CC -v" in the configure file.

### Step 2 :
Since it still didn't work (the output of gcc -v is probably different than the older output of gcc -V), I totally disabled a gcc test in configure by adding the ": <<'END'" and "END", respectively at lines 3919 (after the comment line) and 3943.

### Step 3 :
Then it couldn't find the -lnetcdf so I modified the LDFLAGS and CPPFLAGS environment variables to add netcdf path.
```
export LDFLAGS=-L$DIR/netcdf/lib
export CPPFLAGS=-I$DIR/netcdf/include
```

It worked for me and I was able to compile and run WRF
 
Hi,
this commad:
./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared
generates some error that can be seen in the configure.log file like:

configure:3922: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files

configure:3922: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files

configure:3975: gcc -I/home/cc/Build_WRF/LIBRARIES/grib2/include -L/home/cc/Build_WRF/LIBRARIES/grib2/lib conftest.c -lnetcdf -lz >&5
/usr/bin/ld: cannot find -lnetcdf
collect2: error: ld returned 1 exit status

I followed all the steps mentioned before without any error. What is weird is the fact that "-V" option in gcc in not working even in my fedora machine.
Could you please help me?
I've searched in the forum with no luck.

Best,
M
Code:
 cd ${WRF_FOLDER}/Downloads
      tar -xzvf v$Netcdf_C_Version.tar.gz
      cd netcdf-c-$Netcdf_C_Version/
      export CPPFLAGS=-I$DIR/grib2/include
      export LDFLAGS=-L$DIR/grib2/lib
      export LIBS="-lhdf5_hl -lhdf5 -lz -lcurl -lgfortran -lgcc -lm -ldl -lpnetcdf"
    autoreconf -i -f 2>&1 | tee autoreconf.log
      CC=$MPICC FC=$MPIFC CXX=$MPICXX F90=$MPIF90 F77=$MPIF77 ./configure --prefix=$DIR/NETCDF --disable-dap --enable-netcdf-4 --enable-netcdf4 --enable-shared --enable-pnetcdf --enable-cdf5 --enable-parallel-tests 2>&1 | tee configure.log
    automake -a -f 2>&1 | tee automake.log
      make -j $CPU_HALF_EVEN 2>&1 | tee make.log
      make -j $CPU_HALF_EVEN install 2>&1 | tee make.install.log
      #make check

      export PATH=$DIR/NETCDF/bin:$PATH
      export NETCDF=$DIR/NETCDF

using the autoconf and automake tools help solves this problem
 
Top