User forums > Using Code::Blocks

[SOLVED] Creating folders in build directories

(1/1)

vdweller:
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");
--- End code ---
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)?

stahta01:
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.

vdweller:

--- Quote from: 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.

--- End quote ---
I thought of changing it too but it doesn't have any effect.

oBFusCATed:
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.

vdweller:
Understood. Thanks for the reply!

Navigation

[0] Message Index

Go to full version