Subject: bin/8600: Error dynamically linking a C program calling FORTRAN subroutines on ELF
To: None <gnats-bugs@gnats.netbsd.org>
From: None <matthieu@laas.fr>
List: netbsd-bugs
Date: 10/10/1999 02:24:44
>Number: 8600
>Category: bin
>Synopsis: Error dynamically linking a C program calling FORTRAN subroutines on ELF
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Oct 10 02:24:00 1999
>Last-Modified:
>Originator: Matthieu Herrb
>Organization:
LAAS/CNRS Toulouse, France
>Release: <NetBSD-current 9Oct1999>
>Environment:
System: NetBSD bluenote 1.4K NetBSD 1.4K (BLUENOTE) #25: Sat Oct 9 20:44:05 CEST 1999 matthieu@bluenote:/local/NetBSD/src/sys/arch/i386/compile/BLUENOTE i386
>Description:
Dynamically linking a C program that calls FORTRAN subroutines
gives the following error on i386/ELF. It used to work on
a.out (and works on other systems, like Solaris):
/usr/lib/libg2c.so: undefined reference to `MAIN__'
>How-To-Repeat:
unshar the following test program and run 'make'
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# Makefile
# telf.c
# iabs.f
#
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
Xall: telf
X
Xtelf: telf.o iabs.o
X cc -o $@ telf.o iabs.o -lg2c -lm
END-of-Makefile
echo x - telf.c
sed 's/^X//' >telf.c << 'END-of-telf.c'
Xextern int iabs_(int *i);
X
Xint
Xmain(int argc, char *argv[])
X{
X int i = 1;
X
X f_init();
X
X printf("%d\n", iabs_(&i));
X i = -1;
X printf("%d\n", iabs_(&i));
X return 0;
X}
X
X
END-of-telf.c
echo x - iabs.f
sed 's/^X//' >iabs.f << 'END-of-iabs.f'
X integer function iabs(i)
X integer i
X
X print *,'iabs ',i
X if (i.lt.0) then
X iabs = -i
X else
X iabs = i
X end if
X return
X end
END-of-iabs.f
exit
>Fix:
Linking statically make this work again.
>Audit-Trail:
>Unformatted: