Quote:
Originally Posted by Reina
Hi I have to compile the native language code made in C into a shared library.I try using this:
gcc -fPIC -g -c -Wall HelloWorldImp.c
gcc -shared -Wl,-soname,lybhello.so.1 -o lybhello.so.1.0.1 HelloWorldImp.c
But it gime an error:
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: /tmp/ccEooh8l.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/tmp/ccEooh8l.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
What can I do to solve this?Please help me!
|
hi
according to your query heading.....
Code:
$ gcc -fpic -c shrobj.c
$ gcc -shared -o libshared.so shrobj.o
$ gcc hello.c libshared.so
$ ./a.out
like this u can create shared libraries...
here "shrobj.c", file used to create a ".so"..
cheers
munna