Author Topic: How to run / debug a single file (without a project)  (Read 15736 times)

danizobin

  • Guest
How to run / debug a single file (without a project)
« on: March 16, 2008, 12:26:18 am »
BS"D

When I just open a file, without a project context, almost all the options under "build", "debug" are graid out.

Any ideas?

Thanks,
Dani

Offline DrewBoo

  • Multiple posting newcomer
  • *
  • Posts: 110
Re: How to run / debug a single file (without a project)
« Reply #1 on: March 16, 2008, 01:03:43 am »
Aside from holding a bunch of files together, a project contains important information about what it means to "build" that project.  Things like what the built program should be named, where it should go, where header files can be found, whether it needs debugging info and what optimization level it should undergo.

So the answer I think you're looking for is that one would typically create a project, even if it's just for one file.  That's the norm for all IDEs I've used, anyway.

If an IDE you've used has a feature to "build and run whatever file is open", please let this forum know about it.  It could become a feature.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: How to run / debug a single file (without a project)
« Reply #2 on: March 16, 2008, 01:16:30 am »
Building using the default options that you can set in your compiler preferences can be done with "Compile current file", and once it is built, the program can be run using "Run" too.

Debugging (and several other things) does not work without a project. No, this won't be added.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

danizobin

  • Guest
Re: How to run / debug a single file (without a project)
« Reply #3 on: March 16, 2008, 03:36:59 am »
Thanks,

Anjuta can compile, run & (i think) debug single files.
Very convenient for scholar environments when programs are sporadic and short.

Dani

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: How to run / debug a single file (without a project)
« Reply #4 on: March 16, 2008, 05:19:10 am »
Personally, i always have a project named 'quicktests' that use for throw-away 1 file programs.  Just select-all, delete, type new program (or copy/paste).

Offline neuronet

  • Single posting newcomer
  • *
  • Posts: 4
Re: How to run / debug a single file (without a project)
« Reply #5 on: February 18, 2018, 03:11:01 pm »
I just use the terminal for such one-offs. I'm in linux, so:

Code
g++ -o executable_name the_file.cpp
./executable_name

And voila! But, yeah, once you use code::blocks you have incurred an overhead and why fight the framework? I just make a folder for the simple little one-off scripts, and then in the same folder I will also start projects. It's easy to tell them apart.