Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble Referencing installed libraries #216

Closed
bdaniels134 opened this issue Sep 12, 2024 · 5 comments
Closed

Trouble Referencing installed libraries #216

bdaniels134 opened this issue Sep 12, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@bdaniels134
Copy link

bdaniels134 commented Sep 12, 2024

Describe the bug
This could be an installation or bad referencing issue but bug seemed to be the right choice. Appreciate your help or suggestions. I recently had NCEPLIBS installed for us on our new linux RHEL 8 compute farm vms for NCEP/OPC. The libraries are not being recognized by my makefile that builds fortran code using the gfortran compiler. I'm not sure if I'm using the correct library names or if there was a problem with the installation.
To Reproduce
I'm trying to compile FORTRAN code to make grib2 files that uses the libraries bacio, w3 and g2_4
When running the makefile I get the following:
make
/usr/bin/gfortran -o nc2grib_ncom ./nc2grib2_ncom.o -L/opt/common_apps/nceplibs/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.5.0/ -lg2_4 -lw3 -lbacio -L/usr/lib64 -ljasper -lpng -lz
/usr/bin/ld: cannot find -lg2_4
/usr/bin/ld: cannot find -lw3
/usr/bin/ld: cannot find -lbacio

Expected behavior
The location of the libraries is linked in the makefile so I'm not sure why they are not found. Tried different variations of the library names as they are listed in the installation dirs but this gave same error.

Build Information
How did you build or access NCEPLIBS?
Installed recently by NCO Helpdesk who have root privledges.
System
On what system are you running the code?
Linux RHEL8
Additional context
The code was written several years back and hoping to recompile it for a change in our systems. Appreciate any help or suggestions.

@bdaniels134 bdaniels134 added the bug Something isn't working label Sep 12, 2024
@edwardhartnett
Copy link
Contributor

OK, did you check the directories you are giving in your -L arguments to see if the .a or .so files are present?

Also I don't think it's w3, it's w3emc_4.

But look in the directories to see what files you have.

@bdaniels134
Copy link
Author

Thanks Ed!

Yes, if I look into each libraries' dir there are .a files.
For example in:
/spack/linux-rhel8-skylake_avx512/gcc-8.5.0/w3emc-2.12.0-qqdlddn5jgzygk7noqxqez6oc3ck3h5b/lib64/libw3emc_4.a

So, next is setting the linking and naming of the libraries correctly.
Should I be able to access the libraries found under /gcc-8.5.0 by naming them like -lw3emc_4 or should I explicitly use the full path for each libraries .a file?
I can test this so no worries if you don't know.

Thanks,
Bob

@edwardhartnett
Copy link
Contributor

Set the directory with the -L argument, then link to the library by putting a -l in front of the name, and leaving off the .a.

Like this:

gcc -L /install/dir/lib my_code.c -lw3emc_4

@bdaniels134
Copy link
Author

Thanks!

@edwardhartnett
Copy link
Contributor

OK, I'll close this issue, let me know if you need any more help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants