I use the dlopen/dlsym/dlclose functions for dynamic loading on SunOS 4.1.3
These functions also exist in Solaris 2.3 and OSF 1. However I am not able to
use them. Hereafter is a simple example which work on SunOS 4.1.3
/* File main.c */
#include <stdio.h>
#include <dlfcn.h>
int main()
{
void *handle;
void (*f)();
printf("hello, ");
if ((handle=dlopen("world.so", 1)) == NULL) {
fprintf(stderr, "Cannot open world.so\n");
return 1;
}
f=dlsym(handle, "world");
(*f)();
}
-------------
/* File world.c */
#include <stdio.h>
void world(void)
{
printf("world\n");
}
To compile the main program I do:
gcc -o main main.c (i.e. nothing special)
I compile the world.c program with the -fpic option and load it with -assert
option to build world.so
-- Erick
Received on Tue Aug 02 1994 - 17:05:09 CEST
This archive was generated by hypermail 2.3.0
: Mon Jul 21 2014 - 19:38:59 CEST