Mail Archives: djgpp/1998/04/17/17:16:47
-----Ursprüngliche Nachricht-----
Von: Jasper van Woudenberg <p DOT v DOT woudenberg AT consunet DOT nl>
Newsgroups: comp.os.msdos.djgpp
Datum: Freitag, 17. April 1998 17:45
Betreff: Re: Pascal units in c++
>
>I've tried this like the following:
>
>=========== VESA.H ===========
>#ifndef _VESA_H_
>#define _VESA_H_
>
>// prototypes, structures, vars, etc.
>
>#endif
>
thats it
>========== VESA.CPP ==========
>#ifndef _VESA_CPP_
>#define _VESA_CPP_
you dont need the tow lines above,
but its good to include the header,
like #include "vesa.h"
>
>// 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... BTW: how can i convert an object file to a library?
if you defined the prototypes in the right way, you dont get an "undefined
reference". I think you must have made a spelling mistake when
defining the prototypes.
but you must tell the linker which programs (.o files) he should linkt
together
to an .exe, otherwise the linker will give an error
I personally use Rhide to do this, it does all the work for you, just like
the
pascal-compiler.
Elias Pschernig
- Raw text -