Linking

C/C++ for Open Enterprise Languages on z/OS® 2.0 uses the ld utility to invoke the binder, which links specified object files to create one executable file. You can use the -Wl,<arg>,<arg2>... option to pass the comma separated arguments to the ld utility. For example:
  • -Wl,-v produces pseudo JCL that lists all inputs and options to the ld utility.
  • -Wl,-V produces all binder listings that are essential for diagnosing link errors.

Unless you specify -c or -E, the last step of the compilation command is to perform the link step.

Input files
Object files, unstripped executable files, and library files serve as input to the binder. Object files must have a .o suffix, for example, filename.o. Static library file names have a .a suffix, for example, filename.a. DLL definition side file names have a .x suffix, for example, filename.x.
Output files
The binder generates an executable file by default and places it in your current directory. The default name for an executable file is a.out. To name the executable file explicitly, use the -o file_name option with the invocation command, where file_name is the name you want to give to the executable file. For example, to compile myfile.c and generate an executable file called myfile, enter:
clang++ myfile.c -o myfile
The binder can also generate a shared library. If you use the option --shared, the binder generates a shared library and a side deck file. The default name for the shared library is also a.out and the default name for the side deck file is the name of the shared library with the suffix changed to .x, which is a.x. You can use the -o <file_name> option to name the shared library explicitly. For example,if you specify -o libabc.so, then the side deck file name is libabc.x. You can use the following command to compile myfile.c and generate a shared library with the name of libmyfile.so:
clang++ --shared -o libmyfile.so

Related information

  • ld command in the z/OS UNIX System Services Command Reference