
April 30th, 2012, 07:03 AM
|
|
|
First of all, please use code or highlight tags, when posting source code in this forum.
Furthermore, please post your previous attempts and describe your results. Just posting your source code will typically not yield your intended results. With a "question" like yours, I could reply with a "works flawlessly here" and you would not be any whiser.
That said, it does work flawlessly here:
Code:
user@host ~/path $ gcc -c -fPIC Sample.c -o Sample.o
user@host ~/path $ gcc -c -fPIC Sample1.c -o Sample1.o
user@host ~/path $ gcc -shared -Wl,-soname,Sample.so -o Sample.so Sample.o
user@host ~/path $ gcc -shared -Wl,-soname,Sample1.so -o Sample1.so Sample1.o
user@host ~/path $ gcc -Wall -rdynamic main.c -ldl -o main
user@host ~/path $ ./main
Sample.so is Loaded ya
Sample 1 is Loaded Successfully
hello world
Regards, Jens
|