Author Topic: Compiling and linking three files  (Read 4448 times)

Offline buffbill

  • Single posting newcomer
  • *
  • Posts: 5
Compiling and linking three files
« 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.
« Last Edit: March 19, 2013, 04:48:49 am by buffbill »

Offline Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Compiling and linking three files
« Reply #1 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.

Offline buffbill

  • Single posting newcomer
  • *
  • Posts: 5
Re: Compiling and linking three files
« Reply #2 on: March 20, 2013, 02:56:08 am »
Thanks Radek ... will let you know how I go.

Offline buffbill

  • Single posting newcomer
  • *
  • Posts: 5
Re: Compiling and linking three files
« Reply #3 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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Compiling and linking three files
« Reply #4 on: March 20, 2013, 05:49:02 am »
Reinstall and make sure you enable the contrib plugins and it particular the scripted wizard plugin.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline buffbill

  • Single posting newcomer
  • *
  • Posts: 5
Re: Compiling and linking three files
« Reply #5 on: March 22, 2013, 06:35:47 am »
Thanks oBFusCATed ... think I'm sorted now.