[SOLVED] Distributing an SDL app

ARC

Member
Joined
Oct 21, 2014
Posts
6
I have created an SDL game in visual Studio 2012 that I want to share with people. I've tried packaging the .exe in with all the .dll files and resources yet when it is opened on another computer I get a msvcp110.dll missing from computer error.
To fix this I read that you could install the C++ re-distributable for Visual Studio 2012 so after trying this I got a different error saying msvcp110D.dll was missing from the computer. Reading up on this people said that the solution was "The solution to this problem is to recompile all of your code and dependent libraries/dlls with the same compiler". So I tried compiling my program in visual studio C++ 2010 but now the SDL app will not load any of the textures.
Code:
 //Create texture from surface pixels        newTexture = SDL_CreateTextureFromSurface( gRenderer, loadedSurface );
        if( newTexture == NULL )
        {
            printf( "Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError() );
        }
This returns the error for every texture.
 
Welcome to Sysnative :)

The Stack Overflow Q&A where you got that quotation from is a bit misleading because it was answering the very specific problem experienced by the OP. It should not be interpreted in the completely general case. The fact that the program works on your computer perfectly is a good indication is that this is neither a mixed library issue nor a mixed binding issue.

Instead, we need to look at what msvcpxxxD.dll actually is. Quite simply, it's the Debug version of the VC++ runtime library of whichever version xxx. Your system has both the release and debug runtime libraries installed (the debug version comes with Visual Studio). Hence the program works for you. Your friend though - when you install the release redistributables off the Microsoft website, will only have the release version of the redists. But you provided a debug build which needs the debug libraries, hence this problem.

So, the solution is to undo whatever changes you made so that SDL & your program now works again, then simply recompile the program into a release binary and send that to your friend, not the debug version. Hopefully that should work for you.

Richard
 
Last edited:
So, the solution is to undo whatever changes you made so that SDL & your program now works again, then simply recompile the program into a release binary and send that to your friend, not the debug version. Hopefully that should work for you.

Richard

Same thing I was going to say in much more words :lolg:



In the build menu at the top there should be a compile/build release(not sure the wording as I am on 2010). Doing that should build the standalone executable.
 
Thanks for the reply.
I've tried compiling it as a release but since there is not "compile/build release" option I can find on the toolbar I went to project properties and changed the configuration from debug to release. When I compile now it creates a new folder called 'Release' where it stores the .exe but now some of my code is broken that was not before. Such as an array which is causing an "Access violation reading location" error.
 
Please show me how you're including & linking SDL. Please also make sure that "Runtime Library" is set to "Multi-threaded DLL" & that you're using the release versions of SDL. Does any of that solve the problem? If not, show us the code, preferably a Short, Self-Contained, Correct, Example: Short, Self Contained, Correct Example
 
This is how I'm including SDL: how im includeing SDL.png additional dependencies.png

I downloaded the runtime binaries from the SDL image and mixer etc websites and put those in the release folder where the .exe is. I can now run my app from within Visual Studio with the local windows debugger however when I try and run the .exe it says ...exe has stopped working, windows is checking for a solution to the problem. I've made sure runtime library is set to "Multi-threaded DLL"
 
Upon closing visual studio and re-opening my project I can no longer run my app within it as im back to getting the same "Access violation reading location" exception. Here is the code that is throwing the exception:
Code:
int pixWallFull[3201][3201];
Code:
for(int ix = 0; ix<3202;ix++)    
{
        for(int iy = 0; iy<3202;iy++)
        {
            pixWall[ix][iy] = 0;
            pixWallFull[ix][iy] = 0;
        }
}
Code:
for (int i = 0; i<enemyLength; i++)
            {
                int isInWall = false;
                do{
                    isInWall = false;
                    enemy[i].set_XPos(GetRandomNumber(0, mapWidth));
                    enemy[i].set_YPos(GetRandomNumber(0, mapHeight));                
                    for(int cx = enemy[i].collisionBox.x ; cx<=enemy[i].collisionBox.x + enemy[i].collisionBox.w; cx++)
                    {
                        for(int cy = enemy[i].collisionBox.y ; cy<=enemy[i].collisionBox.y + enemy[i].collisionBox.h; cy++)
                        {
                            if(pixWallFull[cx][cy] == 1) [COLOR=#ff0000][B]​This is what throws the exception[/B][/COLOR]
                            {
                                isInWall = true;
                            }
                            //In center game area
                            if(cx > 870 && cx<1850 && cy>700 && cy<1100)
                                isInWall = true;


                        }
                    }
                    
                }while(isInWall);
                
            }
 
Let's consider a smaller array.

type arr[3];

This is an array containing three element. C++ zero indexes, so we have arr[0], arr[1], arr[2]. arr[3] would be outside of the bounds of arr since this is now the fourth element in an array of size 3. In general, given type arr2[len];, it's valid to access up to arr2[len-1].

Your line "int ix = 0; ix<3202; ix++" runs ix from 0 to 3201 (which is the greatest integer less than 3202). Same for iy. You then use these results directly in pixWallFull[ix][iy] = 0; But that means you're accessing pixWallFull[3201][3201], and given the definition of pixWallFull [int pixWallFull[3201][3201];], that is outside of the bounds of the array --> access violation.

So, either redefine pixWallFull to have [3202][3202] elements, or change "ix<3202" to "ix<3201".

Richard
 
Thanks again for the help

Ok, so I've redefined the array to have [3202][3202] elements yet this code (as shown in my previous reply) still throws the exception.
Code:
if(pixWallFull[cx][cy] == 1)
{
    isInWall = true;
}

What is confusing me is the fact this array worked when I was in debug mode but now im trying to create a release build the code has broken.

I've tried commenting out this if statement and building then. I've sent that to Stephen and he can run the app fine.
 
Thanks again for the help

Ok, so I've redefined the array to have [3202][3202] elements yet this code (as shown in my previous reply) still throws the exception.
Code:
if(pixWallFull[cx][cy] == 1)
{
    isInWall = true;
}

What is confusing me is the fact this array worked when I was in debug mode but now im trying to create a release build the code has broken.

I've tried commenting out this if statement and building then. I've sent that to Stephen and he can run the app fine.

Just to get this straight, is it that after you altered stuff to try to get Release mode working, the program broke for both Debug & Release modes, or does the program work perfectly now if you put it back into Debug mode?

If it's the latter, remember that the project properties are stored independently for Release and Debug. Unless you remember to select "All Configurations" every time you altered a setting, any property alterations you made would have been on the Debug build only. Go through all properties that have been altered in Debug build (shown in bold) and check that they are correct in Release mode too. And check that there aren't any weird settings in Release mode set.

If it's the former, it's likely to be the code at fault & I can look into that in more detail next. I'm still going down the setting route though because I'm sort of worried it's a shared/unshared heap issue as a result of a mixed binding problem, or something else weird like that.

Finally, if you break into the exception, what are the values of cx and cy? Are they sensible? And does pixWallFull point to the same block of memory it does at the beginning of the program?

Richard
 
Switching the program to debug mode means that the program works fine so I tried making sure all the project settings were correct in Release mode too. After changing some the program now works! Hooray.

Thanks for the help
Andrew
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top