Using cygwin-dll with msvc-exe
Brian Inglis
Brian.Inglis@SystematicSw.ab.ca
Tue Jun 30 14:45:23 GMT 2020
On 2020-06-30 01:15, Kristian Ivarsson via Cygwin wrote:
> [snip]
>
>> They have incompatible internal startup and runtime environments including
>> stuff like initialization, signal, and exit function handling
>> (cygwin/newlib/gcc vs
>> Windows/APIs/VC) although Cygwin can build Windows-loadable dlls and
>> Windows-runnable exes and call Windows (system) dlls that don't depend on
>> msvcrt.
> What is interesting is that ldd on cygwin1.dll says it depends on
> msvcrt.dll, but that might not be a problem ?
That might not be accurate:
$ cygcheck cygwin1.dll
Found: C:\...\cygwin64\bin\cygwin1.dll
C:\...\cygwin64\bin\cygwin1.dll
C:\Windows\system32\KERNEL32.dll
C:\Windows\system32\ntdll.dll
C:\Windows\system32\KERNELBASE.dll
> It seems like you could somehow fix it with this trick
> https://cygwin.com/faq/faq.html#faq.programming.msvs-mingw (though I don't
> really understand what difference it would make, because something seems to
> be missing in the explanation (or more probably there's something I don't
> understand;-) and it seems to be a bit cumbersome as well if you're having a
> large product with a long lifetime)
That says you could build Cygwin apps using MS VC/VS, but must first build all
libraries you use, including cygwin, as MS VC/VS compatible DLLs using gcc,
impdef, and lib, and call their routines via Windows APIs, as they duplicate
msvcrt routines. Both cygdrop and cygrunsrv do something similar:
$ cygcheck cygdrop
Found: C:\...\cygwin64\bin\cygdrop.exe
C:\...\cygwin64\bin\cygdrop.exe
C:\...\cygwin64\bin\cygwin1.dll
C:\Windows\system32\KERNEL32.dll
C:\Windows\system32\ntdll.dll
C:\Windows\system32\KERNELBASE.dll
C:\Windows\system32\ADVAPI32.dll
C:\Windows\system32\msvcrt.dll
C:\Windows\system32\SECHOST.dll
C:\Windows\system32\RPCRT4.dll
$ cygcheck cygrunsrv
Found: C:\...\cygwin64\bin\cygrunsrv.exe
C:\...\cygwin64\bin\cygrunsrv.exe
C:\...\cygwin64\bin\cygwin1.dll
C:\Windows\system32\KERNEL32.dll
C:\Windows\system32\ntdll.dll
C:\Windows\system32\KERNELBASE.dll
C:\Windows\system32\ADVAPI32.dll
C:\Windows\system32\msvcrt.dll
C:\Windows\system32\SECHOST.dll
C:\Windows\system32\RPCRT4.dll
C:\Windows\system32\USER32.dll
C:\Windows\system32\win32u.dll
C:\Windows\system32\GDI32.dll
Msys/2/Mingw allow Windows apps to be built by them or their Mingw Cygwin
packages, to run natively/standalone under Windows, so they can be used when
building, installing, or maintaining Cygwin, including e.g. cygcheck and setup:
$ cygcheck cygcheck
Found: C:\...\cygwin64\bin\cygcheck.exe
C:\...\cygwin64\bin\cygcheck.exe
C:\Windows\system32\ADVAPI32.dll
C:\Windows\system32\msvcrt.dll
C:\Windows\system32\ntdll.dll
C:\Windows\system32\KERNELBASE.dll
C:\Windows\system32\SECHOST.dll
C:\Windows\system32\RPCRT4.dll
C:\Windows\system32\KERNEL32.dll
C:\Windows\system32\PSAPI.DLL
C:\Windows\system32\USER32.dll
C:\Windows\system32\win32u.dll
C:\Windows\system32\GDI32.dll
C:\Windows\system32\WININET.dll
$ cygcheck setup-x86_64
Found: C:\...\setup-x86_64.exe
C:\...\setup-x86_64.exe
C:\Windows\system32\ADVAPI32.dll
C:\Windows\system32\msvcrt.dll
C:\Windows\system32\ntdll.dll
C:\Windows\system32\KERNELBASE.dll
C:\Windows\system32\SECHOST.dll
C:\Windows\system32\RPCRT4.dll
C:\Windows\system32\KERNEL32.dll
C:\Windows\system32\COMCTL32.dll
C:\Windows\system32\GDI32.dll
C:\Windows\system32\win32u.dll
C:\Windows\system32\USER32.dll
C:\Windows\system32\ole32.dll
C:\Windows\system32\combase.dll
C:\Windows\system32\bcryptPrimitives.dll
C:\Windows\system32\PSAPI.DLL
C:\Windows\system32\SHELL32.dll
C:\Windows\system32\SHLWAPI.dll
C:\Windows\system32\WININET.dll
C:\Windows\system32\WS2_32.dll
> In my honest opinion I think this disability to use cygwin-libraries from
> windows-applications kind of limits some of cygwins purpose, but I do still
> think cygwin is a great open source project ;-)
You have a choice under Cygwin of:
- using Cygwin POSIX libraries with the Cygwin Unix emulation interface,
allowing you to build and run most packages that run under Unix, without system
(e.g. BSD, Darwin/MacOSX, or Linux) dependencies, including Cygwin/X to build
and run X Window packages, or else
- using Mingw packages and utilities with the Windows APIs.
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in IEC units and prefixes, physical quantities in SI.]
More information about the Cygwin
mailing list