I am trying to port the ncio package ( an overlay to the NetCDF library ) to fpm by providing external libraries through the toml file as follow:
[[test]] name = "test_ncio" link = ["netcdff","netcdf"]
(full setup is there: GitHub - dmr-dj/ncio: Simple Fortran interface to NetCDF reading and writing. , branch fpm)
When doing so, the generated compilation command by fpm is (on my system):
gfortran -I/usr/include -L/usr/lib/x86_64-linux-gnu build/gfortran_72880B597F4FEB11/ncio/test_main.f90.o -lnetcdff -lnetcdf build/gfortran_72880B597F4FEB11/ncio/libncio.a -o build/gfortran_4F14C1E13F387E09/test/test_ncio
and fails with an error message indicating that it cannot find the NetCDF libraries.
However, manually modifying the order of the command above to:
gfortran -I/usr/include -L/usr/lib/x86_64-linux-gnu build/gfortran_72880B597F4FEB11/ncio/test_main.f90.o build/gfortran_72880B597F4FEB11/ncio/libncio.a -o build/gfortran_4F14C1E13F387E09/test/test_ncio -lnetcdff -lnetcdf
results to a success.
This second version is much more inline with the usual ordering:
$(FC) -o $@ $(FFLAGS) $(LDFLAGS) $(FOBJ) $(LIBS)
Where LIBS are at the end.
Am I missing something in the setup of the fpm.toml file or is this gfortran specific?
For info, I am using:
Ubuntu 22.04.1 LTS / gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)
Thanks in advance for your kind help in this matter!