I just started using Code::Blocks and really am not too familiar with C++ anyway, but here's my problem. I can add a new cpp file to my project, give it a header, and include any additional source outside my main. But only with one extra cpp file. When I try to add a second file, compilation always fails.
This happens whether I'm doing a windows app or a console app, whether one extra file is for all my openGL code and the other for my SDL code, or simply a couple of dummy classes (File1 Class1 File2 Class2) just to find out if I can actually compile three source files together or not. I couldn't figure out why my very generic SDL code was failing until I realized it was the third file (two extra above main.cpp).
I can actually add a third source file, and it will compile. I can even #include the header file for that third file. But the moment I declare any classes or functions in the header, or define any functions in the source file, I get a compilation error, and it is random. It may be "error compiling main.o" or error compiling "first_extra_source.o", it just depends on whether I added code to the first or second extra source files (respectively). None of the code is repeated across (multiple declarations) and all headers are guarded. It doesn't matter if I "remove from project" the first extra file or the second extra file, when one is deleted, the project compiles.
I've made sure to check "Debug, Release" checkboxes, as that is the only general solution I've found. Another general solution I found was to directly #include "secondsourcefile.cpp" This did not seem like a great idea, but i tried it anyway and it did not work. Surely there is just some setting I missed... What is that setting? As I said, I am unfamiliar with c++ so it could be that I'm not getting something inherent to the process of creating 'large' projects. According to the first two pages of google, multiple files in CodeBlocks should be automatic now, but it may not be. Do I need to figure out how to do this manually?
Remember, I've had several projects work with one additional file, no questions asked, with no change to my method of setting up a new project, and I've tried to do this four different ways just to finally ensure that it is not bad code (just in case).
Any help would be most appreciated. I finally got my SDL libraries working with borland and have made it through Nehe tutorial 5 with the addition of a joystick. I want to move on to something fun, but I really don't want 12,000 lines of code in one file. I've made the mistake before and I don't ever want to again
Pertinent details:
Code::Blocks 8.02
Borland BCC55 Free Command Line
Windows 7