Problem
How can I create and debug dynamic library functions?
Solution
This example procedure details creation of a debuggable dynamic library function:
1. Create a file called dyfunc.c containing a (very simple) example:
#include <stdio.h>dyfunc(){
printf("Dynamic function called\n");
}2. Create the debuggable dynamic library that contains the above function using cc(CP):
$ cc -g -dy -Kpic -G -o libdyfunc.so dyfunc.c3. Create a program called main.c that calls the dynamic function:
extern void dyfunc();main(){
dyfunc();
}4. Compile this using cc(CP):$ cc -g -dy -Kpic -o main main.c -L. -ldyfunc5. Set the environment variable "LD_LIBRARY_PATH" to the current working directory. For sh(C) and ksh(C), use the following:
$ LD_LIBRARY_PATH=`pwd` export LD_LIBRARY_PATH"main" should now run, and a source-level debugger (for example, dbXtra(CP)) can be used to debug it.
See also
cc(CP), ar(CP), dbx(CP), dbXtra(CP)