This topic is 2128 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am trying to load a .bmp image with SDL but i'm not sure were to put the image so it can be found. When I add the file in the project folder and run this code I get the following output in the console: /Users/user/Library/Developer/Xcode/DerivedData/SDLExperiment-dsfnjwhgojekaeehoaipimlpnoqb/Build/Products/Debug
The image could not be located due to the following error: Couldn't open hello.bmp

[color=#754a2b] #include <SDL.h> #include <iostream> using namespace std; int main( int argc, char* args[] ) { SDL_Surface* hello = NULL; SDL_Surface* screen = NULL; char title[50] = ""; SDL_Init (SDL_INIT_EVERYTHING); screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); hello = SDL_LoadBMP("hello.bmp"); if (hello == NULL) { cout << getcwd(title, 120) << endl; cout << "The image could not be located due to the following error: " << SDL_GetError() << endl; return 1; } SDL_BlitSurface(hello, NULL, screen, NULL); SDL_Flip(screen); SDL_Delay(2000); SDL_FreeSurface(hello); SDL_Quit(); return 0; } 

##### Share on other sites
This is not a question about SDL or about loading bitmap but more about directory structure. I'm not used to Xcode and I find your project path to be quite long, but usually the application will search the file in a relative path to the working directory. Under Windows, when you double click an .exe, the working directory is the same as the executable. Under visual studio when you run the application from the IDE it's by default the directory of the .sln file, but can be modified in the project settings. I'm guessing it's about the same for Xcode.