Subject: Visual Basic and GCC
From: [email-masked] ("Giandomenico De Sanctis")

2 Aug 1997 14:31:11 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook Express 4.71.0544.0
Original-To: <[email-masked]>
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE Engine V4.71.0544.0
Original-Sender: [email-masked]

For who is interested using GNU C-Win32 with Visual Basic, I follow this
steps:
Note: I installed the Minimal GCC-Win32, then the note is referred at this
package;
also, the installation is on Win 95, I not have any experience with Win NT

1) compiling a C DLL, callable by VB 4:
 1.1- prepare the .DEF file with the functions exported by the library, for
example
         EXPORTS
         func1
         func2
 1.2- execute the dlltool utility ('myl' is the name of library in the
example):
dlltool --def myl.def --output-exp myl.exp --output-lib myl.a --dllname
myl.dll
 with this you obtained the .EXP file for use in successive step, and the
..A file
 for using the DLL in others C/C++ programs
 1.3- compile/link the DLL with:
gcc -o myl.dll myl.c myl.exp -dll -mrtd  -windows -mpentium
 use '-windows' only if the DLL call any Win functions; '-mpentium'
optimize the
 code for Pentium, use '-m386' or '-m486' for other processors; '-mrtd' is
essential,
 because force the use of the STDCALL calling convention, that is also used
by VB 4
 With this step you obtain the MYL.DLL.
 1.4- if you want debug the DLL, only by a C calling test program, not by
VB, add the
 '-ggdb3' parameter; after, to debug execute
gdb testp.exe
 assuming 'testp.exe' is the test C program
 1.5- remember that VB 4 integer type correspond to short C type (2 bytes)
in Win32,
 because the integer C type is 4-bytes long

2) obtaining a link definition file to use an existing DLL with a GCC
program/DLL:
 2.1- if you have the MS Visual C .LIB file for the library, prepare the
list
 of exported functions with:
nm exil.lib >exil.def
 (of course, 'exil' is the existing library)
 manually edit exil.def, leaving only the names of exported functions,
without
 leading underscore, but leaving the trailing @xx if any
 2.2- if you not have the .LIB, in explorer right click on the DLL file,
 and choose preview; then, manually (the clipboard is not active !)
 annotate the names of functions, and prepare the .DEF file
 2.3- execute dlltool:
dlltool -k --def exil.def --output-lib exil.a --dllname exil.dll
 the '-k' option eliminate the trailing @xx from function names in the .A
files,
 and is necessary when using the STDCALL convention (then, always when
compiling
 DLL for VB).

<GiDeSa> 

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".