Author Topic: [SOLVED] Creating folders in build directories  (Read 2941 times)

Offline vdweller

  • Single posting newcomer
  • *
  • Posts: 3
[SOLVED] Creating folders in build directories
« 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)?
« Last Edit: May 03, 2020, 12:54:09 pm by vdweller »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Creating folders in build directories
« Reply #1 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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline vdweller

  • Single posting newcomer
  • *
  • Posts: 3
Re: Creating folders in build directories
« Reply #2 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Creating folders in build directories
« Reply #3 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.
(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 vdweller

  • Single posting newcomer
  • *
  • Posts: 3
Re: Creating folders in build directories
« Reply #4 on: May 03, 2020, 12:53:55 pm »
Understood. Thanks for the reply!