My goal is to create a dll created in mingw that I can call
from a Visual Basic application. The code was initially written on a Linux box
and I'm trying to get it to work on Windows. It compiles in cygwin, but I
would like to create a Visual Basic front end.
What I first did was the following:
$gcc -shared -mrtd -mno-cygwin -o foo.dll foo.c
I was able to get foo.dll to work. However, I had problems
using the -mno-cygwin flag when I tried to compile other components.
I read what Mumit Khan suggested and added his files to
/usr/local/mingw, and then tried to compile again with "-mno-cygwin"
flag with the -I/usr/local/mingw/include and the -L/usr/local/mingw/lib
options. However, this still failed to fully compile.
I then installed mingw into c:/mingw and followed the
directions in the FAQ - "How do I use MinGW with Cygwin?"
However, I'm not too sure what options to give my gcc
compiler. Do I just get rid of the -mno-cygwin flag? I tried that and the
simplest case of foo.dll now doesn't work. It compiles, but when I try to use
it from the VB application, it crashes.
I then tried to follow the directions in the FAQ "How
can an MSVC program call a MinGW DLL, and vice versa?"
What I did was run the following commands:
$gcc -shared -o foo.dll foo.c
-Wl,--output-def,foo.def,--out-implib,libfoo.a
$lib /machine:i386 /def:foo.def
$cl foo.c foo.lib
This creates the file foo.exe and foo.obj. The exe works,
and I can execute it from the command line. However, I want a dll that I can
call from a VB program. The dll that is created using the above 3 steps
depends on cygwin1.dll, and even with it doesn't seem to work, as it crashes my
VB program.
Any suggestions would be appreciated.
Thanks,
Ted