471,122 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,122 software developers and data experts.

Creating a shared library and loading it

Hi ,

I am trying to create a shared library and trying to load it
usinf dlopen() function . My code and steps to create and load the *.so
is :

/*** test.c ***/
#include <stdio.h>
void test()
printf("Hello World\n");

/*** Steps for *.so creation ***/
bash-3.00# gcc -fPIC -c test.c
bash-3.00# gcc -o library.so -shared test.o
bash-3.00# gcc -o library.so -Wl,-h,library.so -shared test.o

#include <stdio.h>
#include <dlfcn.h>

int main(int argc,char **argv)
void *handle;
char *error;

handle = dlopen ("library.so", RTLD_LAZY);
if (!handle) {
fprintf (stderr, "%s\n", dlerror());


/*** Steps for creating load executable***/
bash-3.00# gcc test.c -ldl

When I run the "a.out" it gives me the following error

bash-3.00# ./a.out
ld.so.1: a.out: fatal: library.so: open failed: No such file or

Can someone tell me .. where I am wrong ?

Thanks !

Aug 26 '06 #1
0 991

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Francisco Miguel Montenegro Montes | last post: by
3 posts views Thread by Rickard Lind | last post: by
6 posts views Thread by Jeff | last post: by
7 posts views Thread by akennis | last post: by
3 posts views Thread by abhi147 | last post: by
3 posts views Thread by ragi | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.