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
 
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!
 
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.
 
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
 
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
 
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 MLandreau.

I followed the 3 steps you gave here and following your suggestion in Step 2 I made the following changes to the configure script (red, Bold):
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 ": <<END"
set X $ac_compile
ac_compiler=$2
for ac_option in --version -v -V -qversion; do
{ { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compiler $ac_option >&5") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
sed '10a\
... rest of stderr output deleted ...
10q' conftest.err >conftest.er1
cat conftest.er1 >&5
fi
rm -f conftest.er1 conftest.err
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
done

cat confdefs.h - <<_ACEOF >conftest.$ac_ext "END"
/* end confdefs.h. */

In addition, as I am working in tcsh, I replaced the 'export' command in Step 3 with 'setenv'

After executing "./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared"
I found that while I no longer run into the "C compiler cannot create executables" error, I encounter the
following instead

configure: WARNING: unrecognized options: --disable-dap, --disable-netcdf-4

Any help would be greatly appreciated.

Thank you and have a pleasant day.
 

Attachments

  • config.log
    120.8 KB · Views: 1
Hi,

I might have been a bit unclear on the modification with 'END'. Here are the modifications I made :

# Provide some information about the compiler.
: <<END
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
[...]
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
done
END

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

This should skip the test of gcc version
 
For your second issue, it is a warning. Does is compile anyway ?
I wrote my own shell script to compile everything and I created a module to set the environment when I am using wrf and wps. I can put everything here. I don't know if it might help you. Good luck :

compile_libraries.sh
#!/usr/bin/sh
echo "module purge"
module purge

echo "setting environment variables"
export DIR=myDir
export CC=gcc
export CXX=g++
export FC=gfortran
export FCFLAGS=-m64
export F77=gfortran
export FFLAGS=-m64
export JASPERLIB=$DIR/grib2/lib
export JASPERINC=$DIR/grib2/include

echo "---------installing netcdf-c"
echo "untar"
tar xzvf netcdf-c-4.7.2.tar.gz &>> log.compile #or just .tar if no .gz present
cd netcdf-c-4.7.2
echo "configure"
./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared >> log.compile
echo "make"
make &>> log.compile
echo "make install"
make install &>> log.compile
cd ..
echo "--------- netcdf-c installed"

echo "setting environment variables"
export PATH=$DIR/netcdf/bin:$PATH
export NETCDF=$DIR/netcdf
export LIBS="-lnetcdf"
export LDFLAGS=-L$DIR/netcdf/lib
export CPPFLAGS=-I$DIR/netcdf/include

echo "---------installing netcdf-fortran"
echo "untar"
tar xzvf netcdf-fortran-4.5.2.tar.gz &>> log.compile #or just .tar if no .gz present
cd netcdf-fortran-4.5.2
echo "modifying configure file"
cp ../netcdf_fortran_configure configure
echo "configure"
./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared &>> log.compile
echo "make"
make &>> log.compile
echo "make install"
make install &>> log.compile
cd ..
echo "---------netcdf-fortran installed"

echo "---------installing mpich"
echo "untar"
tar xzvf mpich-4.1.2.tar.gz &>> log.compile #or just .tar if no .gz present
cd mpich-4.1.2
echo "configure"
./configure --prefix=$DIR/mpich &>> log.compile
echo "make"
make &>> log.compile
echo "make install"
make install &>> log.compile
cd ..
echo "---------mpich installed"

echo "setting environment variables"
export PATH=$DIR/mpich/bin:$PATH

echo "---------installing zlib"
echo "untar"
tar xzvf zlib-1.2.11.tar.gz &>> log.compile #or just .tar if no .gz present
cd zlib-1.2.11
echo "configure"
./configure --prefix=$DIR/grib2 &>> log.compile
echo "make"
make &>> log.compile
echo "make install"
make install &>> log.compile
cd ..
echo "---------zlib installed"

echo "setting environment variables"
export LDFLAGS="-L$DIR/grib2/lib -L$DIR/netcdf/lib"
export CPPFLAGS="-I$DIR/grib2/include -I$DIR/netcdf/lib"

echo "---------installing libpng"
echo "untar"
tar xzvf libpng-1.2.50.tar.gz &>> log.compile #or just .tar if no .gz present
cd libpng-1.2.50
echo "configure"
./configure --prefix=$DIR/grib2 &>> log.compile
echo "make"
make &>> log.compile
echo "make install"
make install &>> log.compile
cd ..
echo "---------libpng installed"

echo "---------installing jasper"
echo "untar"
tar xzvf jasper-1.900.1.tar.gz &>> log.compile #or just .tar if no .gz present
cd jasper-1.900.1
echo "configure"
./configure --prefix=$DIR/grib2 &>> log.compile
echo "make"
make &>> log.compile
echo "make install"
make install &>> log.compile
cd ..
echo "---------jasper installed"
 
Modules/modulefiles/wrf/1.0
#%Module

proc ModulesHelp { } {
puts stderr "This module sets good environment for wrf"
}

module-whatis "This module sets good environment for wrf\n"

conflict arps wps_ungrib

set DIR myDir
setenv DIR $DIR
setenv CC gcc
setenv CXX g++
setenv FC gfortran
setenv FCFLAGS -m64
setenv F77 gfortran
setenv FFLAGS "-m64 -fallow-argument-mismatch"
setenv JASPERLIB $DIR/grib2/lib
setenv JASPERINC $DIR/grib2/include
setenv LDFLAGS "-L$DIR/netcdf/lib -L$DIR/grib2/lib"
setenv CPPFLAGS "-I$DIR/netcdf/include -I$DIR/grib2/include"
setenv LIBS "-lnetcdf"

prepend-path PATH $DIR/netcdf/bin
setenv NETCDF $DIR/netcdf
setenv NETCDF_classic 1

prepend-path PATH $DIR/mpich/bin
 
Modules/modulefiles/wps_ungrib/1.0
#%Module

proc ModulesHelp { } {
puts stderr "This module sets good environment for wrf"
}

module-whatis "This module sets good environment for wrf\n"

conflict wrf

set DIR myDir
setenv DIR $DIR
setenv CC gcc
setenv CXX g++
setenv FC gfortran
setenv FCFLAGS -m64
setenv F77 gfortran
setenv FFLAGS "-m64 -fallow-argument-mismatch"
setenv JASPERLIB $DIR/grib2/lib
setenv JASPERINC $DIR/grib2/include
setenv LDFLAGS -L$DIR/grib2/lib
setenv CPPFLAGS -I$DIR/grib2/include
#setenv LDFLAGS -L$DIR/netcdf/lib
#setenv CPPFLAGS -I$DIR/netcdf/include
setenv LIBS "-lnetcdf -lz"

prepend-path PATH $DIR/netcdf/bin
setenv NETCDF $DIR/netcdf
setenv NETCDF_classic 1

prepend-path PATH $DIR/mpich/bin

prepend-path LD_LIBRARY_PATH $DIR/grib2/lib
 
The modules are useful only if it is installed on your machine. You can create your own module with the codes I gave and add the following line to you bash_profile :
module use --append yourDir/Modules/modulefiles
 
Hi,

I might have been a bit unclear on the modification with 'END'. Here are the modifications I made :

# Provide some information about the compiler.
: <<END
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
[...]
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
done
END

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

This should skip the test of gcc version
Hi MLandreau.

Thank you for responding to my message and for correcting the mistake I made in editing the configure script. After making the appropriate changes, the config.log file still issues the same warning as before (configure: WARNING: unrecognized options: --disable-dap, --disable-netcdf-4) while the C compiler still cannot create the executables. (log_compile.txt)

Also, thank you for your generosity in sharing the scripts you wrote for environment setting and library compilation (compile_libraries.sh). I am working my way through the tutorial to be sure I get what is happening as I am new to WRF.
 

Attachments

  • log_compile.txt
    1 KB · Views: 1
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

When I tried to install WRF v4.5, following the steps on the web page, I did have a problem with the netcdf-fortran-4.5.2 step. This problem is the same as yours and is not to be ignored as I failed in subsequent tests.

The hint in test is: LIBRARIES/netcdf/lib/libnetcdff.a(nf_control.o): In function `nf_open_mem_'.
nf_contriol.F90:(.text+0xcca): undefined reference to `nf_open_mem'.
collect2: error: ld returned 1 exit status

I'm clueless as to how to fix the installation of this library, so I'd appreciate it if you could provide me with your solution!
 
Top