LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-22-2010, 06:31 AM   #1
lnxdebug
LQ Newbie
 
Registered: Sep 2010
Posts: 2

Rep: Reputation: 0
-fPIC compiler option doesnt let application initialize


Hi,

I am rather having a strange issue with using -fPIC compiler option. My application is developed using GCC and an binary executable created out of it which initializes successfully. By initialization, I meant all the threads in the application are created and I get the required response from the executable.

There was a need to create a .so file out of my application instead of binary executable, as it needs to be integrated with another .so file to create a final patch. So we used -fPIC compiler option and created a .so and also an binary executable.

But with -fPIC included, the executable fails to initialize at all. It executes some instructions in the main program, before finally haulting down with a " Program received signal SIGSEGV, Segmentation fault." error. And it always fails at the same faulty address which points to nothing in my application code.

Tried out different debugger tools gdb, valgrind and even strace. Doesnt seem to point any thing. What is that -fPIC adds to the code, which makes my code fail with strange behaviour.

Appreciate any help on this.

Thanks,
LNXDEBUG
 
Old 09-23-2010, 01:28 AM   #2
darenw
Member
 
Registered: Mar 2009
Location: Very humid Central Florida
Distribution: ArchLinux
Posts: 30

Rep: Reputation: 1
I suspect a missing option to the linker. To make .so files, there's some extra stuff to specify, the details of which I don't have handy. What is your linking command?
 
Old 09-23-2010, 04:03 AM   #3
lnxdebug
LQ Newbie
 
Registered: Sep 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for your reply. The linker options I am currently using are as below :

-fPIC -lstdc++ -Xlinker -zmuldefs -lpthread -rdynamic -lrt -Wno-deprecated -g3

Those are for creating a executable. For .so file, I am adding -shared option.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler option -align amarg Programming 2 09-19-2010 12:20 AM
Error recompile with fPIC, but fPIC is already as a compilation option eolmsan Linux - Software 4 12-03-2008 11:05 AM
about -fpic/-fPIC option for gcc George2 Programming 2 09-04-2006 01:38 AM
GCC compiler option for 64 bit lilzz Linux - Newbie 2 08-15-2006 11:48 PM
Will C++ Application run in computer without gcc c-compiler srivembu Linux - General 4 09-03-2005 10:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:55 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration