News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Running .c files without creating a project

Started by kartal, June 06, 2009, 07:07:32 AM

Previous topic - Next topic

kartal

Hi


I have started learning C and I am enjoying CB quite a bit.

I am wondering that if it it possible to run compile and run .c files without creating a project?

thanks

MortenMacFly

Quote from: kartal on June 06, 2009, 07:07:32 AM
I am wondering that if it it possible to run compile and run .c files without creating a project?
Yes, but with limitations. Just try!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

kartal

MortenMacFly, how do I do it? It seems  like I need a project to be able to open and compile a file?

Dr.Optix

1. Open C::B
2. File->New->File
3. Select C/C++ File and do what the wizard asks you
4. Write this program:
#include<stdio.h>
int main()
{
    printf("Dr.Optix :D");

    return 0;
}


5. Press F9 and all should work without problems :)
Occupation: Hobby Programmer
IDE: Code::Blocks Nightly / CodeLite Latest Stable
Compiler: TDM's GCC/mingw32
Blog: [url="//droptix.wordpress.com"]DrOptix.WordPress.Com[/url]

kartal

Dr.Optix ,
For some reason, I cannot get it to work. It(F9) is just running previously compiled project. I have tried clean, clean workspace etc. I cannot get it to compile the currently open file that is not part of any project. Bear in mind though I do not want to delete or get rid of my open projects. I just want to be able to compile a file that is not part of any projetc, just for convenience.


Dr.Optix

#5
Tryed with multiple instance of C::B like

One where your project is open and one where you edit/compile your "lone wolf" file

EDIT:

Also you can use Ctrl+Shift+F9 to compile current file, but it just compile it, it don't run it.
Occupation: Hobby Programmer
IDE: Code::Blocks Nightly / CodeLite Latest Stable
Compiler: TDM's GCC/mingw32
Blog: [url="//droptix.wordpress.com"]DrOptix.WordPress.Com[/url]

Jenna

Quote from: kartal on June 06, 2009, 06:23:16 PM
Dr.Optix ,
For some reason, I cannot get it to work. It(F9) is just running previously compiled project. I have tried clean, clean workspace etc. I cannot get it to compile the currently open file that is not part of any project. Bear in mind though I do not want to delete or get rid of my open projects. I just want to be able to compile a file that is not part of any projetc, just for convenience.


The default shortcut for compile current file is "Strg+Shift+F9" (easy to see if you open the "Build" menu).

kartal

I am really not sure what I am doing wrong here. The only things I can think of are, 1-user error, 2-I am using nightly.

I can compile the current file but when I click on "Run" it runs the project or tries to built the active project.

Ceniza

Close all your projects first (empty workspace), then try again.