Not able to compile C program on z/OS (USS)

Hi,
I having an issue while compiling a C program in USS (z/OS) machine.

I was able to create objest files (.o) from source (.c) files but when I try to create a binary file from the object files I am getting the below error.

$ cc util.o sock.o app.o -lnsl -o ptf
FSUM3067 The archive library nsl (libnsl.a) cannot be found.

Thanks,
Madhu.

It means what it says, it doesn't have -lnsl.

Do you really need -lnsl?

Hi,
Thanks for the reply.

Sorry, I am not much familiar with -lnsl is. I used it because, the same option is used while compiling the program in other unix boxes too.

When I remove the -lnsl option, I get the below errors

$ cc util.o sock.o app.o -o ptf
IGD01008I ALLOCATION SET TO SCTEMPD M0610
 
IGD01010I ALLOCATION SET TO SGTEMPD STORAGE GROUP

IGD01008I ALLOCATION SET TO SCTEMPD M0610
 
IGD01010I ALLOCATION SET TO SGTEMPD STORAGE GROUP
 
 IEW2763S DE07 FILE ASSOCIATED WITH DDNAME /0000004 CANNOT BE OPENED BECAUSE THE
          FILE DOES NOT EXIST OR CANNOT BE CREATED.
 IEW2302E 1031 THE DATA SET SPECIFIED BY DDNAME /0000004 COULD NOT BE FOUND, AND
          THUS HAS NOT BEEN INCLUDED.
 IEW2763S DE07 FILE ASSOCIATED WITH DDNAME /0000005 CANNOT BE OPENED BECAUSE THE
          FILE DOES NOT EXIST OR CANNOT BE CREATED.
 IEW2302E 1031 THE DATA SET SPECIFIED BY DDNAME /0000005 COULD NOT BE FOUND, AND
          THUS HAS NOT BEEN INCLUDED.
 IEW2456E 9207 SYMBOL ntohl UNRESOLVED.  MEMBER COULD NOT BE INCLUDED FROM THE
          DESIGNATED CALL LIBRARY.
 IEW2456E 9207 SYMBOL htonl UNRESOLVED.  MEMBER COULD NOT BE INCLUDED FROM THE
          DESIGNATED CALL LIBRARY.
 IEW2456E 9207 SYMBOL htons UNRESOLVED.  MEMBER COULD NOT BE INCLUDED FROM THE
          DESIGNATED CALL LIBRARY.
FSUM3065 The LINKEDIT step ended with return code 8.

Make sure you have all the right header files.

z/OS V1R10 information center

1 Like

Hi,
I have added the arpa/inet.h header file and removed the -lnsl option.

Now, I am left with the below errors

$ cc util.o sock.o app.o -o ptf
IGD01008I ALLOCATION SET TO SCTEMPD M0610
 
IGD01010I ALLOCATION SET TO SGTEMPD STORAGE GROUP
 
IGD01008I ALLOCATION SET TO SCTEMPD M0610
 
IGD01010I ALLOCATION SET TO SGTEMPD STORAGE GROUP
 
 IEW2763S DE07 FILE ASSOCIATED WITH DDNAME /0000004 CANNOT BE OPENED BECAUSE THE
          FILE DOES NOT EXIST OR CANNOT BE CREATED.
 IEW2302E 1031 THE DATA SET SPECIFIED BY DDNAME /0000004 COULD NOT BE FOUND, AND
          THUS HAS NOT BEEN INCLUDED.
 IEW2763S DE07 FILE ASSOCIATED WITH DDNAME /0000005 CANNOT BE OPENED BECAUSE THE
          FILE DOES NOT EXIST OR CANNOT BE CREATED.
 IEW2302E 1031 THE DATA SET SPECIFIED BY DDNAME /0000005 COULD NOT BE FOUND, AND
          THUS HAS NOT BEEN INCLUDED.
FSUM3065 The LINKEDIT step ended with return code 8.

Hello Madhu,

From the error, its obvious that you need the libnsl.a because code links against some routines from that lib. What I would suggest is that find that library (using find) and explicitly specify the lib in the compile option (with -L) to see if it works.

find / -type f -iname "libnsl.a" 

From this if you get any results then do

$ cc util.o sock.o app.o -lnsl -o ptf -L<YOUR_RESULT>

If you are not able to find libnsl.a then locate it from similar architecture of compile it on your machine.

Thanks and Regards,
Gaurav.

Hi,
I was able to compile the code now.

I have removed "-lnsl" and included "arpa/inet.h" header file, which fixed the issue related to library.

By removing the "-o ptf" remaining issues were also resolved. But this created the binary as a.out and I have renamed it to ptf.

Thanks,
Madhu.

If you read my link, at least some of those missing "routines" are actually macros and need no library, just headers. I'm not sure there is an lnsl for zos.