Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


SDL Permission denied


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.

  • You cannot reply to this topic
8 replies to this topic

#1 Noob C++   Members   -  Reputation: 116

Like
0Likes
Like

Posted 16 May 2014 - 05:24 PM

Hello All,

 

I am using Code Blocks IDE and SDL. When I was coding in SDL for putting images on the screen and run the program. It worked fine. I decide to change window size then I run the program again but It say SDL Permission denied !

 

How can I fixed that?



Sponsor:

#2 Servant of the Lord   Crossbones+   -  Reputation: 21233

Like
0Likes
Like

Posted 16 May 2014 - 06:04 PM

Post your actual error message.

 

Likely, you were compiling, but your previous build was still running in the background, so your compiler couldn't erase the old exe and write the new exe, because you can't delete an exe that the OS is currently running.

 

tldr: Make sure your executable is closed before recompiling.


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#3 Noob C++   Members   -  Reputation: 116

Like
0Likes
Like

Posted 17 May 2014 - 02:45 PM

SDL FOLDER

 

118hi54.jpg

 

 

SDL >> BIN Folder

 

ngzz3d.jpg

 

SDL >> BIN >> Debug Folder

 

2q1827a.jpg

 

SDL >> BIN >> Release

 

2qnwok4.jpg

 

 

Code Block IDE with SDL Code

 

v3ke94.jpg



#4 Noob C++   Members   -  Reputation: 116

Like
0Likes
Like

Posted 17 May 2014 - 02:46 PM

What Do I need to do to stop from Happening again because I always changing code every time I run the program to make better and adding some stuffs on screen

 

 

 

tldr: Make sure your executable is closed before recompiling.

 

 

Hmmm...how do I do that?


Edited by Noob C++, 17 May 2014 - 02:49 PM.


#5 rip-off   Moderators   -  Reputation: 8773

Like
1Likes
Like

Posted 17 May 2014 - 05:34 PM

Let's break down the error. The source is ld.exe, which is the Linker. The Linker's job is to produce an executable from the various object files, and any libraries. The message mentions C:\Users\DMC\Desktop\SDL\main.exe, so this would be the executable you're building. The message says it cannot open the file due to a permission error. Windows is designed such that any executable file which currently has a running process cannot be modified or deleted. A very likely source of this error is that your program is still running, but you're trying to recompile. There are other ways you could get this error but they are less likely.

How do you avoid this error? The simplest case is where you can see the program's UI Window - simply exit the program, perhaps using the red X in the corner, or hitting the Escape key if you've written your program to close in response to this. It can be handy to implement such a key in Debug mode to speed up development.

You might have a problem if you've introduced a bug in your code where it will not exit when told, or you might be running a program that enters an infinite loop / deadlocks before there is any Window to close.

In this case, if the process is launched from your IDE you may be able to "break into" it using the Debugger to investigate the source of the bug, or simple terminate it if you believe you know what is wrong.

If you cannot see a UI, and your IDE isn't running the process, you can open the Task Manager and try to locate the process there and terminate it. Be careful - if you terminate the wrong process, such as your IDE, you may lose any unsaved work!

If that still doesn't work, there are other possible causes, but as mentioned they are not very likely.

#6 Noob C++   Members   -  Reputation: 116

Like
0Likes
Like

Posted 17 May 2014 - 05:47 PM

Thanks for reply and I know what you mean....
 
My code

#include "SDL/SDL.h"

//The images
SDL_Surface* hello = NULL;
SDL_Surface* screen = NULL;

int main( int argc, char* args[] )
{

//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );

//Set up screen
screen = SDL_SetVideoMode(640, 320, 32, SDL_SWSURFACE );

//Load image
hello = SDL_LoadBMP( "STARFIELDS.BMP" );

//Apply image to screen
SDL_BlitSurface( hello, NULL, screen, NULL );

//Update Screen
SDL_Flip( screen );

//Pause
SDL_Delay( 2000 );

//Free the loaded image
SDL_FreeSurface( hello );

//Quit SDL
SDL_Quit();

return 0;
}


Edited by Noob C++, 17 May 2014 - 05:47 PM.


#7 rip-off   Moderators   -  Reputation: 8773

Like
0Likes
Like

Posted 17 May 2014 - 05:49 PM

Thanks for reply and I know what you mean....

To me, this reads like you understand the problem and how to solve it in future ... but then you also posted your code, do you have another question?

#8 Noob C++   Members   -  Reputation: 116

Like
0Likes
Like

Posted 18 May 2014 - 08:11 AM

I was showing what my code but is there where key can press by user if he/she want press escape key to quit?



#9 rip-off   Moderators   -  Reputation: 8773

Like
0Likes
Like

Posted 18 May 2014 - 10:06 AM

That program looks like it would quit automatically after about two seconds, provided no errors occur which would cause it to behave otherwise. If you want it to respond to the close window button, or to the escape key, you'd need to add a little input loop.

While in practise an error (e.g. no STARFIELDS.BMP file is found) may either be compensated for by checks in the rest of the code, or may cause a segfault, that you are doing no error checking and recovery means that it is possible that your program invokes undefined behaviour, which means that your process might do unexpected things (such as hang).

Here is your program but with error checking added to the initialisation functions:
#include "SDL.h"
#include <iostream>

//The images
SDL_Surface* hello = NULL;
SDL_Surface* screen = NULL;

int main( int argc, char* args[] )
{
    //Start SDL
    if(SDL_Init( SDL_INIT_EVERYTHING ) < 0) {
        std::cerr << "Failed to initialise SDL: " << SDL_GetError() << std::endl;
        return 1;
    }

    //Set up screen
    screen = SDL_SetVideoMode(640, 320, 32, SDL_SWSURFACE );
    if(!screen) {
        std::cerr << "Failed to set video mode: " << SDL_GetError() << std::endl;
        SDL_Quit();
        return 1;
    }

    //Load image
    hello = SDL_LoadBMP( "STARFIELDS.BMP" );
    if(!hello) {
        std::cerr << "Failed to load image: " << SDL_GetError() << std::endl;
        SDL_Quit();
        return 1;
    }

    //Apply image to screen
    SDL_BlitSurface( hello, NULL, screen, NULL );

    //Update Screen
    SDL_Flip( screen );

    //Pause
    SDL_Delay( 2000 );

    //Free the loaded image
    SDL_FreeSurface( hello );

    //Quit SDL
    SDL_Quit();

    return 0;
}
SDL_BlitSurface() and SDL_Flip() can also fail, so for full correctness you'd need to add similar logic at these points too.




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