Author Topic: Can C::B Compile one by one?  (Read 3256 times)

mdyty,

  • Guest
Can C::B Compile one by one?
« on: August 29, 2016, 10:08:04 am »
Hello i am new at Code Blocks, i have a problem.

If you ever try dev c++, you can have some tab (look at the picture) and compile the tab what you open.



the open tab is jcmes.cpp so jcmes is compiled

because if i am make 2 c++ file, and i want to compile the second one it says " multiple definition of main"

please help me.
Iam sorry if my english is bad hehe :D

Offline CJS

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Can C::B Compile one by one?
« Reply #1 on: August 29, 2016, 11:03:00 am »
This is for Code::Blocks 16.01 with the GNU GCC compiler (although I think it's been available for earlier versions): If you have a source code file open in Code::Blocks, you can compile it by first selecting the open file / tab, then go to the menu and select Build / Compile current file, which has the keyboard shortcut: Ctrl + Shift + F9.

(It would be nice if this was available in Code::Blocks as a right click menu option on the open file tab itself.)

Results will be shown on the "Build messages" log, make sure you have it selected.  If the file has already been compiled, nothing much will happen apart from the display of "||=== Build file: Debug in <project name> (compiler: GNU GCC Compiler) ===|".

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Can C::B Compile one by one?
« Reply #2 on: August 29, 2016, 02:00:59 pm »
NOTE: This is not the intended way to use codeblocks...
If you want to build multiple different programs (multiple main functions) you should create multiple projects, or at least create multiple targets (for every executable one target)

NOTE2: You can also build a single file on the project tree if you right click on the file..