Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: dejudicibus on July 31, 2011, 01:36:40 am

Title: Executable to be run must be in a folder different from Output
Post by: dejudicibus on July 31, 2011, 01:36:40 am
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?
Title: Re: Executable to be run must be in a folder different from Output
Post by: zabzonk 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.
Title: Re: Executable to be run must be in a folder different from Output
Post by: oBFusCATed 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)
Title: Re: Executable to be run must be in a folder different from Output
Post by: MortenMacFly 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.
Title: Re: Executable to be run must be in a folder different from Output
Post by: dejudicibus 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?
Title: Re: Executable to be run must be in a folder different from Output
Post by: dejudicibus 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.