no message or dialog when a DLL is missing

Pierre Baillargeon pbaillargeon@innobec.com
Thu Aug 24 19:36:00 GMT 2006


Ok, first I want to show you the minimal test-case I built. Using Visual 
Studio 8, I created a solution containing two projects: a Win32 console 
application and a Win32 DLL. I deleted all the generated stuff and 
replaced them with a single file per project.

The console application project is called NoDLL and its file is called 
NoDLL.c:

__declspec( dllimport ) void __stdcall cant_touch_this();

int main(int argc, char* argv[])
{
     cant_touch_this();
     printf("World!\n");
	return 0;
}

The DLL project is called Missing and its file is called Missing.c:

__declspec( dllexport ) void __stdcall cant_touch_this()
{
     printf("Hello\n");
}

The console project is set to depend on the DLL project: Project menu, 
Project Dependencies... menu item, select the console application in the 
drop down combo-box, check mark the DLL in the list box below it. Now 
the console depends on the DLL and will be linked with its .lib file.

Now, after building the project, I have NoDLL.exe and Missing.dll in the 
same directory.

In a bash shell started from a shortcut (i.e. bash inside cmd.exe), I 
start NoDLL.exe. I get Hello World! as expected. I move the DLL 
elsewhere, now the program does nothing and the exit code (echo $?) is 128.

If I start the program right then in another Windows cmd.exe, i get a 
nice error dialog saying "This application has failed to start because 
Missing.dll was not found. Re-installing the application may fix this 
problem." With the title "NoDLL.exe - Unable To Locate Component". Same 
thing if I double click NoDLL.exe from Windows Explorer.

This difference in behavior was my reason to write in.

Now, about cygcheck. Two cases.

1. If the current directory is where NoDLL.exe and Missing.dll are. In 
this case, I get:

.\NoDLL.exe
   .\Missing.dll
     C:\WINDOWS\system32\KERNEL32.dll
       C:\WINDOWS\system32\ntdll.dll

or

.\NoDLL.exe
Error: could not find Missing.dll
   C:\WINDOWS\system32\KERNEL32.dll
     C:\WINDOWS\system32\ntdll.dll

2. If the current directory is *not* where NoDLL.exe and Missing.DLL 
are. In the case, I always get:

/path/to/where/the/program/is/NoDLL.exe - Cannot open

*Even* if Missing.DLL is present next to NoDLL.exe and NoDLL.exe and can 
be launchedproperly in bash!

Sorry, I was not able to rapidly make the DLL and executable with gcc. 
trying only to build the program, with the DLL already built by MSVC, 
using "gcc -mno-cygwin -L./Debug -lMissing NoDLL.c", resulted in 
"/cygdrive/c/Temp/ccMLHNI5.o:NoDLL.c:(.text+0x2b): undefined reference 
to `__imp__cant_touch_this@0'".

-- 
Pierre Baillargeon
Innobec

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list