My project has become complex enough that it requires many separate source files to be compiled and linked together. I know that I can add source files to the project, but does DevC++ automatically link their object files together when it's compiled with Gcc? I've also had troubles with include files. Several of the source files include the same headers, and when I build them (with the above assumption about linking), the compiler barfs out "multiple declaration" errors. Is their any suggestions around this?
Dev-C++ will link all objects created from project files.
Encapsulate the contents of your headers with:
#ifndef HEADER_ID__ #define HEADER_ID__ // content here #endif
To prevent redefinition.
The thing that's confusing me is that I have done that. Each header has it's own definition for preventing that, but it still barfs these errors. I really don't get it.
Are you sure you've gotten every header? Are you sure the HEADER_ID__ is being defined?
Give us the error messages so that we may interperet them for ourselves.
Oh darnit I'm a moron. I haven't checked this yet, but I know what happened. What I was doing before was "#include"'ing the .cpp files rather than compile+link them (I know it sounds dumb), and I forgot to delete those include statements so the .cpp files were essentially begin compiled and linked twice.
Other IDEs have one button for compiling and another for making. When compiling, only the active source file gets compile, not linked. When making, all files are compiled and linked. This is a convenient way to check the syntax on one file. (I know, another is to write good code in the first place:P) Dev-C++ has only this compile command that performs a total make of the whole project, which is time consuming.
The new versions of Dev-C++ use makefiles and your choice of fast/inaccurate or slow/accurate dependency generation, so only the most recently changed files get recompiled.