Sign in to follow this  
Devil0150

Can't open program outside Visual Studio

Recommended Posts

Devil0150    156

Hi,

 

I made a simple 2D game using the allegro library. When I run it inside Visual Studio, it works fine, both in the release and debug builds.

But when I open the exe file in windows explorer I get an error message:

First it said: "The program can't start because allegro-4.4.2-md.dll is missing from your computer. Try reinstalling the program to fix the problem."

So I pasted that file in the same folder as the exe. And I got the same error message, but for another file, "libgcc_s_dw2-1.dll".
I pasted that file in there folder too, and started the exe again. Now, a blank window opens, and I get an error message:
(Project2.exe has stopped working. Close program or check online for solution).

 

What do I do with this?

Share this post


Link to post
Share on other sites
Brother Bob    10344

Check your working directory if you are opening files within your program. When executing the program from Visual Studio, the working directory is normally not where the application is, but where the project is. If you try to open a file with a relative path, the relative path will not be relative to your program but relative to your project.

 

If you instead, say, double click the file in explorer, the working directory is typically where the application is and any file structure in your Visual Studio project will be wrong.

Share this post


Link to post
Share on other sites
Devil0150    156

I fixed it. I had made just a simple mistake. I had forgot to put the .jpg files needed in the same folder as the exe.
What about the two dll files. Is there any way to build/link the program so I don't need them to open the program?

Share this post


Link to post
Share on other sites
ByteTroll    3035

I fixed it. I had made just a simple mistake. I had forgot to put the .jpg files needed in the same folder as the exe.
What about the two dll files. Is there any way to build/link the program so I don't need them to open the program?

 

The error you posted is Windows telling you that it can not find the dynamic link libraries (DLL's) that the program needs to run.  Putting the ".jpg" files in the in the working directory should not have fixed this issue.

 

As far as the second part of that question, yes there is a way to link them, and the way you are looking for called static linking.  I think Allegro provides a static build.  You will want to link those libraries instead of the dynamic libraries.

 

@EDIT: My bad, I could not see the rest of the question on my phone.  I did not catch the part where you said you copied the DLL's to the folder.  The second error will be fixed by copying the files.

Edited by ByteTroll

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this