Author Topic: Can not run binary from Code::Blocks [SOLVED]  (Read 4080 times)

Offline jury

  • Multiple posting newcomer
  • *
  • Posts: 18
Can not run binary from Code::Blocks [SOLVED]
« 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")
« Last Edit: May 17, 2021, 07:24:51 am by jury »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Can not run binary from Code::Blocks
« Reply #1 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jury

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Can not run binary from Code::Blocks
« Reply #2 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Can not run binary from Code::Blocks
« Reply #3 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]