Author Topic: Executable to be run must be in a folder different from Output  (Read 5634 times)

Offline dejudicibus

  • Single posting newcomer
  • *
  • Posts: 3
    • Dario de Judicibus' Portal
System: Windows 7 - Language: c++ (MinGW) - Libraries: wxWidgets 2.9.2

I just built a new project and the resulting executable was generated in Output folder. Then I use a post-build script to copy it in a test directory. Question is: how can I debug the program, since it should be launched in test directory because it need a number of external files to run? I cannot execute it in Output folder. How I say to Code::Blocks where is the file to be executed, if not in Output folder?
Dario de Judicibus

zabzonk

  • Guest
Re: Executable to be run must be in a folder different from Output
« Reply #1 on: July 31, 2011, 09:11:58 am »
Easiest is probably not to do that copying. Instead create a  new build Target via Project|Properties|Build Targets. make it a duplicate of Debug, but change the output path and filename  and the build directory to where you want the executable to be. Then build and debug with that target.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Executable to be run must be in a folder different from Output
« Reply #2 on: July 31, 2011, 09:14:38 am »
Another option is:
step1. change the working directory option to the place where you want the exe to be run.
step2. add a library search path for that dir, this way LD_LIBRARY_PATH will be modified and the libraries (if there are libs in the output2 dir) will be found and used.

(I'm not 100% this will work, I'm just guessing)
(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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Executable to be run must be in a folder different from Output
« Reply #3 on: July 31, 2011, 09:19:22 am »
I cannot execute it in Output folder. How I say to Code::Blocks where is the file to be executed, if not in Output folder?
You don't need to. You can skip the copy step and just adjust the launch path in the project properties, namely "Execution working directory". Thus, the compiled app will be launched but will find all libs, resources etc. as if it would be launched there.
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 dejudicibus

  • Single posting newcomer
  • *
  • Posts: 3
    • Dario de Judicibus' Portal
Re: Executable to be run must be in a folder different from Output
« Reply #4 on: July 31, 2011, 10:55:55 am »
You don't need to. You can skip the copy step and just adjust the launch path in the project properties, namely "Execution working directory". Thus, the compiled app will be launched but will find all libs, resources etc. as if it would be launched there.

Well, I can change the execution directory only if I check "Custom Makefile", but I do not have any... Do I need to create a custom makefile to change the execution directory?
Dario de Judicibus

Offline dejudicibus

  • Single posting newcomer
  • *
  • Posts: 3
    • Dario de Judicibus' Portal
Re: Executable to be run must be in a folder different from Output
« Reply #5 on: July 31, 2011, 11:01:19 am »
Oh, ok... output dir was in targets dialog too. So I created a new target (Test) specifying where the executable should be generated, with which name and where to run it. No need anymore of post-build copy.
Dario de Judicibus