Author Topic: Making project is so inconvenient, isn't it?  (Read 12964 times)

Offline thanhbuu

  • Multiple posting newcomer
  • *
  • Posts: 24
Making project is so inconvenient, isn't it?
« on: April 16, 2012, 06:53:07 pm »
Does anybody have solution to make a *.cpp file without making project (but there are still full Released and Debug mode) ? I can't find anyway to do this? :(

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Making project is so inconvenient, isn't it?
« Reply #1 on: April 16, 2012, 07:53:21 pm »
Does anybody have solution to make a *.cpp file without making project (but there are still full Released and Debug mode) ? I can't find anyway to do this? :(
Different compiler sets (i.e. for release and debug) REQUIRE a project.

A work-around would be to use the Tools(+) menu and macros to get compiler / debug commands for single files, but I strongly recommend you use a project.

Next time, also please don't start a meaningless poll?! ???
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 Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Making project is so inconvenient, isn't it?
« Reply #2 on: April 16, 2012, 08:23:42 pm »
Why should it be so inconvenient? It's a few clicks and three files in your project directory. It's much more convenient than trying to set debugger and linker options without a project. Note also, that some IDE's (like Open Watcom) will always require a project and will not allow you to pass with "just this file".

Simply put: having an IDE = creating projects. If you do not want a project, run the compiler from a command line.

Offline Freem

  • Almost regular
  • **
  • Posts: 219
Re: Making project is so inconvenient, isn't it?
« Reply #3 on: April 18, 2012, 11:12:50 pm »
There is the "compile file" function which can be used in cases of single junk file.
I already used it some day, if my memory is not bad, and it were able to generate the a.out file, and I were able to run it.

Obviously, I did not tried to debug it, because it was something with... maybe 20 lines?
A solution might be to create a dumb project, create file for functions you want to try, and fill the main with a simple switch.

For files with more than 50 lines, I think you should consider using projects, because that file could grow later when you will think about new features to add.

Offline codeur

  • Multiple posting newcomer
  • *
  • Posts: 113
    • Code::Blocks EDU-Portable
Re: Making project is so inconvenient, isn't it?
« Reply #4 on: April 19, 2012, 04:36:26 am »
For the unofficial education distribution only (Codeblocks-EP comes with bundled compiler and debugger, and supports C and C++ -using GCC- only) I am considering patching the source so as to enable automatic and transparent creation of a console project when there is  no open project and the user clicks on "Build" or "Build and run" while editing a file. Rank beginners tend to do this.

The project created would be a C++ or a C project based on the current file extension and the current file would be automatically added to it. Both release and debug targets would be created, all targets would be built. No project would be created when the extension is invalid.
Any issues with that?

I understand that this would not be of interest to the general distribution, but would be useful for students in their first programming unit in the version used in the education world .

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Making project is so inconvenient, isn't it?
« Reply #5 on: April 19, 2012, 08:22:54 am »
Any issues with that?
No, as long as you provide a patch.

If you make it an option (i.e. no silent magic, but with user interaction), it might even make it into trunk. 8)
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 p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Making project is so inconvenient, isn't it?
« Reply #6 on: April 19, 2012, 04:00:19 pm »
I use the single file often. I do not like to create a new project for a single file, i debug from command line. Instead of creating new projects, a better option would be to use a global project bound to extension.
I am aware that the realization of every whim is impossible, so I wrote a script which automatically generates project. It is Windows only, and uses gawk. gawk is included in Cygwin, so if u have it installed u have gawk too. project_template.cbp.txt have to be located in same folder as script file. First rename createProject.bat.txt to createProject.bat. Now all you have to do is drag'n drop main file on createProject.bat file. You can change template as you wish ( dont change projectName and fileExt).
Maybe later i'll write bash version. Enjoy.
« Last Edit: April 19, 2012, 04:16:50 pm by p2rkw »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Making project is so inconvenient, isn't it?
« Reply #7 on: April 20, 2012, 10:46:50 am »
For the unofficial education distribution only (Codeblocks-EP comes with bundled compiler and debugger, and supports C and C++ -using GCC- only) I am considering patching the source so as to enable automatic and transparent creation of a console project when there is  no open project and the user clicks on "Build" or "Build and run" while editing a file. Rank beginners tend to do this.
Start a cpp file, hit a button, and get an empty project with just that file in it? I would use that every day... those "new project wizards" annoy the hell out of me.  :D
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Making project is so inconvenient, isn't it?
« Reply #8 on: April 20, 2012, 05:11:35 pm »
Start a cpp file, hit a button, and get an empty project with just that file in it? I would use that every day... those "new project wizards" annoy the hell out of me.  :D
You can do an erm... simple wizard to achieve that. 8)
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 codeur

  • Multiple posting newcomer
  • *
  • Posts: 113
    • Code::Blocks EDU-Portable
Re: Making project is so inconvenient, isn't it?
« Reply #9 on: April 21, 2012, 01:08:13 am »
Start a cpp file, hit a button, and get an empty project with just that file in it? I would use that every day... those "new project wizards" annoy the hell out of me.  :D
This encourages me to think that doing it is worthwhile. Perhaps providing a "Build current file" menu entry just below "Compile current file" is a good way to handle this on the interface. What do you think?
It's now definitely planned for the next version of Codeblocks-EP. At this stage only Windows is supported, but a Linux version of Codeblocks-EP will come later. For this feature I'll test and provide a patch for both Linux and Windows so it can be added to trunk if you guys think it's worth doing.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Making project is so inconvenient, isn't it?
« Reply #10 on: April 21, 2012, 08:17:30 am »
codeur: Why would you add another similar option? Why wouldn't you modify the existing one?
(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 codeur

  • Multiple posting newcomer
  • *
  • Posts: 113
    • Code::Blocks EDU-Portable
Re: Making project is so inconvenient, isn't it?
« Reply #11 on: April 21, 2012, 08:46:03 am »
@ oBFusCATed:
This is what I currently have in mind:
- "Compile current file" only compiles a file whether it is in a multiple file project or not. It makes no attempt at linking anything. That's essential and should remain. If there is a demand, I could in addition make this option create a project as below before compiling if the current file is not already in a project (presenting this as a yes/no option before creating the project).
- "Build current file" would offer to attempt to compile and link a file if it is the only file in a project (same as "Build in this case) or if it is not in a project. If the file is not in a project, a default empty (or console) project would be automatically created. The file would become the only file in the project before building. If the file is already in a multi-file project the option would not be available ("Build" is available for this).

At this stage I am listening to any alternative you want to suggest for the interface.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Making project is so inconvenient, isn't it?
« Reply #12 on: April 21, 2012, 01:34:07 pm »
- "Build current file" would offer to attempt to compile and link a file if it is the only file in a project (same as "Build in this case) or if it is not in a project.
If we do this I see one issue: We will have tons of newbies reporting "undefined references" because they didn't understand that it will need more than linking to compile e.g. a hello world OpenGL console application, even if it is in one file. Note that a lot people start with code that requires SDK's (include files / libraries) you don't now when provided a single compilation unit, only!

That was basically a driver for the wizards: They at least create a project that is fully defined and has all options/libs so you can compile it successfully.

So - if you offer to build a file without a project please always present a warning in bold, red, font size "huge" that this trial most likely will fail due to missing include files and/or undefined references and that the only way out is through a project. You may make this an AnnoyingDialog, if you want to, so users can disable it.

Another option would be to scan the compiler's/linker's response for such kind of errors in general and in case there are, always present this message box.

Otherwise our forum will be flooded. ::)
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: 13413
    • Travis build status
Re: Making project is so inconvenient, isn't it?
« Reply #13 on: April 21, 2012, 01:53:48 pm »
codeur:
I still don't see a reason to have two options make it as one and make it smart.
Having two options looking the same will be quite confusing.
(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 codeur

  • Multiple posting newcomer
  • *
  • Posts: 113
    • Code::Blocks EDU-Portable
Re: Making project is so inconvenient, isn't it?
« Reply #14 on: April 21, 2012, 02:16:19 pm »
codeur:
... make it as one and make it smart.

Please explain. I do not understand how to combine those two options as one.
One compiles only, no matter what. The other compiles and if successful attempts to link into an executable. The user normally picks the option depending on where they are in the development cycle. I cannot see any way for an IDE to guess what a user wants there.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Making project is so inconvenient, isn't it?
« Reply #15 on: April 21, 2012, 02:18:32 pm »
If you have a project you are in compile only mode. If you don't you're in compile-and-link mode.
(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 codeur

  • Multiple posting newcomer
  • *
  • Posts: 113
    • Code::Blocks EDU-Portable
Re: Making project is so inconvenient, isn't it?
« Reply #16 on: April 21, 2012, 02:59:37 pm »
... If we do this I see one issue: We will have tons of newbies reporting "undefined references" because they didn't understand that it will need more than linking to compile e.g. a hello world OpenGL console application...

Morten, we have different users in mind:
I have the educational environment in mind (the Codeblocks-EP target audience) where this problem does not occur. There beginners usually write single file text based programs for several weeks before being guided by their teachers to write their first program using a simple graphics API. At that time they are introduced to the mysteries of APIs, SDKs and 3rd party libraries.

You are rather thinking of the self-learner who copies from the web into a new empty file some game code written for OpenGL or produced last century for turbo C++, clicks on "Build and run" and is angry at all these crappy messages that pop up onto the screen.
I have no idea what could be done in this case.

This automatic single-file default project is without doubt worth having in an educational distribution, but I agree that it may increase the self-learner's problems in the standard distribution.
« Last Edit: April 21, 2012, 03:16:47 pm by codeur »

Offline codeur

  • Multiple posting newcomer
  • *
  • Posts: 113
    • Code::Blocks EDU-Portable
Re: Making project is so inconvenient, isn't it?
« Reply #17 on: April 21, 2012, 03:12:27 pm »
If you have a project you are in compile only mode. If you don't you're in compile-and-link mode.

It makes sense now.
However I would rather: When you select "Compile current file": if you have a project you are in compile only mode. If you don't, a new default project is created, also followed by compile only mode. If you want to also link, just press "Build" (the existing "Build" button or menu entry) after successful compilation.

Much better! Thanks for that.

The behaviour (when there is no project) can be enabled or not in a Settings option as suggested earlier by Morten. This would cancel his misgivings regarding that feature in trunk.
« Last Edit: April 21, 2012, 03:27:32 pm by codeur »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Making project is so inconvenient, isn't it?
« Reply #18 on: April 21, 2012, 03:34:34 pm »
The behaviour (when there is no project) can be enabled or not in a Settings option as suggested earlier by Morten. This would cancel his misgivings regarding that feature in trunk.
Why, just implement his suggestions.
Adding options to delegate to the user every little decision you have to make is just plain wrong.
Apple (I'm not their fan) are in fact right in this regard, the software just had to work...
(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 codeur

  • Multiple posting newcomer
  • *
  • Posts: 113
    • Code::Blocks EDU-Portable
Re: Making project is so inconvenient, isn't it?
« Reply #19 on: April 21, 2012, 03:55:07 pm »
. . .
Why, just implement his suggestions.
Adding options to delegate to the user every little decision you have to make is just plain wrong.
Apple (I'm not their fan) are in fact right in this regard, the software just had to work...

Just a sec... In the Codeblocks-EP distribution I am going to implement the single file default project creation, whatever happens in trunk. I don't need to have it as a settings option in that educational distribution.

In trunk, whether you use the patch and make it a settings option or not in the end depends on you, Morten and the rest of the team.
I just think that Morten's worries regarding self-learners are valid.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Making project is so inconvenient, isn't it?
« Reply #20 on: April 21, 2012, 04:17:27 pm »
I just think that Morten's worries regarding self-learners are valid.
It would make it easier for us if it the patch complete in the first place, I guess that's why oBFusCATed said:
Why, just implement his suggestions.
It wouldn't hurt educational (guided) newbies anyways to see such a warning. In fact - is could be even helpful if you didn't listen to your teacher... ;-)
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 carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Making project is so inconvenient, isn't it?
« Reply #21 on: April 24, 2012, 08:59:23 pm »
I noticed this as well, and this is one of the reasons I kept sticking to Dev-C++ for so long. It's nice to have many options when you need them: targets, releases, folder to separate different kinds of files... Great for large projects. But when you don't need them, it's simply too much.

I do a lot of experimenting and need to create MANY small test projects, with maybe 3 or 4 files. In those cases I don't need to have releases and I definitely don't want C::B to create 4 subfolders in every project.

Yes, I do know that you can disable all this on C::B, but it gets tiring to do it every time. I would rather have a simplified flavour of the "empty project" that works the opposite way: Give me all settings at the simplest by default and let me activate extras as needed, instead of making me think the more complex configurations when I'm just trying to keep it simple.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Making project is so inconvenient, isn't it?
« Reply #22 on: April 24, 2012, 09:15:04 pm »
Yes, I do know that you can disable all this on C::B, but it gets tiring to do it every time. I would rather have a simplified flavour of the "empty project" that works the opposite way: Give me all settings at the simplest by default and let me activate extras as needed, instead of making me think the more complex configurations when I'm just trying to keep it simple.
You can write your own project template or you can modify an existing one. They are simple squirrel scripts. To see their code - right click on a template -> edit script/source
(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 carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Making project is so inconvenient, isn't it?
« Reply #23 on: April 24, 2012, 11:04:37 pm »
Yeah, I was able to access the script so that should work. I can give it a try, however I'm not familiar with squirrel or C::B scripting... I hope it's not too lengthy to learn

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Making project is so inconvenient, isn't it?
« Reply #24 on: April 25, 2012, 07:34:54 pm »
You can also create a project skeleton, that fits your needs and save it as user template ("File -> Save project as template" and "File -> New -> From template ...").

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Making project is so inconvenient, isn't it?
« Reply #25 on: April 25, 2012, 11:27:11 pm »
Thanks for the tip. I did try it before, but I was fooled by an alert window. It says that "the folder already contains files and they may be overwritten", and I interpreted that to mean that when using a template the projects create from it always kept the same file names that the template had... My mistake here.