The following procedure enables a shared program to load a shared library explicitly.
Create the library file.
Copy the libdyn2.c file into the libshared2dir directory and rename it libshared2.c. The following Imakefile will build a shared library called libshared2.so:
FPIC = ON SRCS = libshared2.c SharedLibraryTarget (libshared2.so, libshared2.o,,,,) Depend($(SRCS))
Create the program file.
Copy the progdyn2.c file into the progshared2dir directory and rename it progshared2.c. The following Imakefile will build a PIC binary object file called progshared2.o and an executable file called progshared2
FPIC = ON SRCS = progshared2.c SharedUserTarget (progshared2_u, progshared2.o, $(UTILS_LIB) $(CLX_UTILS_LIB),,,) Depend($(SRCS))
Copy the application.
Copy the shared application into the /bin subdirectory of the chorus_root_directory directory:
% cp $WORK/progshared2dir/progshared2_u chorus_root_directory/bin |
Copy the shared library.
Copy the shared library into the /lib subdirectory of the chorus_root_directory directory:
% cp $WORK/libshared2dir/libshared2.so chorus_root_directory/lib |
Notify the runtime linker.
The following command will notify the runtime linker where to find the libshared2.so shared library:
% rsh jericho setenv LD_LIBRARY_PATH /lib/shared:/lib |
Alternatively, set the runpath to /lib in the ldopts argument of the program macro (-rpath /lib).
Start the program.
The following command will start the program and load the libshared2.so and libc.so libraries (if they have not already been loaded by another actor):
% rsh jericho /bin/progshared2 |