Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: vdweller on May 03, 2020, 11:01:29 am

Title: [SOLVED] Creating folders in build directories
Post by: vdweller on May 03, 2020, 11:01:29 am
Hi all,

I am relatively new to Code::Blocks, I have only used it to write dlls in the past. Now I am trying to make a SFML project.

Suppose I have a folder in the project directory called "font". In it, I have a font file which my project uses. In my code I wrote:
Code
int i=font.loadFromFile("font/calibri.ttf");
And, sure enough, it works.

Now when I build my project, the .exe program is created in either the Debug or Release folder. And, naturally, when I try to run the program from either folder, the font isn't loaded unless I copy the "font" folder to the repective location of the .exe.

My question is: Is there a way for C::B to create the "font" folder and its contents in the bin directories? Or do I have to manually copy all required folders to the .exe location (or vice versa)?
Title: Re: Creating folders in build directories
Post by: stahta01 on May 03, 2020, 11:51:18 am
I would first try setting the working directory and see if that fixes the issue.

Project -> Properties...
Tab: Build Targets
Select "Build Target" in left hand list
Change the value of "Execution Working Directory"

Tim S.
Title: Re: Creating folders in build directories
Post by: vdweller on May 03, 2020, 12:04:13 pm
I would first try setting the working directory and see if that fixes the issue.

Project -> Properties...
Tab: Build Targets
Select "Build Target" in left hand list
Change the value of "Execution Working Directory"

Tim S.
I thought of changing it too but it doesn't have any effect.
Title: Re: Creating folders in build directories
Post by: oBFusCATed on May 03, 2020, 12:36:33 pm
You can put the executables in the root folder of your project. You can name them myproj_debug.exe and myproj.exe to be clear which is which.
Or you could use post build steps to copy files around or external scripts. It is up to you how you want to do it.
Title: Re: Creating folders in build directories
Post by: vdweller on May 03, 2020, 12:53:55 pm
Understood. Thanks for the reply!