[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Doubt about -fpic option for compiling objects of shared library
From: |
Paul Pluzhnikov |
Subject: |
Re: Doubt about -fpic option for compiling objects of shared library |
Date: |
Tue, 04 Oct 2005 07:19:30 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) |
"kiran" <kiran.agashe@gmail.com> writes:
> According to docs, there are 2 steps:
> 1> the object files must be compiled using -fpic
> 2> Shared library is created using -shared -fpic
Correct.
> Now my doubt is,
> even if I do not use -fpic option of the first step above, it still
> works (on linux and solaris)!!!
It *happens* to work, but you are programming by coincidence:
http://www.awprofessional.com/articles/article.asp?p=31538&rl=1
It will also likely *not* work on Solaris/SPARC (you probably only
tested on Solaris/x86).
> So is -fpic really required in the first step above???
Yes. Otherwise, your shared library may fail to link (SPARC),
or its pages will not be really shared between processes (Linux).
> on Xeon(Sun-fire V65X) machine, when I use -fpic in the first step
> above, application crashes for "throw" statement.
Look for a bug elsewhere. What is the crash stack trace?
> And if I do not use -fpic in first step, application does not crash!
Probably coincidence.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.