Author Topic: Code executes in terminal when run from code::blocks not directly from Terminal  (Read 6032 times)

Offline abajor

  • Single posting newcomer
  • *
  • Posts: 3
Ok some I'm working on a project for school
Everything compiles fine no warnings, when code::blocks calls either gnome-terminal or xterm the compiled code executes perfectly.

Does the following when I try to run from terminal


This is the build code from codeblocks

even if I copy its syntax I still can't get my compiled code to execute on the terminal.

 

-------------- Build: Release in Lab10 (compiler: GNU GCC Compiler)---------------

gcc -Wall -O2 -c /home/spode/Downloads/git/abajor/Lab10/Game.c -o obj/Release/Game.o
gcc -Wall -O2 -c /home/spode/Downloads/git/abajor/Lab10/Player.c -o obj/Release/Player.o
gcc -Wall -O2 -c /home/spode/Downloads/git/abajor/Lab10/rpg.c -o obj/Release/rpg.o
gcc -o bin/Release/Lab10 obj/Release/Game.o obj/Release/Player.o obj/Release/rpg.o -s
Output file is bin/Release/Lab10 with size 9.98 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: Release in Lab10 (compiler: GNU GCC Compiler)---------------

Checking for existence: /home/spode/Downloads/git/abajor/Lab10/Lab10/bin/Release/Lab10
Executing: gnome-terminal -t Lab10 -x /usr/bin/cb_console_runner LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. /home/spode/Downloads/git/abajor/Lab10/Lab10/bin/Release/Lab10 (in /home/spode/Downloads/git/abajor/Lab10/Lab10/.)
Process terminated with status 0 (0 minute(s), 0 second(s))

 

Anyone have any idea what's going on?
« Last Edit: March 22, 2018, 05:34:28 am by abajor »

Offline sodev

  • Regular
  • ***
  • Posts: 498
What is "does the following" exactly? Terminate immediately? Any chance that it loads some .so from project root directory dynamically? What does gdb say when you run it with it?

Offline abajor

  • Single posting newcomer
  • *
  • Posts: 3
The following is the terminal window results.
Left window is me compiling the code using gcc and a make file.
as you can see I enter ./rpg to run the execeutable in terminal, the terminal acts like I hit enter on a blank line.

The center terminal window is when code::blocks calls the executable it compiled in the terminal, and works fine.

The right terminal window is when I try to run the executable code::blocks compiled manually from the terminal.

I doubt it requires anything specially to execute, it's literally c standard library stuff, and headers that are in my project.

I haven't tried gdb from the terminal, so far when I try to use gdb debug in codeblocks it complains about not being able to access the terminal.

I'll try and use gdb on the compiled bebug version.

Offline abajor

  • Single posting newcomer
  • *
  • Posts: 3
I figured it out code blocks wanted to make its project file a level above the file with my code headers and data.
my relative path was set to look for the data directory one level bellow the project folder, instead of the same folder.

It was exiting because there was no file to load, it's supposed to give me an error message but I guess the program just decided nope, and exited without any error codes.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
You can set the execution path in Project->Properties->build targets tab->execution working dir