Subject: RE: GCC and Visual Basic
From: [email-masked] (Jean-Francois Morcillo)

3 Jul 1998 14:19:09 -0700
Message-ID: <Pine.SOL.3.95.980703063318.15404A-100000.cygnus.gnu-win32@predator>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
To: Kevin Healey <[email-masked]>
Cc: [email-masked]

I may be wrong but in your example you're linking staticaly libbar.a
with main.o ?
So it doesn't mean you have created bar.dll.
When i created my own dll few years ago with borland C/C++ 3.1 and visual
basic 3. I had made a function called libmain in my dll, it's like the
main funtion but for dll. The borland documentation said that this
function was for initialisation of somme different parameters and that she
was called the first time the dll is called. So may be you have to creat
your libmain function ?

Tell me if that help you..

On Wed, 1 Jul 1998, Kevin Healey wrote:

> Well, actually I'm trying access my DLL from Visual Basic for Excel 97.  I
> have also tried to access it from PowerBuilder (which I believe uses the
> same calling convestions as VB).
> 
> The main problem seems to be that the DLL is not loading properly.  The
> error that I get from Visual Basic is:
> 
> "Run-time error '7': File not found: bar"
> 
> The error that I am getting from PowerBuilder is:
> 
> "Error opening DLL library bar.dll for external function."
> 
> These are the same errors that I get if the DLL (bar.dll) is not in the DOS
> PATH.  However, I am ABSOLUTLY certain that the DLL in is the DOS PATH.  It
> is also interesting to know that these are the same errors I get if I
> replace the DLL with a non-DLL file - like a text file.
> 
> These are not the errors that I get from a "good" DLL if the function is
> spelled incorrectly or its name has been mangled.
> 
> Its as if the system doesn't think that bar.dll is really a DLL, or there
> is something wrong with the way the DLL was compiled.
> 
> Furthermore, I HAVE been able to access the functions in bar.dll from an
> executable that was complided with GCC!
> 
> So here are the steps that I have taken to create my dll (remember that I
> am using mingw32):
> 
> 1) Create DLL source:
> ===> bar.c <========================================
> //Testing the creation of a DLL
> 
> #include <windows.h>
> 
> int WINAPI doit (int i)
> {
>      return(i + 10);
> }
> 
> 2) Create .DEF  file:
> ===> bar.def <======================================
> EXPORTS
> doit=doit@4
> ==================================================
> 
> Notice here that I have exported the function name "doit" for the internal
> function name "doit@4".  The @4 comes from using the STDCALL calling
> convension (or WINAPI).  I have done it this way because this is the only
> way I have been able to get an executable to link to the DLL with GCC.
> 
> 3) Run shell script to create the DLL (stright off of Colin Peter's Web
> Page):
> ===> makedll <======================================
> #create bar.o
> gcc -c bar.c
> 
> #create base.tmp (and junk.tmp which is then deleted)
> gcc -mdll -o junk.tmp -Wl,--base-file,base.tmp bar.o
> rm junk.tmp
> 
> #create temp.exp
> dlltool --dllname bar.dll --base-file base.tmp --output-exp temp.exp --def
> bar.def
> 
> #crete bar.dll
> gcc -mdll -o bar.dll bar.o -Wl,temp.exp
> 
> #delete temp.exp because we don't need it anymore
> rm temp.exp
> ===================================================
> 
> This will create bar.dll that can be linked to a GCC compiled executable as
> follows:
> 
> 1) Create source:
> ===> main.c <======================================
> // Main file to try linking with a DLL under mingw32
> 
> int
> main()
> {
>         printf("doit(5) returns %d\n", doit(5));
> }
> ====================================================
> 
> 2) Run shell script to create main:
> ===> main.def <======================================
> #create main.o
> gcc -c main.c
> 
> #create libbar.a (import library for bar.dll)
> dlltool --dllname bar.dll --def bar.def --output-lib libbar.a
> 
> #create main.exe using libbar.a
> gcc -o main.exe main.o -lbar
> ====================================================
> 
> So, why can't I call doit() from my Visual Basic application?
>

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