Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: dukester on January 27, 2024, 05:04:56 pm

Title: Using code::blocks w/o a project
Post by: 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 ..
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 27, 2024, 05:39:23 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 ..
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; }
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.

Title: Re: Using code::blocks w/o a project
Post by: 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
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 27, 2024, 06:28:59 pm
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)) ===|
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 27, 2024, 06:32:46 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

Right on! Thx, but I still get that error msg from code::blocks.
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 27, 2024, 08:36:30 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

Right on! Thx, but I still get that error msg from code::blocks.
What OS and what version of CodeBlocks are you using?
show us your hello world code inside codetags  (the # above a reply box). 
Title: Re: Using code::blocks w/o a project
Post by: Miguel Gimenez on January 27, 2024, 08:43:31 pm
You must install and configure a compiler.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 27, 2024, 09:52:23 pm

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

Code
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;
}

Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 27, 2024, 10:06:27 pm
Make sure that your Menu/Settings/Compiler/ToolChain_executables look like this:
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 27, 2024, 10:56:16 pm
Thx for the screenshot!! Yup! Got it set up that way also!
I have zero probs from the CLI / emacs / geany. Compiles like a charm. I just got the notion to test-drive code::blocks! Too much grief it seems.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 04:00:43 am
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).

I just tried your above suggestion for hellery! No joy!
The main.c file got written to the HelloWorld directory, BUT /obj/Release/main.o never gets written so gcc chokes with an error msg.

Quote
/usr/bin/bash: gcc -Wall -O2 -Wall -std=c99 -m64 -Og  -I~/programming/c/code/HelloWorld -I~/programming/c/code/HelloWorld/ -c ~/programming/c/code/HelloWorld/main.c -o obj/Release/main.o: No such file or directory
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 28, 2024, 04:11:15 am
What version of CodeBlocks are you using?
Should show in the splash screen, but you can find it in the Menu/Help also.

Tomorrow, I'll load up Codeblocks in a Linux VM and see what's going on.

Hang in there, bud. You're gonna like CodeBlocks.  :)

I've been using it for Windows, Linux, and embedded coding for 20 yrs. I know any new software is hard to get started using. After that, it flies.

We'll figure this out. I just need to cause the same problems you're having to understand what's going on.


Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 04:40:29 am
Right on! I'm close to the solution I'm sure!
I've got v20.03 on this Linux antiX box!

Thanks for all your help!
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 28, 2024, 10:30:12 pm
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)
Code
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
Code
||=== 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
Code
-------------- 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=

Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 10:37:27 pm
WOW! I'll try disabling all plugins as well except those you kept - and try again. Thanks a bunch for the trouble you went through!
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 28, 2024, 10:39:52 pm
But notice that your compiler is acting differently from mine.
Is your bash script outputing to a different location than CB expects?
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 10:42:52 pm
I don't use a bash script. My default shell is zsh, but I set C::B to use bash thinking that maybe it didn't play nice with zsh or visa-versa!
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 28, 2024, 10:45:37 pm
Check, that on output, the .o file is sitting in the same dir as the .c file.
You don't get the option of moving the .o or executable when not using a project.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 10:46:54 pm
OK - will do!

C::B is not cranking out a `.o' file at all or `gcc' I should say!
What gives?
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 28, 2024, 10:59:32 pm
Right click on Build log tab and copy paste here.
The same for the Build messages.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 11:02:50 pm

-------------- Build: Debug in HelloWorld (compiler: GNU GCC Compiler)---------------

gcc -Wall -g -Wall -std=c99 -m64 -Og  -I/home/dnormandin/programming/c/code/HelloWorld -I/home/dnormandin/programming/c/code/HelloWorld/ -c /home/dnormandin/programming/c/code/HelloWorld/main.c -o obj/Debug/main.o
gcc  -o bin/Debug/HelloWorld obj/Debug/main.o  -O2 -m64 
/usr/bin/bash: gcc -Wall -g -Wall -std=c99 -m64 -Og  -I/home/dnormandin/programming/c/code/HelloWorld -I/home/dnormandin/programming/c/code/HelloWorld/ -c /home/dnormandin/programming/c/code/HelloWorld/main.c -o obj/Debug/main.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))


 ||=== Build: Debug in HelloWorld (compiler: GNU GCC Compiler) ===|
 gcc -Wall -g -Wall -std=c99 -m64 -Og  -I/home/dnormandin/programming/c/code/HelloWorld -I/home/dnormandin/programming/c/code/HelloWorld/ -c /home/dnormandin/programming/c/code/HelloWorld/main.c -o obj/Debug/main.o||No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 28, 2024, 11:10:52 pm
You're using a project? The Debug target?

I thought we were working on NO project builds.
Lets simplfy. Start over and use only the build process I used.
We can get to projects a little later.

I want to know that a no-project plan works first.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 11:13:38 pm
You bet! Sorry about that ...
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 11:21:27 pm

-------------- Build file: "no target" in "no project" (compiler: unknown)---------------

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))
 
Checking for existence: /home/dnormandin/programming/c/code/temp/HelloWorld

-------------- Build file: "no target" in "no project" (compiler: unknown)---------------

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))
 

||=== Build file: "no target" in "no project" (compiler: unknown) ===|
 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|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 28, 2024, 11:29:32 pm
Is there an actual HelloWorld.o sitting in the source dir along wth HelloWold.c ?
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 11:33:52 pm
~/programming/c/code/temp
ls -al HelloWorld.*
-rw-r--r-- 1 dnormandin dnormandin 161 Jan 28 15:18 HelloWorld.c

find ${HOME} -name HelloWorld.o -print
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 28, 2024, 11:38:49 pm
Ok, so the compiler is acting up.
Lets get rid of those extra compiler settings.

In your compiler settings, uncheck
-std=c99 -m64 -Og -O2
from both the compiler and the linker options.
until you don't see them in the logs.
 
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 11:43:37 pm
Whoa! I just copied the gcc instructions issued by C::B (from the Build Log output) - and pasted into the /temp directory where HelloWorld.c lives. No probs - I've now got a HelloWorld.o file.

I'll run the 2nd gcc line and I bet I'll get an executable.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 28, 2024, 11:46:21 pm
Nope! I got a linking error:

gcc  -o /home/dnormandin/programming/c/code/temp/HelloWorld /home/dnormandin/programming/c/code/temp/HelloWorld.o  -O2 -m64
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 29, 2024, 12:04:24 am
There something weird in your build log.
Code
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.
Code
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]
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 29, 2024, 12:14:15 am
/usr/bin/bash is set in Menu/Settings/General/Environment Settings/General settings

In there I also set the terminal I want to use.
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 29, 2024, 12:20:11 am
For our tests, set:
shell to run to: /bin/sh -c
Terminal to launch: xterm -T $TITLE -e
Open containing folder: xdg -open
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 29, 2024, 12:24:55 am
Done!! Re-built w/ following results:


-------------- Build file: "no target" in "no project" (compiler: unknown)---------------

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/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

||=== Build file: "no target" in "no project" (compiler: unknown) ===|
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o||in function `_start':|
(.text+0x20)||undefined reference to `main'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 29, 2024, 12:27:16 am
Where did the "/usr/bin/ld: /usr/lib/gcc/x86..." line come from?
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 29, 2024, 12:29:11 am
From the "Build Messages"
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 29, 2024, 12:31:52 am
The compiler setting should look like this.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 29, 2024, 12:37:19 am
Yup! That's exactly what I've got!

Say - you've been overly kind and generous with your time. I can use the Geany or emacs editor - no problem. C::B was worth a test-drive but you've got a life other than it. Thanks for all the effort!!
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 29, 2024, 12:38:21 am
Ok, sorry it didn't work out.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 29, 2024, 12:39:34 am
👍

Joy!!


-------------- Build: Debug in HelloWorld (compiler: GNU GCC Compiler)---------------

gcc -Wall -g -Wall -std=c99 -m64 -Og  -I/home/dnormandin/programming/c/code/HelloWorld -I/home/dnormandin/programming/c/code/HelloWorld/ -c /home/dnormandin/programming/c/code/HelloWorld/main.c -o obj/Debug/main.o
gcc  -o bin/Debug/HelloWorld obj/Debug/main.o  -O2 -m64 
Output file is bin/Debug/HelloWorld with size 17.47 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

-------------- Run: Debug in HelloWorld (compiler: GNU GCC Compiler)---------------

Checking for existence: /home/dnormandin/programming/c/code/HelloWorld/bin/Debug/HelloWorld
Set variable: LD_LIBRARY_PATH=.:/usr/share/lib:/usr/lib/x86_64-linux-gnu
Executing: xterm -T HelloWorld -e /usr/bin/cb_console_runner LD_LIBRARY_PATH=/usr/share/lib:/usr/lib/x86_64-linux-gnu:. /home/dnormandin/programming/c/code/HelloWorld/bin/Debug/HelloWorld  (in /home/dnormandin/programming/c/code/HelloWorld/.)
Process terminated with status 0 (0 minute(s), 7 second(s))
 
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 29, 2024, 04:12:25 am
Congratulations, you are tenacious. A sign of a good coder/programmer.

In your leasure time (if there's such a thing) read some of the following in the "projects" section.

Quote

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.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 29, 2024, 04:20:49 am
Thx for the URLs! I've got the 2nd one DLed already. I'll read the C::B users manual for sure. BTW, I still can't get C::B to compile a standalone .c file. It appears that it's not sending the linker the correct info on my system. It worked on your VM - so go figure, right? Whatever - I'll just use the project way! Thx again!
Title: Re: Using code::blocks w/o a project
Post by: stahta01 on January 29, 2024, 04:38:05 am
Thx for the URLs! I've got the 2nd one DLed already. I'll read the C::B users manual for sure. BTW, I still can't get C::B to compile a standalone .c file. It appears that it's not sending the linker the correct info on my system. It worked on your VM - so go figure, right? Whatever - I'll just use the project way! Thx again!

IIRC, the global compiler settings needs the correct compiler to be set as default.
Edit: And, I have no idea if single file option links correctly on Windows; I never tried it.

Tim S.
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 29, 2024, 04:45:59 am
Thx for the URLs! I've got the 2nd one DLed already. I'll read the C::B users manual for sure. BTW, I still can't get C::B to compile a standalone .c file. It appears that it's not sending the linker the correct info on my system. It worked on your VM - so go figure, right? Whatever - I'll just use the project way! Thx again!

IIRC, the global compiler settings needs the correct compiler to be set as default.
Edit: And, I have no idea if single file option links correctly on Windows; I never tried it.

Tim S.

I was able to compile, link and run a single source file with CB 20 and the Nightly (no project) on both Windows and Linux (Mint 21.x).
But others cannot.
I don't see why. Must be above my pay grade.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 29, 2024, 04:46:36 am
My global compiler setting must be set correctly because it finally compiled the code under the project structure. However, for some reason it refused to crank out an obj file for the linker. Can't be a permissions issue, otherwise it would choke also when building as a project.
Title: Re: Using code::blocks w/o a project
Post by: stahta01 on January 29, 2024, 06:34:59 am
My global compiler setting must be set correctly because it finally compiled the code under the project structure. However, for some reason it refused to crank out an obj file for the linker. Can't be a permissions issue, otherwise it would choke also when building as a project.

When *not* using a project, the single file operations needs to use an Compiler, it either uses "GCC" or the "DEFAULT" Compiler. The global compiler options is where the default compiler is set. There has been many of weird problem traced to the CB user having an different global Compiler than the person trying to help them. I do not think this is your problem; but, it has surprised me how many people over look the set as default option for hours while some tries to help them!

Tim S.
 
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 29, 2024, 06:41:50 am
The compiler is set correctly in my C::B - GCC!! For some reason, C::B is running gcc in such a way that the obj file(s) are not created in single file, no project mode.
Title: Re: Using code::blocks w/o a project
Post by: stahta01 on January 29, 2024, 08:12:42 am
The compiler is set correctly in my C::B - GCC!! For some reason, C::B is running gcc in such a way that the obj file(s) are not created in single file, no project mode.

If you expected the linker to be called, you will not see that.
I do think it is creating an object file, but, it will be someplace that might not be expected.
Edit: My info is years out of date; I have not used it in the last 3 years.

Tim S.
Title: Re: Using code::blocks w/o a project
Post by: Pecan on January 29, 2024, 11:52:48 pm
I think what @stahta01 is saying is:

Menu/Setting/compiler and in the top comboBox choose
the compiler with "(default)" appended.
See if that solves the problem.

It might as well do the link for you. It did for me.
Or maybe i should say, it created the executable.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 30, 2024, 06:42:39 am
I tried to include a screen shot but it didn't work.
Anyway, I don't have an entry like you show with the arrow.
I just have GNU GCC Compiler with no default after it
Title: Re: Using code::blocks w/o a project
Post by: nenin on January 30, 2024, 07:25:24 am
I tried to include a screen shot but it didn't work.
Anyway, I don't have an entry like you show with the arrow.
I just have GNU GCC Compiler with no default after it
Here you can set it as default.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 30, 2024, 01:44:44 pm
The "Set as Default" button is greyed out/not active on my version of C::B. The dropdown menu works and I can select from a long list of compilers - so I chose GNU GCC Compiler - but I cannot make it the default!!
Title: Re: Using code::blocks w/o a project
Post by: Grit Clef on January 31, 2024, 03:17:22 am
Is your GNU GCC Compiler already default(followed by "default" within a pair of parentheses )? In that case, the Set As Default button will be gray.
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 31, 2024, 03:22:55 am
See reply #48 above! Anyway - I've given up on C::B on my Linux box. I've wasted enough of my and others' time. Thx for the input!!
Title: Re: Using code::blocks w/o a project
Post by: Grit Clef on January 31, 2024, 03:36:52 am
Sorry, I didn't read your reply#48.
But I Think This still can be solved. Could you please try closing all projects, and reset Compiler options again(my personal idea)?
Title: Re: Using code::blocks w/o a project
Post by: dukester on January 31, 2024, 03:43:57 am
I've already nuked C::B off my system. I first installed a binary version for Linux. No joy! Then I built from source - No joy! I'm done - especially when I can compile C code by hand on a  terminal with zero probs - or from emacs - or from geany! Thanks anyway!!
Title: Re: Using code::blocks w/o a project
Post by: stahta01 on February 08, 2024, 04:47:22 pm
The "Set as Default" button is greyed out/not active on my version of C::B. The dropdown menu works and I can select from a long list of compilers - so I chose GNU GCC Compiler - but I cannot make it the default!!

On windows, this means the currently selected compiler is the default already.

Tim S.