The way that most compilers work is that they will compile each individual
cpp file into an object file (.o). All these object files are then passed
through a linker program which connects then together, mainly making the
function calls in one cpp file point to the relevant function in another
cpp. The linker will output the executable code (.exe). You shouldn't ever
need to include a .cpp file into any other cpp file or header, you only
include the header (.h) file if you happen to need a function from one of
the other cpp's (or libraries). In fact it is considered bad practice to
include a cpp into another.
This is only a quick explanation of the process. Before IDE's you would have
edited all the code in a text editor of some kind and then typed in the
commands like gcc MyCPP.cpp, link MyCPP.o etc... (that may be wrong)
To produce a program in Dev-C++ at the moment you need to put all the CPP
files in to a project, making sure that if any one cpp uses a function from
another to #include the header of that cpp at the top. Then click on compile
and the rest of the work is done for you. If it's successful then you will
be given the option of executing it, otherwise you will be presented with a
list of errors, that you can double click on to take you to the relevant
section (most of the time). If you are editing the headers aswell then it is
safe to add them to the project also, as one of the faults with Dev-CPP at
the moment is that it won't let you edit a file that isn't part of the
project without closing the project.
Remember that most linker errors occur because the .o or .a (library) file
wasn't given to the linker program. Undefined reference or first occurance
type errors are usualy because you either failed to declare a function
prototype or variable, didn't include the relevant header, or you mistyped a
name somewhere.
Hope this helps.
Regards, Jason.
----- Original Message -----
From: "carlos GARCÍA DEL MONTE" <cg...@wo...>
To: <dev...@li...>
Sent: Wednesday, December 05, 2001 6:35 PM
Subject: [Dev-C++] Re:I need a basic [...] compiling classes
>
>
> Daniel Anderson escribió:
>
> > Hola,
> > I am trying to find out how to properly compile a program when there are
> > user-written classes involved. I have 3 files- a header file
(dynarray.h),
> > an implementation file (dynarray.cpp), and my main program. Using Dev
C++,
> > what is the proper method and order to correctly compile? This is my
first
> > program where I have had to implement a class, and I can't find
information
> > on how to use Dev C++ to do this. Thanks!
> >
> > Danny
> >
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> Include them in a project, that's all. And #include "file.h" in
> file.cpp, and
> #include "file.h"
> #include "file.cpp" in your main.cpp.
> But if that doesn't work (I think you ask because that doesn't work, but
> I say
> it, so if not, you know now), I imagine you would must write all the
> code in
> the same file...
> Well, but I am a so unexperienced about programming, perhaps there would
> be
> other solutions... Perhaps writing a makefile? (I have no idea about
> makefiles)... Or perhaps your copy of the program is a wrong one
> (perhaps it
> got downloaded badly) and you'll need download it again. (?)
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|