Subject: b16/17: ld doesn't see main() in a library
From: [email-masked] (Mumit Khan)

8 Dec 1996 11:05:24 -0800
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Original-To: [email-masked]
Original-Sender: [email-masked]

I've been testing g77 port under both b16 and b17, and in both cases, ld
refuses to see main() in libf2c.a. I have to do the following to make it
work:
    
    % g77 -o foo.exe foo.f main.o

where main.o is extracted from libf2c.

The following doesn't help either (and it shouldn't if the above fails):

    % g77 -o foo.exe foo.f /abs/path/to/libf2c.a

    % nm -p /abs/path/to/libf2c.a | grep main
    00000100 T _main
             U ___main
    % nm -p main.o | grep main
    00000100 T _main
             U ___main

If I don't specify main.o on the command line, I get the following
(expected when there is no main defined anywhere) error:

========================

[khan@dhaka /src/win32/binary-io-test:926] env
PATH=${PATH}:/src/gnu/win32-b17/lib/gcc-lib/i486-cygwin32/cygnus-2.7.2-961023
/src/gnu/win32-b17/bin/i486-cygwin32-g77 -v -o bwrite.exe bwrite.f
 /src/gnu/win32-b17/bin/i486-cygwin32-gcc -v -o bwrite.exe -xf77 bwrite.f
-xnone -lf2c -lm Reading specs from
/src/gnu/win32-b17/lib/gcc-lib/i486-cygwin32/cygnus-2.7.2.f.1-961023/specs
gcc version cygnus-2.7.2-961023
 /src/gnu/win32-b17/lib/gcc-lib/i486-cygwin32/cygnus-2.7.2.f.1-961023/f771
bwrite.f -fset-g77-defaults -quiet -dumpbase bwrite.f -version -fversion
-o /tmp/cca17744.s GNU F77 version cygnus-2.7.2-961023 (i486-cygwin32)
compiled by GNU C version 2.7.2+repo.  GNU Fortran Front End version
0.5.18 compiled: Dec  8 1996 02:14:25

/src/gnu/win32-b17/lib/gcc-lib/i486-cygwin32/cygnus-2.7.2.f.1-961023/../../../../i486-cygwin32/bin/as -o /tmp/cca177441.o /tmp/cca17744.s
 /src/gnu/win32-b17/lib/gcc-lib/i486-cygwin32/cygnus-2.7.2.f.1-961023/ld
-o bwrite.exe
/src/gnu/win32-b17/lib/gcc-lib/i486-cygwin32/cygnus-2.7.2.f.1-961023/../../../../i486-cygwin32/lib/crt0.o
-L/src/gnu/win32-b17/lib/gcc-lib/i486-cygwin32/cygnus-2.7.2.f.1-961023
-L/src/gnu/win32-b17/lib/gcc-lib/i486-cygwin32/cygnus-2.7.2.f.1-961023/../../../../i486-cygwin32/lib /tmp/cca177441.o -lf2c -lm -lgcc -lcygwin -lkernel32
-lgcc
/src/gnu/win32-b17/lib/gcc-lib/i486-cygwin32/cygnus-2.7.2.f.1-961023/../../../../i486-cygwin32/lib/libcygwin.a(libcmain.o): In function `main':
/src/gnu/win32/src-b17/i486-cygwin32/winsup/libcmain.cc:30: undefined
reference to `WinMain@16'
collect2: ld returned 1 exit status

========================

Note that the order of libraries is the correct one -- -lf2c -lcygwin, so
I'm not sure what the problem is here.

fyi, I'm cross-compiling from a linux RH 4.0 box.

Any ideas how I can work around it?

Thanks
Mumit -- [email-masked]
http://www.xraylith.wisc.edu/~khan/
-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".