Author Topic: Running .c files without creating a project  (Read 6662 times)

Offline kartal

  • Multiple posting newcomer
  • *
  • Posts: 10
Running .c files without creating a project
« on: June 06, 2009, 07:07:32 am »
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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Running .c files without creating a project
« Reply #1 on: June 06, 2009, 07:23:01 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline kartal

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Running .c files without creating a project
« Reply #2 on: June 06, 2009, 07:34:34 am »
MortenMacFly, how do I do it? It seems  like I need a project to be able to open and compile a file?

Offline Dr.Optix

  • Multiple posting newcomer
  • *
  • Posts: 30
  • I'm studying OS Developing.
    • DrOptix Blog
Re: Running .c files without creating a project
« Reply #3 on: June 06, 2009, 09:49:55 am »
1. Open C::B
2. File->New->File
3. Select C/C++ File and do what the wizard asks you
4. Write this program:
Code
#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: DrOptix.WordPress.Com

Offline kartal

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Running .c files without creating a project
« Reply #4 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.


Offline Dr.Optix

  • Multiple posting newcomer
  • *
  • Posts: 30
  • I'm studying OS Developing.
    • DrOptix Blog
Re: Running .c files without creating a project
« Reply #5 on: June 06, 2009, 06:46:28 pm »
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.
« Last Edit: June 06, 2009, 06:50:29 pm by Dr.Optix »
Occupation: Hobby Programmer
IDE: Code::Blocks Nightly / CodeLite Latest Stable
Compiler: TDM's GCC/mingw32
Blog: DrOptix.WordPress.Com

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Running .c files without creating a project
« Reply #6 on: June 06, 2009, 06:53:08 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).

Offline kartal

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Running .c files without creating a project
« Reply #7 on: June 06, 2009, 07:02:54 pm »
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.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Running .c files without creating a project
« Reply #8 on: June 07, 2009, 10:23:06 am »
Close all your projects first (empty workspace), then try again.