Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: jury on May 15, 2021, 07:18:15 pm

Title: Can not run binary from Code::Blocks [SOLVED]
Post by: jury on May 15, 2021, 07:18:15 pm
After the binary is built, it does not run from Code::Blocks.
In "Build log" the command for running is:
Code
------------- Run: all in gemrb (compiler: GNU GCC Compiler)---------------

Checking for existence: /home/jury/gemrb-0.7.0/build/gemrb
Set variable: LD_LIBRARY_PATH=.:
Executing: xterm -T gemrb -e /home/jury/gemrb-0.7.0/build/gemrb (in /home/jury/gemrb-0.7.0/build/gemrb)

It looks like its missing the binary name, as for my understanding it should execute something like this: /home/jury/gemrb-0.7.0/build/gemrb/gemrb
And when I copy this command from Code::Blocks to terminal window, it of course does not execute anything, as /home/jury/gemrb-0.7.0/build/gemrb is just a path ending with a folder name. When adding a binary name to this path, it runs fine.
So, what do I have to tweak in project options, so the command for running binary will work properly?

What I have done so far:
- set directory (as it was blank) in Project -> Properties -> Project settings -> Execution Directory
- set directory (as it was blank) in Project -> Properties -> Build targets -> Execution working dir
I have tried absolute and relative paths for above options, but none made any difference.

System: latest PCLOS Xfce
Code::Blocks: 20.3

(if it matters its a project made by cmake with option: -G "CodeBlocks - Unix Makefiles")
Title: Re: Can not run binary from Code::Blocks
Post by: oBFusCATed on May 15, 2021, 07:22:19 pm
Project -> Properties -> <your target> -> Output filename controls what is being run.
Probably cmake doesn't generate it correctly or you need to select the proper target.
I'm not 100% sure that running more complex executables is working correctly for cmake generated projects.
Some simple targets work, but if the target needs an installation step in order to work, I doubt it will work from C::B.
Title: Re: Can not run binary from Code::Blocks
Post by: jury on May 15, 2021, 07:34:17 pm
Project -> Properties -> <your target> -> Output filename controls what is being run.
Probably cmake doesn't generate it correctly or you need to select the proper target.

Seems you are right that cmake didn't generate is correctly. There was only binary name there, so I though that setting "Execution working dir" together with this "Output filename" should somehow work together. But it seems not. I have changed "Output filename" to the whole path with binary name and it ... WORKS! :D
Thanks. I have now my first cmake project working properly. Phew, it was a lesson.
Title: Re: Can not run binary from Code::Blocks
Post by: oBFusCATed on May 16, 2021, 02:00:50 am
Just keep in mind that every time you run "cmake ." or something similar it will destroy your edits.
Also the "all" target is used to build the whole app. Probably you have another target which you can use for running the application, which is set correctly.