[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ shared libraries on Sun Forte compiler
From: |
Bob Friesenhahn |
Subject: |
Re: C++ shared libraries on Sun Forte compiler |
Date: |
Thu, 28 Nov 2002 10:21:18 -0600 (CST) |
Have you tried using the CVS version of libtool? This seems to work
ok with the Sun Forte compiler. Earlier versions of libtool are not
designed to work with C++.
Bob
On Thu, 28 Nov 2002, Ulrik Petersen wrote:
> Hello,
>
> libtool is great, but unfortunately it still does not
> work equally well on all platforms. I have problems
> with building shared C++ libraries on the Sun Forte CC
> compiler, especially when using templates. There are
> severel problems, all of which I will describe below.
>
> The Sun Forte compiler has problems when object files
> are moved around, which libtool does by default. This
> is because the Sun Forte compiler stores template
> instances in separate files, along with information
> about which object files belong with which template
> instances. Thus when object files are moved around
> (between $libdir and $objdir), the linker (which
> happens to be the compiler) does not know where to
> find the template instances, resulting in unresolved
> symbols. There is a FAQ dealing with this at:
>
> http://wwws.sun.com/software/sundev/suncc/faqs/cpp.html#0q3
>
> Here is a (very dirty) sed script I use in my
> configure.in in order to make libtool work:
>
> s/compiler_o_lo="no"/compiler_o_lo="yes"/
> s%$show "$mv $output_obj $libobj"%\#%
> s%$show "$mv $libobj $obj"%\#%
> s%$show "$mv $output_obj $obj"%\#%
> s%$show "$mv $libobj $lo_libobj"%\#%
> s%$run $mv $output_obj $libobj%test "x" = "x"%
> s%$run $mv $libobj $obj%test "x" = "x"%
> s%$run $mv $output_obj $obj%test "x" = "x"%
> s%$run $mv $libobj $lo_libobj%test "x" = "x"%
> s%\*\.lo) libobjs="\$libobjs \$arg"%\*\.lo)
> libobjs="\$libobjs \$objdir/\$arg"%
>
> As you can see, this sed script solves three problems:
>
> 1) It sets compiler_o_lo to yes, even though
> aclocal.m4 believes it should be no.
>
> 2) It removes the lines that mv any object files.
>
> 3) It puts $objdir/ in front of all object files when
> linking.
>
> Also, as detailed in the Sun Forte C++ User's Guide,
> one should use CC -xar -o instead of ar and CC -g
> instead of ld when linking C++ libraries. Otherwise,
> templates are not instantiated.
>
> Here is the code I use in my configure.in to
> accomplish this. ISHOSTSUNCC is a variable I set
> myself.
>
> if test x$ISHOSTSUNCC = xyes; then
> AR=CC;
> AR_FLAGS="-xar -o";
> LD=CC;
> export AR AR_FLAGS LD
> fi
>
> dnl Invoke libtool
> AC_PROG_LIBTOOL
>
> Of course, one should not use the CC compiler as the
> linker/archiver when linking C libraries. So there
> are some language-related complexities involved here.
>
> The Sun Forte C++ User's Guide can be found at:
>
> http://docs.sun.com/db/doc/806-7991
>
> The relevant sections are: Chapter 7 (especially
> 7.3.1), Chapter 16 (especially 16.2 and 16.3), Chapter
> 12.
>
> If you need any other information, please contact me
> off-list: address@hidden
>
> Best regards,
>
> Ulrik Petersen
> Emdros maintainer, <http://www.emdros.org/>
>
>
> =====
> --
> Ulrik Petersen, Denmark
>
> Beskyt din computer mod virus og misbrug! Læs mere i Yahoo! Sikkerhedscenter
> på www.yahoo.dk/sikkerhedscenter
>
>
> _______________________________________________
> Libtool mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/libtool
>
======================================
Bob Friesenhahn
address@hidden
http://www.simplesystems.org/users/bfriesen