Newbie linking problem

M

MagmaGal

Hi all,

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)
---------------------------------------------------------------
When I type 'make selfpfit', I get the following:

------------------------------------------------
gcc -c selfpfit.c
gcc -c sumio.fpfit.c
g77 -c -e -fno-underscoring area.f
g77 -c -e -fno-underscoring sphere.f
g77 -c -e -fno-underscoring mconv.f
g77 -c -e -fno-underscoring rfuncs.f
cc -o selfpfit selfpfit.o sumio.fpfit.o area.o sphere.o mconv.o
rfuncs.o -L/lib -lm -lg2c
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'
collect2: ld returned 1 exit status
make: *** [selfpfit] Error 1
------------------------------------------------

This seems to me like a linking problem, since area.o, sphere.o,
mconv.o are all created in the directory. The code was all written for
UNIX, and I am running RedHat Linux release 8.0 Kernel 2.4.18-14 on an
i686. Can anyone give me any advice on what's going wrong?

Thanks.

Diana
 
M

Mark A. Odell

(e-mail address removed) (MagmaGal) wrote in

Hi all,

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)
---------------------------------------------------------------
When I type 'make selfpfit', I get the following:

------------------------------------------------
gcc -c selfpfit.c
gcc -c sumio.fpfit.c
g77 -c -e -fno-underscoring area.f
g77 -c -e -fno-underscoring sphere.f
g77 -c -e -fno-underscoring mconv.f
g77 -c -e -fno-underscoring rfuncs.f
cc -o selfpfit selfpfit.o sumio.fpfit.o area.o sphere.o mconv.o
rfuncs.o -L/lib -lm -lg2c
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'
collect2: ld returned 1 exit status
make: *** [selfpfit] Error 1
------------------------------------------------

This seems to me like a linking problem, since area.o, sphere.o,
mconv.o are all created in the directory. The code was all written for
UNIX, and I am running RedHat Linux release 8.0 Kernel 2.4.18-14 on an
i686. Can anyone give me any advice on what's going wrong?

First, tell us how this is a question about the C *language* ?
 
C

Christopher Benson-Manica

Mark A. Odell said:
First, tell us how this is a question about the C *language* ?

If I may say so, posts such as this don't really help the original
off-topic poster understand just what the problem is; IMHO a link to
the FAQ and welcome message is more useful.
 
C

Christopher Benson-Manica

MagmaGal said:
This seems to me like a linking problem, since area.o, sphere.o,
mconv.o are all created in the directory. The code was all written for
UNIX, and I am running RedHat Linux release 8.0 Kernel 2.4.18-14 on an
i686. Can anyone give me any advice on what's going wrong?

Your post is off-topic for comp.lang.c. Please visit

http://www.ungerhu.com/jxh/clc.welcome.txt
http://www.eskimo.com/~scs/C-faq/top.html
http://benpfaff.org/writings/clc/off-topic.html

for posting guidelines and frequently asked questions. Thank you.
 
D

Dave Thompson

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
 
T

Tim Prince

Dave said:
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?
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top