Reputation: 4501
I have some videofiles in our SVN repository alongside the sourcecode of my application. After checking out, the visual studio project is built using cmake. my code needs to load the video files and it works well when running the application out of visual studio - but when the exe file in the release/debug folder is doubleclicked, it crashes because the relative paths are not right anymore. aparently when running it from within visual studio, the folder where the .sln file lies is considered the root of relative paths.
how can I refere to the videofiles from the code, such that the application works if i run it within visual studio as well as if i double click the exe in the release/bin folders, without to duplicate the videos? (they are quite big)
I need to do this because I have to hand in my application such that it can be compiled and run out of the box as well as executed without visual studio.
Upvotes: 4
Views: 7525
Reputation: 78320
You can change your project's settings to make the IDE's behaviour match double-clicking on the executable, and then fix your relative paths.
For VS10/VS11, in the project's properties page, at the top select All Configurations
from the Configuration:
list.
Then select Configuration Properties
->Debugging
and set the Working Directory
to $(OutDir)
Beware that running the executable from the command prompt in a directory other than $(OutDir) will still fail.
Upvotes: 7