I am working on a new CentOS 8 server to replace an aging CentOS 6 server. Most everything is working and I am having the primary users test out everything they use the server for. Many errors have come and gone but this one not so much.

The user is running a gcc command:

gcc process-hdf.c -o process-hdf.exe -I/usr/include/hdf -L/usr/lib64 -lmfhdf -ldf -ljpeg -lz -lnsl -lm

which ends up failing with

/usr/bin/ld: cannot find -lnsl

I have done the following so far:

  • Ran ld -l nsl, same error as with gcc.
  • Verified that libnsl is installed within /usr/lib64.
  • Verified both packages, libnsl and libnsl2 are installed.
  • Checked the ldconfig cache and both versions of libnsl are listed.
  • Removed the libnsl package, other packages depend on libnsl2. No change when removed.

Any info would be appreciated.

  • -o process-hdf.exe looks like the build system is trying to create a windows executable. there's nothing wrong per se (and process-hdf.exe is a valid - although unusual - unix executable name), but it might indicate that the build system is very hackish and/or broken. – umläute Jan 4 at 20:43
  • "Verified that libnsl is installed within /usr/lib64.": which files did you find to pass the "verification"? (please add that info to your question) – umläute Jan 4 at 20:44
  • 2
    Do you have the libnsl2-devel package installed? – Vojtech Trefny Jan 4 at 20:50
  • 1
    Can you edit into the question the output of ls -l /usr/lib64/libnsl* (ls rather than ld) please? – icarus Jan 4 at 21:10

Do you have the libnsl2-devel package installed? – Vojtech Trefny Jan 4 at 20:50

This was it. Before I posted the question I had searched for other libnsl2 packages, hoping to find a -devel, but it did not show up in the results hence I did not think it existed.

Turned out the powertools repository had been disabled. Checking the repository files all of the edits I had made to point to our local repository had been removed because the names of the files had been changed. My modified files had been renamed as .rpmsave files.

After fixing the repository issue I was able to install libnsl2-devel. A quick check with ld -l nsl now showed the expected output and the compilation command now works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.