LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 08-12-2007, 03:37 PM   #1
Reina
LQ Newbie
 
Registered: Aug 2007
Posts: 1

Rep: Reputation: 0
How can I create a Shared library?


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!
 
Old 08-12-2007, 11:14 PM   #2
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Rep: Reputation: 30
Quote:
Originally Posted by Reina View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
list library function of a shared library .so powah Linux - General 7 10-25-2011 04:47 AM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
Trying to create a shared library mukund_desh Linux - Software 1 05-24-2005 05:41 AM
How to write makefile to create shared library in 2.6 kernel yogeshwar_s Linux - Software 1 12-29-2004 12:39 AM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM


All times are GMT -5. The time now is 05:04 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration