From: "Stefan Viljoen" Newsgroups: comp.os.msdos.djgpp Subject: Re: Newbie Question Date: Fri, 1 Oct 1999 21:24:38 +0300 Organization: The South African Internet Exchange Lines: 46 Message-ID: <7t32f6$m62$3@ctb-nnrp2.saix.net> References: <37F065E4 DOT 2C3B57D5 AT virtualis DOT com> <37F0EF05 DOT B46FB474 AT crosswinds DOT net> <37F16793 DOT 4D98B7CE AT virtualis DOT com> NNTP-Posting-Host: pc36-01-p38.nt.saix.net X-Trace: ctb-nnrp2.saix.net 938806566 22722 155.239.194.38 (1 Oct 1999 19:36:06 GMT) X-Complaints-To: abuse AT saix DOT net NNTP-Posting-Date: 1 Oct 1999 19:36:06 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com ----- Original Message ----- From: Alex Mendes da Costa 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!.