News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

[SOLVED] Creating folders in build directories

Started by vdweller, May 03, 2020, 11:01:29 AM

Previous topic - Next topic

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:
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)?

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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

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.
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.
(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!]

vdweller