For Programmers: Free Programming Magazines  


Home > Archive > Fortran > November 2004 > Re: Newbie linking problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Newbie linking problem
Dave Thompson

2004-11-01, 3:56 am

On 19 Oct 2004 08:26:04 -0700, droman@earth.leeds.ac.uk (MagmaGal)
wrote in comp.lang.c; comp.lang.fortran added and fup2:

> I have the following makefile:
>
> ---------------------------------------------------------------
> .f.o: ; g77 -c -e -fno-underscoring $*.f
> .c.o: ; gcc -c $*.c
>
> BIN = ../.
>
> LIBS = -L/lib -lm -lg2c
>
> selfpfit: selfpfit.o sumio.fpfit.o area.o sphere.o mconv.o rfuncs.o
> cc -o selfpfit selfpfit.o sumio.fpfit.o area.o sphere.o mconv.o
> rfuncs.o $(LIBS)
> [ which compiles OK but linking gets ]
> selfpfit.o: In function `main':
> selfpfit.o(.text+0x93e): undefined reference to `sphere'
> selfpfit.o(.text+0x9c2): undefined reference to `area'
> sumio.fpfit.o: In function `putsumUW':
> sumio.fpfit.o(.text+0x63c): undefined reference to `mconv'
> [on] RedHat Linux release 8.0 Kernel 2.4.18-14 on an
> i686. Can anyone give me any advice on what's going wrong?
>

As others have noted this is offtopic for c.l.c, which does not handle
implementation (compiler, platform) specifics _or_ other languages.

However, at least the last version I looked at of clc's welcome
message to which you were already referred does not list
comp.lang.fortran, which _does_ (usually) handle platform specifics of
Fortran, and some interlanguage linking particularly including
Fortran-C, which for now is itself platform specific. (In f2003 it
is/will be standardized, but you don't have that yet and may or may
not be able to get it anytime very soon.)

Your kernel version is almost certainly not relevant; the g77 version
might be, although I believe the name-mangling stuff, which is almost
certainly the issue here, doesn't vary very much, and someone who
answers might already know what RH 8.0 included.

- David.Thompson1 at worldnet.att.net
Tim Prince

2004-11-01, 8:56 am

Dave Thompson wrote:[color=darkred]
> On 19 Oct 2004 08:26:04 -0700, droman@earth.leeds.ac.uk (MagmaGal)
> wrote in comp.lang.c; comp.lang.fortran added and fup2:
>
>
It's generally better to start out with normal linkage conventions,
particularly if you don't understand the implication of what you have
done. For example, who knows what -e would do? There's some reason for
the choices made by g77, and for people adhering to them.
Given that you chose otherwise, use nm to examine your .o files to find
out which don't match your expectation.
I still use red hat 8, but never with the broken versions of gcc and g77
which came with it. When asking for help on newsgroups, it's best to
use a standard version of the compiler and ask on a newsgroup devoted to
that compiler.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com