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]

shared object creation with g77 3.0


Hello,

I looked through a lot of the documentation but couldn't find any 
reference to my problem.

I'm using gcc/g77 3.0 as obtained from sun freeware, on a Sun Ultra 2 
running Solaris 8.0 10/2000.

I was compiling shared object files that are provided as examples that 
are provided with the IDL 5.0.3 distribution of how to interface C or 
FORTRAN subroutines with IDL.

My problem boiled down to the fact that when I used g77 to link the 
object files to form the shared object (which only included two 
subroutines, one in C, and one in FORTRAN, an undefined MAIN__ procedure 
was listed in the shared object, and IDL choked on that.

However, when I did the linking step directly with /usr/ccs/bin/ld 
(getting the right libraries included in the right order), the necessary 
references were properly resolved, and no bogus MAIN__ routine showed up 
in the shared object. IDL was able to handle that version just fine.

I was unable to figure out from the documentation or from the g77 -v 
--help listing whether there are compilation aruments that would 
suppress the inclusion of the MAIN__ listing.

FYI, here is a typical output for the linking step:


g77 -v -m32 -lsunmath -G -o  example_f2f.so \
         example_f2f.o example.o -lF77 -lm -lc
g77 version 3.0 (Fortran Frontend version 0.5.26 20010617 (experimental))
Driving: g77 -v -m32 -lsunmath -G -o example_f2f.so example_f2f.o 
example.o -lF77 -lg2c -lm -lc -lg2c -lm
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/specs
Configured with: ../configure --disable-nls --disable-libgcj 
--enable-languages=c++,f77,objc
Thread model: posix
gcc version 3.0

/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/collect2 -V -G -Y 
P,/usr/ccs/lib:/usr/lib -Qy -o example_f2f.so
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/crt1.o 
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/crti.o
/usr/ccs/lib/values-Xa.o 
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/crtbegin.o 
-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0 -L/usr/ccs/bin 
-L/usr/ccs/lib 
-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/../../.. -lsunmath 
example_f2f.o example.o -lF77 -lg2c -lm -lc -lg2c -lm -lgcc -lc -lgcc 
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/crtend.o 
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/crtn.o
ld: Software Generation Utilities - Solaris-ELF (4.0)

Also, I'm puzzled: checking with 'elfdump', I found "UNDEF MAIN__" in 
libg2c.a, which showed up in my shared object file when I linked with 
g77, but no MAIN or main appeared in the shared object when I linked 
directly with ld, even though -lg2c was included in the argument list.

So -- how do I link subroutines & functions into a shared object with 
g77 without having the phantom MAIN__ program listed in the symbol table?

Thanks,
David Finley

-- 
David S. Finley
Eureka Scientific, Inc.
david@eurekasci.com


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