User forums > Using Code::Blocks

Using code::blocks w/o a project

(1/12) > >>

dukester:
noob to the *blocks" here!
noob to C as well.
I want to simply compile a single c source code file, without having to go through all the project file stuff etc - like in emacs & geany etc.

Is it possible with code::blocks? TIA ..

Pecan:

--- Quote from: dukester on January 27, 2024, 05:04:56 pm ---noob to the *blocks" here!
noob to C as well.
I want to simply compile a single c source code file, without having to go through all the project file stuff etc - like in emacs & geany etc.

Is it possible with code::blocks? TIA ..

--- End quote ---
Yep, just create a file in a temp folder like:

--- Code: ---#include <iostream>
int main() {
std::cout << "Hello World! Welcome to your first C++ program!" << std::endl; }

--- End code ---
and name it HelloWorld.cpp (no spaces)

Start CodeBlocks and use Menu/File/Open or just ctrl-o keys
and hit the compile icon (the gear icon).
Click on the "Build log" tab to make sure no errors occured.
Clik on Menu/Build/Run.
You should see a console open with "Hello World! Welcome to your first C++ program!" as output.

Easier than that is:
Load Codeblocks and do:
If you get messages like: "HelloWorld already exists, do you want to overwrite it?", answer yes.
1) Menu/file/new/project...
2) Double click "Project application"
3) Click on "next" two times. Enter the name "HelloWorld" (no spaces)  in the project title.
4) Click on "next" and "finished"
5) On the Project tab double click "main.cpp" to open the file.
Cl6) Cick on the compile (gear icon) to compile, then  Menu/Build/run (or the  green right-pointing run arrow).

For further reading:
https://www.codeblocks.org/user-manual/
https://www.sci.brooklyn.cuny.edu/~goetz/codeblocks/codeblocks-instructions.pdf (this takes some time to load into a browser). Maybe download it instead.

Pecan:
I found an even easier way to create the file.
Menu/File/new/Empty file.
Paste the code into the file.
Menu/File/Save as/ c:\temp\HelloWorld.cpp (or any other folder, as long as it's not a protected OS folder.
Menu/Build
Menu/Build/Run

dukester:
I did just as you suggested - opened an existing .c source file.
Build & run

I keep getting:

||=== Build file: "no target" in "no project" (compiler: unknown) ===|
||=== Build failed: 0 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

dukester:

--- Quote from: Pecan on January 27, 2024, 06:14:23 pm ---I found an even easier way to create the file.
Menu/File/new/Empty file.
Paste the code into the file.
Menu/File/Save as/ c:\temp\HelloWorld.cpp (or any other folder, as long as it's not a protected OS folder.
Menu/Build
Menu/Build/Run

--- End quote ---

Right on! Thx, but I still get that error msg from code::blocks.

Navigation

[0] Message Index

[#] Next page

Go to full version