Author Topic: Builds fine, runs in terminal but not from CB  (Read 2844 times)

Offline lhm100

  • Single posting newcomer
  • *
  • Posts: 2
Builds fine, runs in terminal but not from CB
« on: October 07, 2024, 11:20:25 pm »
I searched and could not find an answer to this, sorry if I missed it. 
Similar things on windows, and with bad characters in paths - but nothing that addressed this.

Stumped - need some suggestions on how to figure out what's happening:
Versions:
Starting Code::Blocks Release 20.03  rev 11997 2021-11-08, 13:51:13 - wx3.0.5 - gcc 11.2.0 (Linux, unicode) - 64 bit
Linux Mint 21.2

I start CB from a terminal (so I see some output as it's running).
I create a new console cpp project and just leave the default "Hello World" code in place.
I build the project just fine:

Code
-------------- Build: Release in Hello (compiler: GNU GCC Compiler)---------------
Scanned 0 files for #includes, cache used 0, cache updated 0
CWD for depslib was: /home/lee/MySourceCode/Hello.
CWD for depslib is: /home/lee/MySourceCode/Hello.
Scanned 0 files for #includes, cache used 0, cache updated 0
g++ -Wall -fexceptions -O2  -c /home/lee/MySourceCode/Hello/main.cpp -o obj/Release/main.o
g++  -o bin/Release/Hello obj/Release/main.o  -s 
Output file is bin/Release/Hello with size 14.13 KB
CWD for depslib was: /home/lee/MySourceCode/Hello.
...
CWD for depslib is: /home/lee/MySourceCode/Hello.
Scanned 0 files for #includes, cache used 0, cache updated 0
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

From a separate terminal, if I navigate to the /bin/Release directory and run the generated file:
Code
lee@lee-X570S:~/MySourceCode/Hello/bin/Release$ ./Hello 
Hello world!
lee@lee-X570S:~/MySourceCode/Hello/bin/Release$
it runs just fine.

I would expect that I should also be able to run the generated file from within CB.  When I try that I get only this output in the terminal (that I started CB from)
Code
-------------- Run: Release in Hello (compiler: GNU GCC Compiler)---------------
And the CB thread (looking at top) goes to 100% and CB hangs there.  (A few clicks around the window and the window manager allows me to "force quit" CB.)

I have tried to adjust the
Settings - Environment - Terminal to launch console programs: 
With many different things that all work fine from a separate terminal.  Even just trying to open a terminal and display the date. 
Nothing produces any difference at all - CB still hangs - no output anywhere.  So I believe CB is having issues before it tries to run the terminal command.

What I am in need of is:
Is there any way for me to get more info about what's happening?  There are no errors, no crash reports, no core dumps... nothing.  Just the one line shown above and a pegged CPU. 

I can figure out the correct terminal command - if I could get CB to actually execute something and show me what it's trying to do. 
Candidates would be:
Code
gnome-terminal -- bash -c ./
gnome-terminal -t $TITLE -x ./
etc...   I know -x is deprecated and "-- " is the new syntax. But -x does still work. 

But it doesn't matter WHAT I put in there now - it does the same (no)thing...

What can I do to get more info to help you help me?

Let the fun begin!
Thank you.





 

Offline Evan

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Builds fine, runs in terminal but not from CB
« Reply #1 on: October 08, 2024, 10:09:08 am »
Not an Code::Blocks expert at all, but I'm also running the same Linux Mint like you.

I used Software Manager to install "Codeblocks" and the "Codeblocks-contrib" and it just worked right out of the box. I don't use the terminal if I can avoid it, hence clumsy fingers and dyslectic issues, but I assume it works, because I use it every day without troubles.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7679
    • My Best Post
Re: Builds fine, runs in terminal but not from CB
« Reply #2 on: October 08, 2024, 03:07:47 pm »
The most common search results on CB was "gnome-terminal -t $TITLE -x".

Code
gnome-terminal -t $TITLE -x

Link to a another possible value https://forums.codeblocks.org/index.php/topic,16485.msg111897.html#msg111897

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline lhm100

  • Single posting newcomer
  • *
  • Posts: 2
Re: Builds fine, runs in terminal but not from CB
« Reply #3 on: October 09, 2024, 06:34:03 pm »
Update 1.
Still not working.
I did try adding the -contrib package, and that didn't make any difference.  (Didn't really expect it to - but it didn't cost much to try it).

I also was able to use the cb_console_runner program (from another terminal) to run my program.
Code
gnome-terminal -- cb_console_runner '/home/user/full-path-to-my-executable'
and that opened a terminal and ran my program fine.
I don't think CB needs to use that "helper" on linux - but if it does use it - we now know that the hang-up is NOT with cb_console_runner.

I was also able (from a terminal) to successfully run:
Code
xterm -e cb_console_runner  '/home/user/full-path-to-my-executable'
and an xterm window opened and ran my code.
So I put
Code
 xterm -e cb_console_runner 
into the Terminal to launch console programs: box, and the result is the same - nothing, just hangs CB.
So I think I am certain the issue is not in gnome-terminal, cb_console_runner, or xterm. 

Still stumped - 
Keep the ideas coming, please.