Author Topic: Making project is so inconvenient, isn't it?  (Read 12961 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.