Author Topic: compiling multiple .cpp files without a project  (Read 4340 times)

Offline michaelp

  • Single posting newcomer
  • *
  • Posts: 5
compiling multiple .cpp files without a project
« on: February 23, 2008, 07:23:57 pm »
First of all, hi Code::Blocks community.  :D My first post, needing to ask a question.
Been using Code::Blocks for about 3 months now, it's great. Was using Dev-Cpp before, then switched. Anyways, to my question.

A lot of the time in Code::Blocks, I have wanted to compile more than 1 .cpp file without having to make another project. Let's say I have main.cpp, and questions.cpp. How do I get those 2 files to compile together without having to create a Code::Blocks project?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: compiling multiple .cpp files without a project
« Reply #1 on: February 23, 2008, 08:18:47 pm »
You cannot do that. The IDE allows you to quickly compile one file into one program for your convenience, but for anything "serious", i.e. anything that takes several files, you need a project.

Well, actually you can get it to work if you are willing to write your own commandline and install that as "tool"... but I don't assume that is what you want.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

mariocup

  • Guest
Re: compiling multiple .cpp files without a project
« Reply #2 on: February 23, 2008, 10:44:21 pm »
Hi michaelp,

there is also another possibility. The plugin ShellExentsion Plugin (http://developer.berlios.de/projects/cbilplugin/) is a a file explorer within codeblocks. You can use so called shell extensions, that are put in the context menu. In your case you could define a shell extension e.g.

gcc $mpaths -o test.o

So if you select different files in the file explorer and choose the new context menu then $mpaths will be expanded with your selection.

See section "File Explorer and Shell Extension Plugin" in the online manual http://www.codeblocks.org/en-docs-wrapper for details.

Bye,

Mario


Offline michaelp

  • Single posting newcomer
  • *
  • Posts: 5
Re: compiling multiple .cpp files without a project
« Reply #3 on: February 24, 2008, 01:50:26 am »
@ mariocup: Seems like a lot of work. Not sure I'd want to do that. Thanks for the suggestion though.

@Thomas: Okay, just wanted to know if you could. Would be a nice feature if you could get that into Code::Blocks.  :D