Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can an MSVC program call a MinGW DLL, and vice versa?

DLL mingw msvc program versa
0
Posted

How can an MSVC program call a MinGW DLL, and vice versa?

0

Assume we have a testdll.h, testdll.c, and testmain.c. In the first case, we will compile testdll.c with MinGW, and let the MSVC-compiled testmain call it. You should use gcc -shared -o testdll.dll testdll.c \ -Wl,–output-def,testdll.def,–out-implib,libtestdll.a to produce the DLL and DEF files. MSVC cannot use the MinGW library, but since you have already the DEF file you may easily produce one by the Microsoft LIB tool: lib /machine:i386 /def:testdll.def Once you have testdll.lib, it is trivial to produce the executable with MSVC: cl testmain.c testdll.lib Now for MinGW programs calling an MSVC DLL. We have two methods. One way is to specify the LIB files directly on the command line after the main program. For example, after cl /LD testdll.c use gcc -o testmain testmain.c testdll.lib The other way is to produce the .a files for GCC. For __cdecl functions (in most cases), it is simple: you only need to apply the reimp tool from Anders Norlander (since his web site is no longer avai

0

• There exists two methods, both described in MSVC_and_MinGW_DLLs.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123