Author Topic: Online info on using CodeBlocks  (Read 4184 times)

Offline papagym

  • Multiple posting newcomer
  • *
  • Posts: 41
Online info on using CodeBlocks
« on: July 19, 2015, 04:18:02 pm »
Where can I find online tutorials on using CB ? Particularly in a home school environment. Since CB is geared to a project oriented base (uses groups of files). I'm having a hard time using it while learn C++ at the same time.  What I'm looking for is how to run and save individual small programs like you might do in a class room.
What this all boils down to is I want to learn the basics before getting into projects.

I know how to use File->New->Empty File. to start a file.

Thanks for the input!


 
« Last Edit: July 19, 2015, 05:22:56 pm by James Guth »

Offline papagym

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Online info on using CodeBlocks
« Reply #1 on: July 19, 2015, 05:45:41 pm »
I found this site but it seem to have some old material in it.

It might help new users, it covers some basics like including C:B install, debugger, etc..

https://www3.ntu.edu.sg/home/ehchua/programming/howto/CodeBlocks_HowTo.html

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Online info on using CodeBlocks
« Reply #2 on: July 19, 2015, 06:19:37 pm »
c::b is build to use projects as smallest build unit  (not 100%, the smallest build unit are targets, but this does not chance the handling)

So the "normal" and easiest approach would be to create a new project for every executable you want to create (this would save you from a lot trouble with debugging for example)

A second approach, what needs a bit more work (and i would be to lazy, because it is to easy create new projects) is to use build targets:
1) Create a project
2) Add your first source file for your first program
3) build and run and test it

if you want to add a second executable to your project follow this steps:
4) File->New->Build Target
5) Coose "console" click "go"
6) Hit next on the intro page
7) Coose a name for your build target(program) and fill it in "Build target Name"
7a) if you want to debug your program enable the "Enable debugging symbols for this target" checkbox
8) "finish"
9) File-> New->File...
10) your appropriate file (c or c++)
11) next
12) choose c or c++
13) Fill the filename with full path (use the ... button)
14) Select the target you have created earlier in step 7)
15) finish

now you can use the second file for your second program.
to build it choose in the drop down menu near the build controls  in the toolbar your target name

if you get the error (i got this every time i add a new target, and this is a bug in c::b i should add to the bug tracker):
Code
multiple definition of `main'|
you have to check that only one of your main source files in enabled per target.
To do so:
1) Projects->Properties->Build Targets
2) Click on the right every target and check in the "Build target files" box in the right bottom corner that there is only one file selected per target.

As you can see using targets is a lot more complicated than creating a new project per executable...

There is also a third approach that only uses files, but i don't know the exact steps to reproduce it, and you also will get trouble when you start to using the debugger (we have 100 of posts in this forum of people who have problems because they are using only files and not projects or targets for they builds)


i hope this helps.
maybe i add this to the wiki

greetings

[edit] ps. Sourceforge is still down so i probably will forget to add or fix this bug...
« Last Edit: July 19, 2015, 06:21:47 pm by BlueHazzard »