Author Topic: Compiling problems  (Read 8385 times)

Offline unknown_corpse

  • Single posting newcomer
  • *
  • Posts: 2
Compiling problems
« on: March 10, 2014, 08:42:39 am »
I have problem compiling C++ programs in Code Blocks. I created a project successfully & save 2 programs under that project, but when I compile the 2nd program it will always compile & run the first program. The second program is compiled only after I remove the 1st one from the project. How am I supposed to run other programs?
Also can u guys tell me about a good & easy compiler which can run my programs without hassle?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Compiling problems
« Reply #1 on: March 10, 2014, 06:27:40 pm »
1) http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F
2) Use one project per program, or use build targets:
    2.1) Right click on your project -> Properties -> Build Targets -> Add 
    2.2) Select the files for any program in "build target files" and a "output filename"
    2.3) After configuring all select your build target near the run/compile buttons
3) What os? platform independent? I personally prefer gcc...

greetings

Offline unknown_corpse

  • Single posting newcomer
  • *
  • Posts: 2
Re: Compiling problems
« Reply #2 on: March 12, 2014, 08:55:34 am »
Thank you so much for replying buddy. I tried the second method of building files that u had mentioned, I'm still facing the same problem. Only the first program runs no matter what program I try to compile & run. Guess I'll have to make a separate project for every file. Code block sucks! Isn't there an easy C++ compiler out there? I've tried Dev C++ & it hangs all the time. tried turbo C++ & it cannot even understand #include<iostream>. how am I supposed to learn C++?
My OS is Win 7

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Compiling problems
« Reply #3 on: March 12, 2014, 09:45:53 am »
Isn't there an easy C++ compiler out there?
Sorry but you're a bit confused what C::B is and isn't - http://wiki.codeblocks.org/index.php?title=FAQ-General#Q:_What_Code::Blocks_is_not.3F

about your problem: If you want to have multiple single file programs, just don't create projects, but open you file and hit build&run. A project can run a single program a time.
« Last Edit: March 12, 2014, 09:47:51 am by oBFusCATed »
(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 blauzahn

  • Almost regular
  • **
  • Posts: 179
Re: Compiling problems
« Reply #4 on: March 12, 2014, 07:24:37 pm »
If your programs consist of more than 1 source file each, make one project for each program. That is what they are for.
Apart from selecting files, a project contains all the helpful information, how to make a running binary,
exactly all those things you cry for. You can compile and run each project independently.

Your workspace shows the currently loaded projects (e.g. your 2 programs). If you double click
on a projectname in the workspace area, it becomes the active project, that is compiled and run
if you click on the buttons.

Other IDEs do excactly the same thing.

You can always call a C++ compiler without codeblocks from the commandline, like:
g++ -Wall -o myprog.exe myprog.cpp
That is about as easy as it can get.