Pre-emptive Solution for 'The application was unable to start correctly (0x000007b)'

Started by
5 comments, last by gretty 7 years, 8 months ago

I thought if you compile a Visual-studio 2013 Win32 project using `/MT` Code Generation->Runtime library then it will automatically package all dependency dll's - including 3rd party dll's - into the executable?

Currently certain users get an error when running my .exe. Its related to not having a 3rd party dll (OpenSSL):

The program can't start because LIBEAY32.dll is missing from your computer

This error has occurred for users using my .exe on Windows 10 OS's. How can I ensure all dependency dll's are packaged into my .exe?

I currently compile my application on my 64bit Windows 8.1 OS. The win32 visual-studio project is compiled using the following project properties:

  • Character Set: Unicode char set
  • Use of MFC: Use standard windows libraries
  • Whole Program Optimisation: Use Link Time Code Generation
  • Debug info format: none
  • Code Generation->Runtime library: /MT
Advertisement

I thought if you compile a Visual-studio 2013 Win32 project using `/MT` Code Generation->Runtime library then it will automatically package all dependency dll's - including 3rd party dll's - into the executable?


That is absolutely not the case. The /MT switch links the static C++ runtime. If you use any 3rd party dependencies you will have to ensure you compile them to static libraries and link to those. Note that getting some libraries to compile in this way can take some knowledge and work since a lot of projects are not intended to be used that way. There are also potentially problematic license issues unless you originally picked your libraries with an eye towards that.
You are very lucky because you get a very detailled, descriptive error message. Normally, Windows pukes out some "Unable to start" bullshit without telling you what's wrong. You then have to fire up dependency walker and check every DLL and do an educated guess what may be wrong.

Often, it's a 64-bit DLL bein in PATH and thus being loaded (duh, very intelligent, thank you) in a 32 bit process (whenever I have this particular problem, it is (99.975%) libstdc++6.dll).

In your case, the message is very clear:

LIBEAY32.dll is missing

Include that file in your installer (or zip file) so it's in the application's directory, and you're good.

I am linking the static OpenSSL libraries so shouldn't I not need to distribute the dll with my installer? Shouldnt it be packaged into the exe?

My Linker->Input->Additional Dependencies are:

C:\OpenSSL-Win32\lib\VC\static\libeay32MTd.lib

C:\OpenSSL-Win32\lib\VC\static\libeay32MT.lib

C:\OpenSSL-Win32\lib\VC\static\libeay32MD.lib

C:\OpenSSL-Win32\lib\VC\static\libeay32MDd.lib

C:\OpenSSL-Win32\lib\VC\static\ssleay32MTd.lib

C:\OpenSSL-Win32\lib\VC\static\ssleay32MT.lib

C:\OpenSSL-Win32\lib\VC\static\ssleay32MD.lib

C:\OpenSSL-Win32\lib\VC\static\ssleay32MDd.lib

Then either those are not built correctly as static libraries or something else you are linking pulls in a dynamic OpenSSL dependency. If you changed those dependencies recently it's also possible (though unlikely) that you need to force a complete rebuild of the project.

You can also see if you can set the linker to verbose. It should then list every library it is linking and you can verify you are only linking exactly what you expect. Even if you made no mistakes yourself all it takes is a single well-hidden #pragma comment(lib, ...) to screw you over.

I am linking the static OpenSSL libraries so shouldn't I not need to distribute the dll with my installer? Shouldnt it be packaged into the exe?

My Linker->Input->Additional Dependencies are:

C:\OpenSSL-Win32\lib\VC\static\libeay32MTd.lib

...

C:\OpenSSL-Win32\lib\VC\static\libeay32MD.lib

C:\OpenSSL-Win32\lib\VC\static\libeay32MDd.lib

C:\OpenSSL-Win32\lib\VC\static\ssleay32MTd.lib

...

C:\OpenSSL-Win32\lib\VC\static\ssleay32MD.lib

C:\OpenSSL-Win32\lib\VC\static\ssleay32MDd.lib

Bear in mind that libraries with a "d" at the end are generally debug libraries, and you probably don't want them being used in the release version of your code.

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

Typically, that error code usually deals with conflicts for 32 and 64-bit libraries. Had this issue occur several times, sometimes because the dll being loaded is for the wrong arch, other times because a 32-bit exe header is missing information necessary to be run on a 64-bit version of Windows.

Excuse me if I am ignorant of this, but I noticed that there is a 32 at the end of each library. Are you compiling for 64-bit or just compiling on a 64-bit Windows installation? If it's the latter, have you run into the same issue on 32-bit Windows?

I am linking the static OpenSSL libraries so shouldn't I not need to distribute the dll with my installer? Shouldnt it be packaged into the exe?

My Linker->Input->Additional Dependencies are:

C:\OpenSSL-Win32\lib\VC\static\libeay32MTd.lib

...

C:\OpenSSL-Win32\lib\VC\static\libeay32MD.lib

C:\OpenSSL-Win32\lib\VC\static\libeay32MDd.lib

C:\OpenSSL-Win32\lib\VC\static\ssleay32MTd.lib

...

C:\OpenSSL-Win32\lib\VC\static\ssleay32MD.lib

C:\OpenSSL-Win32\lib\VC\static\ssleay32MDd.lib

Bear in mind that libraries with a "d" at the end are generally debug libraries, and you probably don't want them being used in the release version of your code.

Quoted for truth. Too easy to assume one is already aware of this.

Shogun.

Are you compiling for 64-bit or just compiling on a 64-bit Windows installation?

I am compiling just using the 32bit static libraries (on my 64bit Windows 8.1 OS) in the hopes that I can just cover everyone (correct me if I am wrong about this?). My application is a simple WinAPI c++ utility application. So it's small (<800kb) so it doesn't make sense to distribute the visual c++ redistributable package with my installer. What I am hoping is to package all dependencies (I only use static libraries) into my .exe if possible.

This topic is closed to new replies.

Advertisement