as per fpm documentation, I believe you could solve your issue by manually passing fpm a compiler flag that tells the compiler to search in that folder, i.e., if youâre using gfortran,
fpm build --flag -I/opt/gnu/include
Does this solve your issue?
Also: please send the output of your fpm build --verbose command, that will help with understanding whatâs going on.
[100%] Compiling...
/usr/bin/ld: I cant localize -l/opt/gnu/include
collect2: error: ld returned 1 exit status
<ERROR> Compilation failed for object " main "
<ERROR>stopping due to failed compilation
STOP 1
I know nothing about fpm but it seems that it treats wgrib2api and netcdf as libraries to link with, not the modules which are special object files (you should have both .mod and .o file).
`/usr/bin/ld: nĂŁo foi possĂvel localizar -lwgrib2api`
means that the linker was instructed to find libwgrib2api.a (static) or libwgrib2api.so (dynamic) library file.
What if you remove the link = directive?
Copy the libraries from /opt/gnu/lib to /opt/gnu/include (keeping the link directive). Nothing happens and got the same error.
Coment the #link = [âwgrib2apiâ,ânetcdfâ]. Then the results are worst. The compiler list all the references to the library as ânot definedâ. (âreferĂȘncia nĂŁo definida paraâ = âreference not defined toâ. Bellow I put part of output.
/usr/bin/ld: filesMod.f90:(.text+0x93df): referĂȘncia nĂŁo definida para "__netcdf_MOD_nf90_get_var_3d_fourbytereal"
/usr/bin/ld: filesMod.f90:(.text+0x97ce): referĂȘncia nĂŁo definida para "__netcdf_MOD_nf90_close"
/usr/bin/ld: filesMod.f90:(.text+0x9e7d): referĂȘncia nĂŁo definida para "__netcdf_MOD_nf90_get_var_3d_fourbytereal"
/usr/bin/ld: filesMod.f90:(.text+0xa2b8): referĂȘncia nĂŁo definida para "__netcdf_MOD_nf90_get_var_3d_fourbytereal"
/usr/bin/ld: filesMod.f90:(.text+0xa69e): referĂȘncia nĂŁo definida para "__netcdf_MOD_nf90_get_var_3d_fourbytereal"
/usr/bin/ld: filesMod.f90:(.text+0xaa6e): referĂȘncia nĂŁo definida para "__netcdf_MOD_nf90_get_var_3d_fourbytereal"
/usr/bin/ld: build/gfortran_6ED43C0A746540CF/pre-brams/libpre-brams.a(src_filesMod.f90.o): na função "__filesmod_MOD_readatmosgrib2":
filesMod.f90:(.text+0xd4f0): referĂȘncia nĂŁo definida para "__wgrib2api_MOD_grb2_mk_inv"
/usr/bin/ld: filesMod.f90:(.text+0xd5d4): referĂȘncia nĂŁo definida para "__wgrib2api_MOD_grb2_inq"
/usr/bin/ld: filesMod.f90:(.text+0xd852): referĂȘncia nĂŁo definida para "__wgrib2api_MOD_grb2_inq"
/usr/bin/ld: filesMod.f90:(.text+0xddb2): referĂȘncia nĂŁo definida para "__wgrib2api_MOD_grb2_inq"
/usr/bin/ld: filesMod.f90:(.text+0xddf0): referĂȘncia nĂŁo definida para "__wgrib2api_MOD_grb2_free_file"
/usr/bin/ld: filesMod.f90:(.text+0xf4d0): referĂȘncia nĂŁo definida para "__wgrib2api_MOD_grb2_inq"
/usr/bin/ld: filesMod.f90:(.text+0xfad8): referĂȘncia nĂŁo definida para "__wgrib2api_MOD_grb2_free_file"
Actually I think that FPM is not good enough for the proposal I want. As base for compile a large model. But I will keep trying.
external-modules tells fpm that there are used modules with those names, which are not in the projectâs source files;
link tells fpm that it needs to link libwgrib2api.a and libnetcdf.a
-I/opt/gnu/include tells fpm where the additional module files are
Now I think you should also ensure your libraries are seen by the compiler.
Option 1: add their path to environment variable LD_LIBRARY_PATH
Option 2: pass their path to fpm by adding one more flag: --flag -L/opt/gnu/lib (or the exact path where the .a files are located
fpm was meant more as a package manager (i.e., closed ecosystem) than a full build system, but if youâve got suggestions, please submit them to the projectâs issue page so the community can discuss over them!
PS: also note Iâm undergoing a metapackages implementation that should soon make the most common dependencies automatic (think coarrays, MPI, HDF, netCDF, etc.).
One more time, thanks a lot! I had a huge mistake here. The problem was another libraries: wgrib2_api and netcdff (NetCDF Fortran) that not included in link list. I put them and fix the issue. The lines became:
external-modules = ["wgrib2api","netcdf"]
link = ["wgrib2","wgrib2_api","netcdf","netcdff"]