Author Topic: Why doesn't CodeBlocks turn on debugging when I wanna compile a single file?  (Read 7821 times)

Offline Oleg

  • Single posting newcomer
  • *
  • Posts: 3
Why doesn't CodeBlocks turn on debugging when I wanna compile a single file? I see that the debugging feature is turned on only when working on a project, but not on a single file. Let's assume I wanna compile and run just a single C++ file. How do I turn on the debugging feature in this case? (Besides the obvious -g option, but you know what I mean).

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
How do I turn on the debugging feature in this case?
This is not possible / implemented. You'll need a project for the debugger. There are many reasons for this. One is that the debugger needs a path configuration available only through the project settings.

Single file support is limited to compilation, only. Sorry.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Oleg

  • Single posting newcomer
  • *
  • Posts: 3
 Okay, when I try to add my file to a newly created project, some mess happens and codeblocks doesn't wanna build, run, or debug the file. Also, for some reason, the project created its own file (main.cpp) and, of course, I don't really need it. Please tell me what to do to successfully add my single file to a project without creating a mess, so I could debug it.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Please tell me what to do to successfully add my single file to a project without creating a mess, so I could debug it.
- Create an empty project (not a console application or alike)
- Add the file to the project.

For the very IDE basics consult the documentation of Code::Blocks.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Oleg

  • Single posting newcomer
  • *
  • Posts: 3
When I try to add the file to an empty project, it asks me to overwrite it. I don't know what I am doing wrong.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
How many times have people asked for this specific feature?

Morrrrrten: you say that there are many reasons. Don't you think it would be nice to make a list of those reasons and classify them somehow? It could be a good starting point (a guide if you prefer) to implement it someday. It would be good to put that list somewhere else, like the wiki, so it does not get lost so easily.

BTW: Hi, long time no sprechen :)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
How many times have people asked for this specific feature?
I know, but you should also guess that it will be quite complex and blew the code a lot.

I personally follow a different strategy: Do not allow single file compilation (without a project) at all and probably have a one-click project setup. But I am aware that there are objections.

In addition: As you know, obfuscated works hard on a new debugger framework. Probably it's better to notify him that there would be such "need" by some people. I guess he can estimate quite well the additional effort needed for his refactoring work.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
I personally follow a different strategy: Do not allow single file compilation (without a project) at all and probably have a one-click project setup. But I am aware that there are objections.
+1

In addition: As you know, obfuscated works hard on a new debugger framework. Probably it's better to notify him that there would be such "need" by some people. I guess he can estimate quite well the additional effort needed for his refactoring work.
Not sure if this is hard, can I get the path to the resulting executable easily?
(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 thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Single file compilation was the worst ever feature to be included. Not so much because it is bad per se, but because it is causing wrong expectations and this is the source of a million requests.
Such as, people don't get it that you can't debug a single file without a project. Of course, at first sight there seems to be no obvious reason why you shouldn't be able to.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
I personally follow a different strategy: Do not allow single file compilation (without a project) at all...
-1

Dear forum,


What a'butt having dummy projects by default? Something similar to what happens in Delphi. You just say: I want a new Form, and voilĂ ! There is a dummy project, a dummy .pas file and a dummy .dfm file. You do not even need to save any of them in order to test and debug anything you want. If you like it, you can save it anywhere you want afterwards, but if you do not, it is almost like if nothing had happened (there may be a .exe created somewhere which is most likely to be overwritten by the next 'dummy' test).

Morrrrrrrrrrrten: is that more or less, kind of, approximately, nearly what you mean by "one-click project setup"?

In any case, that also has a drawback: C::B's default behavior is to "save before compiling". Of course you need to save the file somewhere to feed the hungry compiler easily, let it chew the file for a while and wait until it spits that precious object file. It would be lovely if for such a 'dummy' project a "save to temporary file and do not bother the user" could be implemented.

Another nice thing of such an implementation is that you can easily add extra dummy files to the dummy project, yet you do not need to save them in order to compile them all, link them together and run (and even debug) the resulting executable.

Waiting for you complaints.

mvg,

Me.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Waiting for you complaints.
I could imagine having everything saved into the systems temp folder for the one-click-project and remove it on C::B destruction and/or creating another one-click-project. Surely the user would be informed that this is going to be a temporary project for "playing".

However, if I have the choice between anything like this and removing single file compilation ability I'd clearly choose the second option.

BTW: Not to forget: As a non-supporter I am surely not the one that is going to implement this.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ