Mail Archives: djgpp/1999/10/01/18:31:32
----- Original Message -----
From: Alex Mendes da Costa <alexmdc AT virtualis DOT com>
Newsgroups: comp.os.msdos.djgpp
Sent: Wednesday, September 29, 1999 4:12 AM
Subject: Re: Newbie Question
> Okay, so now I have a header file with my routines declared and globals
> and stuff called "subs.h" and I have a c program containing all these
> subs called "subs.c" and I have a program called "prog.c" which contains
> the line '#include "subs.h"'. I try to compile this using GCC (ie gcc
> prog.c -o prog.exe) and I get error messages for all my subs which say:
> c:/djgpp/tmp\cccqmssf(.text+0x123):prog.c:undefined referance to 'mysub'
> or something similar.
>
> I know I'm probably doing something really dumb but I can't figure it
> out!
The problem is that you need to link both the source files that are involved
in the program - the header included in PROG.C refers to objects that the
linker cannot find at link time (because you did not include subs.c in the
command line) and that is why it does not work. To fix it I think you need
to do something like
gcc prog.c subs.c -o prog.exe
When using Allegro for example, where the object code is in a library file
liballeg.a (a library being a collection of object files, i. e. built up out
of lots of seperate modules) you would do something like
gcc prog.c -o prog.exe -lalleg
This is pretty much what you do when you are linking assembly modules to
DJGPP modules using something like NASM - see my WWW page's programming
section for an example of how you link two modules together using the DJGPP
make facility, which is a neat facility for handling projects with many
little modules (or just two, like you have here.)
This message courtesy of
RylanNet rylan AT intekom DOT co DOT za
http://home.intekom.com/rylan/
--
StarWars for ever!.
- Raw text -