Can't open program outside Visual Studio

Started by
4 comments, last by Datamancer 10 years, 8 months ago

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?

Advertisement

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.

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?

In theory you can statically link to allegro. Directions are here, though I've never done this myself.

Ok I'll look for it myself. Thanks

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.

"The code you write when you learn a new language is shit.
You either already know that and you are wise, or you don’t realize it for many years and you are an idiot. Either way, your learning code is objectively shit." - L. Spiro

"This is called programming. The art of typing shit into an editor/IDE is not programming, it's basically data entry. The part that makes a programmer a programmer is their problem solving skills." - Serapth

"The 'friend' relationship in c++ is the tightest coupling you can give two objects. Friends can reach out and touch your privates." - frob

This topic is closed to new replies.

Advertisement