Your experience matches mine: the Cygwin ldd utility does not work properly
with MinGW DLLs and prints a bunch of question marks.  There is an ntldd
utility you can use instead.  If it's not on your path already, I'm not
sure the best way to obtain it.  I just use MSYS2, because it's basically a
fork of Cygwin that makes it easy to install MinGW compilers and all the
other open source utilities you would need to build software on Linux,
including ntldd.

--David

On Wed, Mar 6, 2019 at 4:44 AM Matthias Apitz <g...@unixarea.de> wrote:

>
>
> Hello,
>
> We have some bigger Java applications running as fat clients on
> Windows PC. These clients are using some Windows services, for example for
> printing, through some DLL written in C++ many years ago and then only
> compiled as 32-bit DLL. Moving forward to OpenJDK 1.8 with a 64-bit JRE
> we now struggle with compiling these DLL to a 64-bit version and I proposed
> here in my company to give mingw-w64 a try. I installed the recent version
> of mingw-w64 into Cygwin and can produce the 64-bit DLL this way (more or
> less without going through all details):
>
> LANG=C export LANG
> CC=/usr/bin/x86_64-w64-mingw32-gcc.exe
> DLL=SiPrinter_x64.dll
>
> for i in *.cpp; do
>     ${CC}  -I/home/apitzm/jdk1.8.0_202/include
> -I/home/apitzm/jdk1.8.0_202/include/win32 -c ${i}
> done
>
> ${CC} -shared -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -o ${DLL} *.o
> -lwinspool -lstdc++ -lgdi32 -lcomdlg32
>
> The resulting SiPrinter_x64.dll causes in Java a class loader exception
> because
> there is someting missing:
>
> $ ldd SiPrinter_x64.dll
>         ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x77890000)
>         kernel32.dll => /cygdrive/c/Windows/system32/kernel32.dll
> (0x77770000)
>         KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll
> (0x7fefd660000)
>         ??? => ??? (0x69640000)
>         ^^^^^^^^^^^^^^^^^^^^^^^   ????
>
> and the loader exception is:
>
> java.lang.UnsatisfiedLinkError:
> C:\Users\apitzm\vb\SunRise\SRv70\Ausleih-Client\bin\SiPrinter.dll: Can't
> find dependent libraries
>         at java.lang.ClassLoader$NativeLibrary.load(Native Method)
>         at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
>         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
>         at java.lang.Runtime.loadLibrary0(Runtime.java:870)
>         at java.lang.System.loadLibrary(System.java:1122)
>         at sisis.util.Printer.<clinit>(Printer.java:67)
>         at sisis.lib.drucker.GDIDrucker.<init>(GDIDrucker.java:132)
>         at sisis.app.btc.BTCApp.initDrucker(BTCApp.java:3419)
>         at sisis.app.btc.BTCApp.<init>(BTCApp.java:2840)
>         at sisis.app.btc.BTCApp.main(BTCApp.java:1865)
> Exception: System.loadLibrary()
>
> What is missing in the DLL, also seen as a problem by the ldd-command?
>
> Thanks
>
>         matthias
> --
> Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/
> +49-176-38902045
> Public GnuPG key: http://www.unixarea.de/key.pub
>
>
> _______________________________________________
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to