Mail Archives: djgpp/1998/04/17/14:46:36
Jasper van Woudenberg wrote:
>
> Hi!
> I've tried this like the following:
>
> =========== VESA.H ===========
> #ifndef _VESA_H_
> #define _VESA_H_
>
> // prototypes, structures, vars, etc.
>
> #endif
>
> ========== VESA.CPP ==========
> #ifndef _VESA_CPP_
> #define _VESA_CPP_
>
> // function body's
>
> #endif
>
> ========== MAIN.CPP ==========
> include "vesa.h"
>
> void main()
> {
> // function call to function in VESA.CPP
> };
>
> I get an "undefined reference" in main() on the line which calls the
> function. The only way to solve this problem is to add the line '#include
> "vesa.h"' to vesa.cpp, and to include vesa.cpp in the main program, not
> vesa.h. Somehow i get the feeling this is not the way it is supposed to be
> done...
Hmm. TP has a "smart" mode of figuring out which units to make
when they are not there. So, if you have a main program main.pas that
USES Unit;
and a unit.pas, tp will automatically make unit.tpu from unit.pas, and
link all that together.
gcc and friends work differently. You can have mixed language projects
made
of C, FORTAN, and Pascal (Basic?).
So there is no automatism like that. The quick thing is to say
gxx -o main.exe main.cpp vesa.cpp
but that'll compile vesa.cpp everytime. So it's better to
gxx -c main.cpp /* compile main */
gxx -c vesa.cpp /* compile vesa */
gxx -o main.exe main.o vesa.o /* linking */
Even better is get used to Makefiles, or use an IDE like RHIDE.
>
> BTW: how can i convert an object file to a library?
>
ar -svr libfoo.a vesa.o
--
Ciao
Tom
*************************************************************
* Thomas Demmer *
* Lehrstuhl fuer Stroemungsmechanik *
* Ruhr-Uni-Bochum *
* Universitaetsstr. 150 *
* D-44780 Bochum *
* Tel: +49 234 700 6434 *
* Fax: +49 234 709 4162 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
*************************************************************
- Raw text -