Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: milleja46 on September 21, 2012, 02:28:28 pm

Title: Why does code::blocks want image under user directory?
Post by: milleja46 on September 21, 2012, 02:28:28 pm
Ok, I've just started using code::blocks, and wanted to test a friends lib he was making. The problem is I made a sdl project. After making it I tried running it to make sure sdl was working properly on my computer(since I was going to test the lib as a sdl lib). But it reported that it couldn't find the cb.bmp that it created for it. After some frustration, and asking on the irc channel, I figured out that it wanted it under /Users/mynamehere. Does anyone know why this might be and how to change it? I'm on mac by the way
Title: Re: Why does code::blocks want image under user directory?
Post by: Jenna on September 21, 2012, 02:47:01 pm
It's up to the programmer to tell the app where to search for a file (text, image or whatever).

If you have used the wizard to create the sample sdl-app: it's just a simple skeleton, you have to fill it with really useful functions and make it work as you expect it, especially if you want to distribute your software.
Title: Re: Why does code::blocks want image under user directory?
Post by: milleja46 on September 21, 2012, 02:48:50 pm
Yeah but why is it looking for the c::b generated cb.bmp under /Users/mynamehere ?
Title: Re: Why does code::blocks want image under user directory?
Post by: Jenna on September 21, 2012, 03:41:17 pm
It's up to the programmer to tell the app where to search for a file (text, image or whatever).

And if you look at the code (and understand it), you know ehy this happens.

Just one hint: the default excution dir of the sample (if you run it through C::B) is the projects toplevel path (see "Project->Properties->Build targets").
Title: Re: Why does code::blocks want image under user directory?
Post by: milleja46 on September 21, 2012, 04:15:31 pm
That doesn't seem to be true with the image since it seemed to expect it under my user directory instead...might it be a bug?
Title: Re: Why does code::blocks want image under user directory?
Post by: Jenna on September 21, 2012, 07:40:54 pm
That doesn't seem to be true with the image since it seemed to expect it under my user directory instead...might it be a bug?
If it's the sample project, it expects the image in the directory you are in when starting the project.
Title: Re: Why does code::blocks want image under user directory?
Post by: milleja46 on September 21, 2012, 10:04:45 pm
That makes no sense....
Title: Re: Why does code::blocks want image under user directory?
Post by: oBFusCATed on September 21, 2012, 10:12:25 pm
You'll have to debug it to understand what is the real problem.

One way to do it is to use the call getcwd(...) and then to print the working path of the executable.