Author Topic: Hello world didn't work at the same time that it did work  (Read 3148 times)

Offline matthewbaynham

  • Single posting newcomer
  • *
  • Posts: 3
Hello world didn't work at the same time that it did work
« on: October 23, 2022, 03:00:08 pm »
I wrote the very simplest "hello world" program to get use to Code Blocks. In the terminal window it works fine, but in the Code Blocks debugger I get an error it says "failed to execute terminal command".

I've attached a screen shot of the Code Blocks window and you can see the one line of code inside the main, and you can see the error at the bottom of the window in red in the debugger window.

The second screen shot that I've attached is the very same application running in the terminal window.  This is compiled by Code Blocks.

So why is Code Blocks compiling something that doesn't work in Code Blocks and yet the same executable that Code Blocks fails to run will run in a terminal window?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Hello world didn't work at the same time that it did work
« Reply #1 on: October 23, 2022, 04:39:38 pm »
So why is Code Blocks compiling something that doesn't work in Code Blocks and yet the same executable that Code Blocks fails to run will run in a terminal window?
A reason could be that you don't have the terminal (xterm in that case) installed. If so, just change the settings and use a terminal that is available for your platform.
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 matthewbaynham

  • Single posting newcomer
  • *
  • Posts: 3
Re: Hello world didn't work at the same time that it did work
« Reply #2 on: October 23, 2022, 05:32:27 pm »
I think you have it the wrong way around.

It worked in the terminal window (I don't know if it's xterm or term but it's a command line).

But it didn't work in Code Blocks, although it was written using Code Block and compiled using Code Blocks, then failed to run in Code Blocks.  Look in the screen shot I posted in the black part of the window there is red writing saying "Failed to execute terminal command".

Why does what Code Blocks compiled work outside of Code Blocks but not in Code Blocks?  It just doesn't make sense.

Online Commaster

  • Almost regular
  • **
  • Posts: 171
Re: Hello world didn't work at the same time that it did work
« Reply #3 on: October 23, 2022, 07:29:30 pm »
No, Morten has it the right way around.

Try copying the "Failed to execute terminal command" (Everything inside the ' ') and pasting it in your terminal window.

This will quickly show if you have the xterm app installed (which is the default terminal in Code::Blocks settings, and you can change this, as pointed out by Morten)

Offline matthewbaynham

  • Single posting newcomer
  • *
  • Posts: 3
Re: Hello world didn't work at the same time that it did work
« Reply #4 on: October 23, 2022, 08:33:12 pm »
OK, now that makes more sense, I didn't have xterm installed.

But simply installed xterm solved that.

Thanks for that.

Offline Wkerry

  • Multiple posting newcomer
  • *
  • Posts: 42
Re: Hello world didn't work at the same time that it did work
« Reply #5 on: October 29, 2022, 05:16:01 am »
Is there a way to use a different terminal than xterm? (I do not like xterm).

Online Commaster

  • Almost regular
  • **
  • Posts: 171
Re: Hello world didn't work at the same time that it did work
« Reply #6 on: October 29, 2022, 01:43:42 pm »
Is there a way to use a different terminal than xterm? (I do not like xterm).
As Morten mentioned, yes, you can.
Settings -> Environment... -> General settings -> Terminal to launch console programs