Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: buffbill on March 19, 2013, 04:37:02 am

Title: Compiling and linking three files
Post by: buffbill on March 19, 2013, 04:37:02 am
I'm following a number of books learning C++ using C::B v 10.05 with OS MS/XP.
My C++ Prima now requires that three files are employed rather than just a single *.cpp file.
One file is a " header" containing the class information starting with #ifndef and ending with #endif.
The other two files are .cpp files one for class methods and one for main() and its headers.
My problem is to determine how to compile and link the 3 files. My other apparently unrelated problem is that the debugging comand icons are always grayed out when i am using C::B.
Any help would be appreciated.
Title: Re: Compiling and linking three files
Post by: Radek on March 19, 2013, 05:48:43 am
That's why you have an IDE like Code Blocks ;) It allows you to create projects consisting from more than one source file. Therefore:

(1) Create a new project.
(2) Add both source files to the project. You can also add the header (recommended, the header will be at hand when you work on the project).
(3) In the Build Options - Compiler, tell the compiler where is your header.
(4) In the Build Options - Linker, inform the linker on additional libraries (if any).
(5) Save the project.
(6) Compile.
(7) Run or Debug.
Title: Re: Compiling and linking three files
Post by: buffbill on March 20, 2013, 02:56:08 am
Thanks Radek ... will let you know how I go.
Title: Re: Compiling and linking three files
Post by: buffbill on March 20, 2013, 03:35:49 am
I don't seem to be able to name a project by clicking on "Create a new Project" on the opening page of C::B. The drop down box has no templates so I can't select one.
The Project/Build Options is grayed out. Any suggestion?
Title: Re: Compiling and linking three files
Post by: oBFusCATed on March 20, 2013, 05:49:02 am
Reinstall and make sure you enable the contrib plugins and it particular the scripted wizard plugin.
Title: Re: Compiling and linking three files
Post by: buffbill on March 22, 2013, 06:35:47 am
Thanks oBFusCATed ... think I'm sorted now.