Cannot use Cygwin64 with MSVC 64-bit DLL

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot use Cygwin64 with MSVC 64-bit DLL

Cygwin list mailing list
Hi all

I am ultimately trying to use Cygwin 64-bit to port a Solaris server application which uses the Informix Client SDK.  However, the Win64 version of that product comes as a binary-only distribution of DLLs built by MSVC .

I have managed to reproduce the problem in a simple test case.  I made a full writeup here: https://stackoverflow.com/questions/61812131/

In brief, linking a 64-bit DLL created by MSVC with early binding to any program built with /usr/bin/gcc  (or /usr/bin/g++) produces a runtime error "The procedure entry point __cxa_atexit could not be located in the dynamic link library F:\temp\mre.exe"​ .  (Also, if the executable is launched from the Cygwin shell no output appears; I see this error popup by launching from command prompt).

However the testcase does work correctly if I use late binding (i.e. LoadLibrary and GetProcAddress).  But this is a considerable nuisance in comparison to early binding (i.e. linking against the DLL's import library).  It also works correctly under MSYS2 , and native-target mingw-w64.  Only Cygwin64 early-binding exhibits the problem.

I don't have the option of trying to rebuild the import library as suggested in comments to my SO question, as the Informix DLL is stripped .  I would like to use Cygwin as opposed to MSYS2 because the application uses SYSV IPC which is supported by Cygwin. So I need to either resolve this problem, create my own "import library" with late binding thunks for every function, or rewrite the SYSV IPC stuff to WinAPI stuff and use MSYS2 instead. Hoping the first of those three options turns out to be possible!

Regards,
M.M.
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: Cannot use Cygwin64 with MSVC 64-bit DLL

Cygwin list mailing list
On 17.05.2020 23:03, Old Wolf via Cygwin wrote:

> Hi all
>
> I am ultimately trying to use Cygwin 64-bit to port a Solaris server application which uses the Informix Client SDK.  However, the Win64 version of that product comes as a binary-only distribution of DLLs built by MSVC .
>
> I have managed to reproduce the problem in a simple test case.  I made a full writeup here: https://stackoverflow.com/questions/61812131/
>
> In brief, linking a 64-bit DLL created by MSVC with early binding to any program built with /usr/bin/gcc  (or /usr/bin/g++) produces a runtime error "The procedure entry point __cxa_atexit could not be located in the dynamic link library F:\temp\mre.exe"​ .  (Also, if the executable is launched from the Cygwin shell no output appears; I see this error popup by launching from command prompt).
>
> However the testcase does work correctly if I use late binding (i.e. LoadLibrary and GetProcAddress).  But this is a considerable nuisance in comparison to early binding (i.e. linking against the DLL's import library).  It also works correctly under MSYS2 , and native-target mingw-w64.  Only Cygwin64 early-binding exhibits the problem.
>
> I don't have the option of trying to rebuild the import library as suggested in comments to my SO question, as the Informix DLL is stripped .  I would like to use Cygwin as opposed to MSYS2 because the application uses SYSV IPC which is supported by Cygwin. So I need to either resolve this problem, create my own "import library" with late binding thunks for every function, or rewrite the SYSV IPC stuff to WinAPI stuff and use MSYS2 instead. Hoping the first of those three options turns out to be possible!
>
> Regards,
> M.M.
> --


the __cxa_atexit is available from the cygwin1.dll itself.
Have you tried to add "-lcygwin" at the end of your command line:

g++ -o mre.exe mre.cc /f/temp/simpledll/x64/Debug/simpledll.lib -lcygwin

As it should be the default linking, I doubt it is that the root cause.

May be the difference is in the 64 bit models

https://cygwin.com/cygwin-ug-net/programming.html#gcc-64

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