This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: SunOS shared libs ?


On Wed, 10 June 1998, 10:20:45, law@hurl.cygnus.com wrote:

 > 
 >   In message <13694.39488.317757.302619@slsvhmt>you write:
 >   >  >     Ok, thanks that seems to have fixed the problem. I'd strongly
 >   >  >     suggest adding this to the FAQ.
 >   > 
 >   > Jeff Law, do you think it's worthwhile?
 > It's probably a reasonable thing to do.
 > 
 > jeff

How about this?

diff -rupN -x CVS wwwdocs.orig/htdocs/faq.html wwwdocs/htdocs/faq.html
--- wwwdocs.orig/htdocs/faq.html	Tue May 19 22:24:19 1998
+++ wwwdocs/htdocs/faq.html	Thu Jun 11 19:34:37 1998
@@ -40,6 +40,7 @@
   <li><a href="#gnat">Using egcs with GNAT/Ada</a>
   <li><a href="#gpc">Using egcs with GNU Pascal</a>
   <li><a href="#cvssnapshots">Using CVS to download snapshots </a>
+  <li><a href="#picflag-needed">`assert pure-text failed:' - Why can't I build a shared library?</a>
 </ol>
 
 <hr>
@@ -607,8 +608,27 @@ the form "egcs_ss_<date>".  The latest o
 tag "egcs_latest_snapshot".
 
 <hr>
+<h2><a name="picflag-needed">`assert pure-text failed:' - Why can't I build a shared library?</a></h2>
+<p>This kind of error occurs when you've failed to provide proper flags
+to gcc how to produce <tt>position independent code</tt> (PIC).
+
+<p>How comes this? I only want to link my various .o files into one shared library!
+This is due to gcc's collect2 program generating a small .c file which is responsible for
+e.g. calling static CTOR/DTORs. This file will be silently compiled and linked with
+your own .o files. Make sure to specify <tt>-fPIC</tt> or <tt>-fpic</tt> (whatever
+you've used for compiling your .o files) even when linking:
+
+<pre>
+	gcc -c -fPIC myfile.c
+	gcc -shared -o libmyfile.so -fPIC myfile.o
+</pre>
+
+<p>This kind of error will most likely be seen on SunOS and HP-UX and when using
+their native binutils, i.e. no GNU as and/or ld.
+
+<hr>
 <p><a href="index.html">Return to the egcs home page</a>
-<p><i>Last modified:  May  9, 1998</i>
+<p><i>Last modified:  June 11, 1998</i>
 
 <!--#include virtual="/glimpsebox.html"-->
 </body>


manfred


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]