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 ..
Yep, just create a file in a temp folder like:
#include <iostream>
int main() {
std::cout << "Hello World! Welcome to your first C++ program!" << std::endl; }
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.
What OS and what version of CodeBlocks are you using?
show us your hello world code inside codetags (the # above a reply box).
[/quote]
gcc --version
gcc (Debian 10.2.1-6) 10.2.1 20210110
codeblocks -h
Starting Code::Blocks Release 20.03 rev 11983 Feb 20 2020, 19:35:00 - wx3.0.2 - gcc 6.3.0 (Linux, unicode) - 64 bit
cat hello.c
#include <stdio.h>
int main(){
printf("Hello World from Turner Valley!\n");
printf("This program was compiled in the emacs editor.\n");
return 0;
}
I brought up (in a VMware) Linux Mint 21.x:
Name : Code::Blocks
Version : 20.03-r11997
SDK Version : 2.0.0
Scintilla Version: 3.7.5
Author : The Code::Blocks Team
E-mail : info@codeblocks.org
Website : http://www.codeblocks.org
wxWidgets Library (wxGTK port)
Version 3.0.5 (Unicode: wchar_t, debug level: 1),
Runtime version of toolkit used is 3.24.
Compile-time GTK+ version is 3.24.33.
I disabled all plugins except: (via Menu/Plugins/Manage Plugins)
Abbreviations
AutoVersioning
Autosave
BrowseTracker
Compiler
Debugger
DragScroll
Files extension handler
Foreign projects Importer
Header Fixup
Help pllugin
IncrementalSearch
Keyboard shortcuts
OccurrencesHighlighting
Open files list
ReopenEditor
Scripted wizard
SmartIndentCpp
SmartIndentXml
Source Exporter
Source code formatter
ThreadSearch
Todo List
wxSmith
sxSmith-Aui
wxSmith-Contrib Items
wxSmith-MIME plugin
I restarted CB after disabling plugins.
I performed the following.
1) Menu/File/New/EmptyFile
2 copy/pasted your code into the Untiled1 editor.
3) Menu/File/Save as/ into Home/pecan/temp/HellowWorld.c
4) Menu/Build/Build
5) Menu/Build/Run
The results are in the .jpg attached.
Build Messages
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
||=== Build finished: 0 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Build Log
-------------- Build file: "no target" in "no project" (compiler: unknown)---------------
gcc -c /home/pecan/Temp/HelloWorld.c -o /home/pecan/Temp/HelloWorld.o
gcc -o /home/pecan/Temp/HelloWorld /home/pecan/Temp/HelloWorld.o
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Checking for existence: /home/pecan/Temp/HelloWorld
Executing: 'xterm -T '/home/pecan/Temp/HelloWorld' -e '/usr/bin/cb_console_runner' '/home/pecan/Temp/HelloWorld'' (in '/home/pecan/Temp')
Set variable: LD_LIBRARY_PATH=
There something weird in your build log.
gcc -Wall -std=c99 -m64 -Og -I/home/dnormandin/programming/c/code/temp -I -c /home/dnormandin/programming/c/code/temp/HelloWorld.c -o /home/dnormandin/programming/c/code/temp/HelloWorld.o
gcc -o /home/dnormandin/programming/c/code/temp/HelloWorld /home/dnormandin/programming/c/code/temp/HelloWorld.o -O2 -m64
/usr/bin/bash: gcc -Wall -std=c99 -m64 -Og -I/home/dnormandin/programming/c/code/temp -I -c /home/dnormandin/programming/c/code/temp/HelloWorld.c -o /home/dnormandin/programming/c/code/temp/HelloWorld.o: No such file or directory
Process terminated with status 127 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
What is that line that begins with "/usr/bin/bash". What the heck is that??
Look at my Build log. there are only two lines. And nothing to do with bash. That line is wiping out your .o file.
gcc -c /home/pecan/Temp/HelloWorld.c -o /home/pecan/Temp/HelloWorld.o
gcc -o /home/pecan/Temp/HelloWorld /home/pecan/Temp/HelloWorld.o
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Checking for existence: /home/pecan/Temp/HelloWorld
Executing: 'xterm -T '/home/pecan/Temp/HelloWorld' -e '/usr/bin/cb_console_runner' '/home/pecan/Temp/HelloWorld'' (in '/home/pecan/Temp')
Set variable: LD_LIBRARY_PATH=
[/code]