Author Topic: Compile single file  (Read 25696 times)

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Compile single file
« on: July 14, 2005, 11:07:44 pm »
Well, I thought Code::Blocks had this but it seems not.

I hadn't tried it before till today and I found it didn't work!

To be more clear I mean that if I open/create a single file and want to compile it Code::Blocks won't allow me to do that, I must create a project first!

Is it supposed to work this way? Could it be changed/implemeted ~easily?

darklordsatan

  • Guest
Compile single file
« Reply #1 on: July 14, 2005, 11:25:58 pm »
IIRC, VC++ 6.0 forced you to create a new workspace or you couldnt compile new files

I guess so far its supossed to work this way, why not submitting a feature request?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Compile single file
« Reply #2 on: July 14, 2005, 11:29:06 pm »
Quote from: darklordsatan
I guess so far its supossed to work this way, why not submitting a feature request?

Don't bother, there is one already (and many duplicates deleted) :)

Yiannis.
Be patient!
This bug will be fixed soon...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Compile single file
« Reply #3 on: July 14, 2005, 11:57:56 pm »
And I predict there will be many more, too! :-P

So, what should we do to implement this RFE?

darklordsatan

  • Guest
Compile single file
« Reply #4 on: July 15, 2005, 04:25:42 am »
Quote from: rickg22
And I predict there will be many more, too! :-P

So, what should we do to implement this RFE?


The start point would be to enable the compiler options in the compile menu when theres an opened file, but not opened project

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Compile single file
« Reply #5 on: July 15, 2005, 07:48:51 am »
i don't see any sense in compiling a file without a project - what settings should be used as defaults ?

the only thing i can imagine, is to pop up a dialog, which presents you a list
of predefined and user defined template projects and asks to specify one of these to use.

BUT the least time i usually have to spend for a new project is setting up a project - can't really see any major effort.

kjliew

  • Guest
Compile single file
« Reply #6 on: July 15, 2005, 08:12:59 am »
While I am not against in implementing this feature, compiling a mere single file should not be bothered by modern IDE. The reason that we need an IDE is because we are dealing with real world development projects that have the source files organized in tree, and potentially the need to link with 3rd party SDK/Library. No such projects will ever be in single-file content. It's also a poor programming practice to lump everything into single file. In fact, if anyone really lump everything into one .cpp and .h files, he doesn't really need an IDE since everything can be referenced. He doesn't even need things such as code completion, class/struct reference/lookup etc. which usually help in quickly locating useful declarations.

Single file project is overkilled in using an IDE. I would rather use "gcc -o Hello Hello.cpp" to build and use Vim for editing.

darklordsatan

  • Guest
Compile single file
« Reply #7 on: July 15, 2005, 08:17:43 am »
Quote from: tiwag
i don't see any sense in compiling a file without a project


Sometimes is handy, when you have a small piece of code and wanna compile it right away without the IDE asking you to create a project file... And what if you have a lot of small code snippets and need to compile them...
There are elaborate solutions, like creating the project, then adding a file, and copy+paste 24/7 for all the snippets, in the same file, but this is just tiring...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Compile single file
« Reply #8 on: July 15, 2005, 08:33:09 am »
Stan's right. If we want newbies to use the IDE, we need to give them the tools they need to simplify learning.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Compile single file
« Reply #9 on: July 15, 2005, 10:16:38 am »
Quote from: darklordsatan
... And what if you have a lot of small code snippets and need to compile them...


i use a Test-Project where i add new modules with the code to test.
sometimes, ehen the code to test has it's own main() function, i add a new target to the Test-project.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Compile single file
« Reply #10 on: July 15, 2005, 10:18:58 am »
Quote from: kjliew
...Single file project is overkilled in using an IDE. I would rather use "gcc -o Hello Hello.cpp" to build ...


that's my opinion too

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Compile single file
« Reply #11 on: July 15, 2005, 10:47:11 am »
Well, that's something I liked of Dev-C++, and believe me, I've made a lot of little tests, well 133 non-wxWidgets related tests, and it's really handy to be able to compile them and run them from the IDE.

Code::Blocks has showed to be pretty nice to use with projects, workspaces and different targets, but why not to give the simple functionality too? I'm pretty sure it'll be nice for newbies and, once again, handy.

Offline squizzz

  • Almost regular
  • **
  • Posts: 132
Compile single file
« Reply #12 on: July 15, 2005, 10:48:58 am »
It sounds like it's useless option, BUT... it gives a nice feeling that IDE is lightweight and ready to go right after it starts. I agree that it's mostly valuable for newbies, who usually try dozen of book examples without even knowing what workspace/project/target is. Sometimes I do also find this useful, when I quickly have to try if some snippet works - guess what am I doing then? - yup, launching my old fellow Dev-C++ :)
Well, the fact that Dev-C++ does have it is IMHO good enough itself to have it too. Which IDE will newbies find easier to use (at least as an initial feeling) if they can't simply hit compile button and have their "hello world" program running?

I think it would be nice to have "Compile file" option, that compiles source file as a simple console application with default compiler, and eventually have the possibility to upgrade it to a project (*.cbp with this very file already included). Even if I'm not going to use it often. :)
this space is for rent

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Compile single file
« Reply #13 on: July 15, 2005, 10:51:51 am »
I agree that this functionality should be included. I think that we should make Code::Blocks usefull for a wide range of users including "example newbies" :lol:
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Compile single file
« Reply #14 on: July 15, 2005, 12:21:06 pm »
i think the better approach is to give newbies the information WHAT they are doing actually
and not to make it as easy as possible to compile a few code-fragments without tinking about
what they're doing. In long term this strategy leads to a lot of "Bug reports" about
* cannot link, unresolved external xyz ,...
You just have to look, what's happening in the devcpp forums, most of the questions there
could be answered by themselves, if they had a few lines of documentation, how the
devcpp is working. Even more worse is the situation with wx-devcpp.
They glued together MingW and wxWidgets libraries and Includefiles in a completely
brainless way - obviously someone without knowledge of the power of several built-versions
of wxWidgets has done this - what leads to a terrible situation especially for "neewbies", if they
eventually want to try compiling some wx-widgets-supplied samples.
They can't then rely on the wxWidgets documentation and for all the devcpp's - with or without wx -
doesn't exist any relyable documentation. That is really confusing for newbies.

My opinion is, in general "newbies" are willing to learn - we have to give them proper documentation.

this is opposed to : "Do it like it works with our sample projects - or do it not ... live or die, basta"

darklordsatan

  • Guest
Compile single file
« Reply #15 on: July 15, 2005, 12:32:39 pm »
Well tiwag, you really have it going on there. But notice we are not talking about here in regards of a newbie specific feature, but something that could help many advanced users too.
I agree with you when you say you dont like it... well I do and I think many people do as well.

Perhaps what you say about docs.. well thats unfortunately the way most open source apps are nowadays - with a lack of documentation. Probably someone should take care of starting documenting c::b deeply... that should do it for a long-term project. And this single-file-compile should definitely worth a section in there...

Now, to follow your pace, probably a message box with a warning could be shown every time the user would try to compile an orphan file, with an option (perhaps a checkbox?) to "never show this warning again". The warning would say something relating how compiling a file without belonging to a project could take to unresolved linker errors and such, and that the user shouldnt bug the authors about this... (or RTFM , in case there was one... :) )

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Compile single file
« Reply #16 on: July 15, 2005, 01:10:29 pm »
Documentation is something that should grow, I think we should start with it as soon as possible (I will help if I can) but where do we store it? in the wiki?
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

darklordsatan

  • Guest
Compile single file
« Reply #17 on: July 15, 2005, 01:25:40 pm »
I was meaning more of a .chm file for instance, bundled with the installation, but I guess a first step would be to put it in the wiki (perhaps to serve as a storage server, and so people can edit typos, improve articles and stuff), and when one article is considered to be "stable", then it could be added to the main help file. The problem that might arise in this schema would probably be the formatting...

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Compile single file
« Reply #18 on: July 15, 2005, 01:28:41 pm »
it is a problem, I can't export wiki pages... (as far as I can see, perhaps an admin is able to do it?) (I opened another topic about documentation ;))
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Compile single file
« Reply #19 on: July 15, 2005, 02:30:43 pm »
Back to the topic, I just added the ability to compile a single file not belonging to a project.
It's already in CVS.
Only thing, it doesn't work with "Compile" but with "Compile current file". I think this makes it more apparent...

Yiannis.
Be patient!
This bug will be fixed soon...

darklordsatan

  • Guest
Compile single file
« Reply #20 on: July 15, 2005, 02:37:35 pm »
That is great Yiannis, thanks; and yeah, the "compile current file" is more appropiate than "compile"

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Compile single file
« Reply #21 on: July 15, 2005, 05:45:43 pm »
Yay! :) Does it link the file too? Will it be in 1.0?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Compile single file
« Reply #22 on: July 15, 2005, 05:51:02 pm »
Quote from: rickg22
Yay! :) Does it link the file too? Will it be in 1.0?

Yes and yes.

Yiannis.
Be patient!
This bug will be fixed soon...

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Compile single file
« Reply #23 on: August 15, 2005, 06:02:45 pm »
Bah, I just tried something and it didn't work.

Code::Blocks compiles a single file without problems but if I set options in the compiler (flags, defines, ...) it won't use them.

Global compiler and linker options MUST be used when compiling a single file too.

Should I add I'm testing that with Code::Blocks HEAD? Haven't tried with VERSION_1.

I would really like to see this little bug fixed soon  :(

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Compile single file
« Reply #24 on: August 15, 2005, 06:36:37 pm »
I don't know how that works :( The compiler plugin is like an alien beast to me. And since Yiannis is still on vacation, I need your help, guys...