Mail Archives: cygwin/1998/07/06/13:08:12
For whats its worth, I got an error when doing the,
gcc -mdll -o junk.tmp -Wl,--base-file,base.tmp bar.o
It said something like win AT main16 or win16 AT main undefined, which
according to nm on libcygwin.a lives there. Actually I suspect that
im at fault for not using ming, but there you go :-)
Does anyone have clean, clear and tested instructions for creating a dll
with just cygnus, and not ming. I have several libraries that I really
want to start attempting to port, and this would help me *tremendously*.
Failing that, I guess I will have to see what the VC5++ help pages
say, and try the equivalent.
>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 AT 4
>> ==================================================
>>
>> Notice here that I have exported the function name "doit" for the internal
>> function name "doit AT 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
------------------------------------------
Darren Evans 0171 573 5961
Systems Engineer FAX 0171 573 5959
Systems Operation Group
Online Magic Ltd
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -