• Create Account

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1Arale  Members   -  Reputation: 206

Like
0Likes
Like

Posted 11 May 2013 - 04:04 PM

Greetings, all.

I've looked all over the place for a solution to this honestly sort of embarrassing problem. I have this code here:

   // Load BITMAP



and I've tried configuring the directory in every which way I know to get it to read the BMP's in the "spr" folder in the "data" folder next to the EXE. Last time I tried this I used an absolute directory (c:/users/whoever/etc) and obviously that won't work on others' computers. I checked the BMP's and they seem to be fine. Any tips?

Using Allegro 4 and Code::Blocks, by the way

### #2Brother Bob  Moderators   -  Reputation: 10029

Like
1Likes
Like

Posted 11 May 2013 - 04:38 PM

Relative paths are relative to the current working directory, which does not necessarily have to be where the executable is located. Since you mention that you use an IDE, check what the current working directory is when you execute your executable from the IDE if that is what you're doing.

For example, Visual Studio usually sets the working directory to the project directory, but the executable is located somewhere else. Here's my directory setup for my projects:

• Project directory: c:\path\to\project
• Executable directory c:\path\to\project\bin\x64\Release
• Data directory: c:\path\to\project\data

Thus, my Visual Studio executes the command "c:\path\to\project\bin\x64\Release\program.exe" with the working directory "c:\path\to\project", and my program thus accesses files in the data directory with "data\file.bmp" because that is the relative path to the bitmap from the working directory.

If I instead open the file explorer and double click on the executable, the working directory is the executable directory itself, and thus "data\file.bmp" will not found anymore. In that case I would have to use "..\..\..\data\file.bmp" to take three steps up to leave the "bin\x64\Release" substructure.

### #3Arale  Members   -  Reputation: 206

Like
0Likes
Like

Posted 11 May 2013 - 04:51 PM

There's a part of the project properties named Execution Working Directory in build targets, which is set just to "."

and changing that to the directory where I actually put the EXE does nothing, either.

I'll keep tinkering though, I see where you're coming from.

EDIT: Scratch that!! It worked! Thanks so much.

Edited by Arale, 11 May 2013 - 04:53 PM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS