News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Using code::blocks w/o a project

Started by dukester, January 27, 2024, 05:04:56 PM

Previous topic - Next topic

Pecan

But notice that your compiler is acting differently from mine.
Is your bash script outputing to a different location than CB expects?

dukester

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!
--
Duke

Pecan

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.

dukester

#18
OK - will do!

C::B is not cranking out a `.o' file at all or `gcc' I should say!
What gives?
--
Duke

Pecan

Right click on Build log tab and copy paste here.
The same for the Build messages.

dukester


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

--
Duke

Pecan

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.

dukester

--
Duke

dukester


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

Pecan

Is there an actual HelloWorld.o sitting in the source dir along wth HelloWold.c ?

dukester

#25
~/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
--
Duke

Pecan

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.

dukester

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.
--
Duke

dukester

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

Pecan

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]