www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/21/01:32:14

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Newbie question: Linking in RHide
Date: 20 May 1997 19:57:11 GMT
Organization: Oxford University, England
Lines: 55
Message-ID: <5lsvmn$2s3@news.ox.ac.uk>
References: <33814CF5 DOT F50 AT eduserv2 DOT rug DOT ac DOT be>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Alexander Borghgraef (aborghgr AT eduserv2 DOT rug DOT ac DOT be) wrote:
...asking for details on using Allegro with RHIDE.

Short and sweet: 

1) #include <allegro.h> in every file which calls Allegro routines
directly

2) Go to the Options menu, choose Libraries, and put `alleg' in the top
slot, making sure you also check (mark with an X) the box to its left.

FYI, to clarify the process of compiling and linking multi-file projects
(in answer to your question about using libraries in such projects):

In general, at a simplistic level, you first *compile* each
.c/.cc/.cpp/etc file to a .o object file. This is what RHIDE is doing when
it says `Compiling xxxxx.c'. When all the .o files are created, you then
*link* them together to form the executable. I think RHIDE says `Creating
xxxxx.exe' for this stage.

At this stage, the linker attempts to resolve all the (used) external
references in the programs, e.g. function prototypes and `extern'
declarations of variables. Consequently, this is the stage where it looks
for the actual code for the routines you use, both functions you prototype
in header files for use in several source files, and functions prototyped
in allegro.h which you are using. So this is the stage where you need to
link in any libraries you use, for example adding `-lalleg' to the linking
command line.

So, building your executable on the command line from sources, you give
the compiling commands:

gcc -o foo.o -c foo.c

for each source file (or leave out the `-o foo.o' and do them all at
once), and then the linking command:

gcc -o foobar.exe foo.o bar.o -lalleg

to link the object files, along with the library, into the executable
(replacing gcc with gxx for C++ programs *only* in the linking line; it
just sticks a few more libraries in automatically).

The `#include <allegro.h>' in a source file tells the compiler that these
routines will eventually be provided; the `-lalleg' on the linking command
line actually provides these routines.

I hope this helps. You don't need to worry about it in RHIDE; just put any
libraries in the menu I mentioned and use the appropriate #includes.

-- 
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford

What's the wizard's password for? (dunnet)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019