* DLL help needed
@ 1998-11-08 2:27 Carlos Albar-Diaz
0 siblings, 0 replies; 9+ messages in thread
From: Carlos Albar-Diaz @ 1998-11-08 2:27 UTC (permalink / raw)
To: gnu-win32
I am not able to use my mingw32-built DLLs from MS Excel. The problem seems to be the DLLs need to use the __stdcall convention, and the instructions/makefiles I have are for _cdecl convention.
How do I make a dll from an .o file that contains a function defined woth __stdcall? How do I find out the mangling of the function name? Mumit's makefiles do all this OK until I put __stdcall in the function.
I have browsed the files but none of the "recipes" I saw work with __stdcall.
I will greatly appreciate your help.
Carlos
-----
Free e-mail group hosting at http://www.eGroups.com/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: DLL help needed
1998-11-14 3:05 ` Carlos Albar-Diaz
@ 1998-11-14 8:41 ` Mumit Khan
0 siblings, 0 replies; 9+ messages in thread
From: Mumit Khan @ 1998-11-14 8:41 UTC (permalink / raw)
To: Carlos Albar-Diaz; +Cc: gnu-win32
"Carlos Albar-Diaz" <carlosad@yahoo.com> writes:
> I have failed in my attempt to modify Mumit's "dllhelpers" package to
> create dlls from WINAPI/__stdcall functions. It works all right when
> the function inputs/outputs are integers, but it fails when I try to
> use floats or doubles.
It's a bug in GCC (incorrectly pops floating point stack in addition to
the regular one!), and has been reported. Unfortunately, I have no idea
when it will be fixed.
You're right that this bug pretty much kills the prospect of using EGCS
to produce loadable functions for VB etc which require WINAPI.
Regards,
Mumit
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: DLL help needed
1998-11-09 7:48 ` Jens Yllman
@ 1998-11-14 3:05 ` Carlos Albar-Diaz
1998-11-14 8:41 ` Mumit Khan
0 siblings, 1 reply; 9+ messages in thread
From: Carlos Albar-Diaz @ 1998-11-14 3:05 UTC (permalink / raw)
To: gnu-win32
I have failed in my attempt to modify Mumit's "dllhelpers" package to
create dlls from WINAPI/__stdcall functions. It works all right when
the function inputs/outputs are integers, but it fails when I try to
use floats or doubles.
I have browsed all the relevant archives and I have seen similar problems
reported, but no solutions.
Any ideas? I will appreciate them very much.
BTW, I am using egcs1.1 for mingw32.
Thanks, Carlos
PS: Thanks Jens for your comments, now I attach all the files for your enjoyment :)
This is the (failed) output of the program usedll.c, attached below:
-----------------
dll_double_square (3.0) = -1.#IND00 ---> calcs the square of a double
(fails with WINAPI convention)
dll_int_square (30,40) = 1200 ---> multiplies 2 ints, works OK
------------------
When I get rid of the WINAPI attributes, everything works well. The
problem I have is that I have to use WINAPI to call the DLL from
MS Excel.
All the sources and make commands follow:
-------------------
make commands
-------------------
gcc -c -DBUILDING_DLL=1 -I. -g -Wall -o cdll.o cdll.c
gcc -c -DBUILDING_DLL=1 -I. -g -Wall -o dllinit.o dllinit.c
dlltool --export-all --output-def cdll.def cdll.o dllinit.o
dllwrap --def cdll.def --driver-name gcc -o cdll.dll \
cdll.o dllinit.o
gcc -c -I. -g -Wall -o usedll.o usedll.c
dlltool --dllname cdll.dll --def cdll.def \
--output-lib libcdll.a
gcc -o usedll.exe -g -Wall usedll.o -L./ -lcdll
C:\usr\dll\c>
------------------------
cdll.c
-------------------------
#include "cdll.h"
DLLIMPORT WINAPI int
dll_int_square (int i, int j)
{
return i * j;
}
DLLIMPORT WINAPI double
dll_double_square (double d)
{
return d * d;
}
------------------------
cdll.h
-------------------------
#include "windows.h" //CAD inserted this
#ifndef cdll_h_included
#define cdll_h_included
#if BUILDING_DLL
# if __GNUC__ && ! defined(__declspec)
# define DLLIMPORT
# define DECLSPEC_NOT_SUPPORTED
# else /* ! __GNUC__ || __declspec */
# define DLLIMPORT __declspec (dllexport)
# endif /* ! __GNUC__ || __declspec */
#else /* Not BUILDING_DLL */
# if __GNUC__ && ! defined(__declspec)
# define DLLIMPORT extern
# define DECLSPEC_NOT_SUPPORTED
# else /* ! __GNUC__ || __declspec) */
# define DLLIMPORT __declspec (dllimport)
# endif /* ! __GNUC__ || __declspec) */
#endif /* Not BUILDING_DLL */
DLLIMPORT WINAPI int dll_int_square (int, int) ;
DLLIMPORT WINAPI double dll_double_square (double);
#ifndef DECLSPEC_NOT_SUPPORTED
#else /* DECLSPEC_NOT_SUPPORTED */
#define dll_global_int_var (*_imp__dll_global_int_var)
#endif /* DECLSPEC_NOT_SUPPORTED */
#endif /* cdll_h_included */
------------------------
usedll.c
-------------------------
#include <stdio.h>
#include "cdll.h"
int main () {
printf ("dll_double_square (3.0) = %f\n", dll_double_square (3.0));
printf ("dll_int_square (30,40) = %d\n", dll_int_square (30,40));
return 0;
}
-----------------------------
cdll.def (generated automatically, same for the import library and the dll)
-----------------------------
; dlltool --export-all --output-def cdll.def cdll.o dllinit.o
EXPORTS
dll_int_square@8 @ 1 ;
dll_double_square@8 @ 2 ;
-----------------------------
dllinit.c
-----------------------------
/* dllinit.c -- Portable DLL initialization.
Copyright (C) 1998 Free Software Foundation, Inc.
Contributed by Mumit Khan (khan@xraylith.wisc.edu).
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <stdio.h>
BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason,
LPVOID reserved /* Not used. */ );
#ifdef __CYGWIN32__
#include <cygwin32/cygwin_dll.h>
DECLARE_CYGWIN_DLL( DllMain );
/* save hInstance from DllMain */
HINSTANCE __hDllInstance_base;
#endif /* __CYGWIN32__ */
BOOL APIENTRY
DllMain (
HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
#ifdef __CYGWIN32__
__hDllInstance_base = hInst;
#endif /* __CYGWIN32__ */
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
\x1a
> What exactly is the problem? Do you get any error messages? How does
> the names look in the .dll? Have you exported the functions? I'm not
> sure the __stdcall does that. I guess you link a .def file with the .dll
> to export the functions. Have you looked att the site for mingw32???
>
> Jens Yllman
>
-----
See the original message at http://www.egroups.com/list/gnu-win32/?start=9054
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 9+ messages in thread
* DLL help needed.
@ 1998-11-10 19:28 Murugan Muthusamy
0 siblings, 0 replies; 9+ messages in thread
From: Murugan Muthusamy @ 1998-11-10 19:28 UTC (permalink / raw)
To: gnu-win32
Hi everyone,
I'm trying to build Netscape win32 plugin DLL
with gnu-win32 tools.
I'm getting the following link errors.
win.exp(.edata+0x30):fake:undefined reference to NP_GetEntryPoints.
Any suggestions? or references?
Thanks in advance.
muru@ia-us.com
-----
Free e-mail group hosting at http://www.eGroups.com/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: DLL help needed
1998-11-08 2:27 Carlos Albar-Diaz
@ 1998-11-09 7:48 ` Jens Yllman
1998-11-14 3:05 ` Carlos Albar-Diaz
0 siblings, 1 reply; 9+ messages in thread
From: Jens Yllman @ 1998-11-09 7:48 UTC (permalink / raw)
To: Carlos Albar-Diaz, gnu-win32
Hello,
I'm quite new to use gcc to compile on the win32 platform. So I'm not
sure I can help you. But one of the big problems is namemangling.
Especially when we compile C++ programs. That's why you use the extern
"C" syntax on functions that should use C namemangling. But when it is
win32 functions they should be using pascal namemangling and parameter
passing. This is only if the system is to call the function. And
probably MS Excel whan the pascal namemangling. And what I understand is
that __stdcall is used to get pascal namemangling and parameter passing.
What exactly is the problem? Do you get any error messages? How does
the names look in the .dll? Have you exported the functions? I'm not
sure the __stdcall does that. I guess you link a .def file with the .dll
to export the functions. Have you looked att the site for mingw32???
Jens Yllman
Carlos Albar-Diaz wrote:
>
> I am not able to use my mingw32-built DLLs from MS Excel. The problem seems to be the DLLs need to use the __stdcall convention, and the instructions/makefiles I have are for _cdecl convention.
>
> How do I make a dll from an .o file that contains a function defined woth __stdcall? How do I find out the mangling of the function name? Mumit's makefiles do all this OK until I put __stdcall in the function.
>
> I have browsed the files but none of the "recipes" I saw work with __stdcall.
>
> I will greatly appreciate your help.
>
> Carlos
>
> -----
> Free e-mail group hosting at http://www.eGroups.com/
> -
> For help on using this list (especially unsubscribing), send a message to
> "gnu-win32-request@cygnus.com" with one line of text: "help".
------------------------------------------------------------
Uniweb AB Phone: +46 8 626 42 00
P O Box 745 FAX: +46 8 626 42 01
S-191 27 SOLLENTUNA
SWEDEN http://www.uniweb.se/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 9+ messages in thread
* DLL help needed
@ 1998-11-08 2:27 Carlos Albar-Diaz
1998-11-09 7:48 ` Jens Yllman
0 siblings, 1 reply; 9+ messages in thread
From: Carlos Albar-Diaz @ 1998-11-08 2:27 UTC (permalink / raw)
To: gnu-win32
I am not able to use my mingw32-built DLLs from MS Excel. The problem seems to be the DLLs need to use the __stdcall convention, and the instructions/makefiles I have are for _cdecl convention.
How do I make a dll from an .o file that contains a function defined woth __stdcall? How do I find out the mangling of the function name? Mumit's makefiles do all this OK until I put __stdcall in the function.
I have browsed the files but none of the "recipes" I saw work with __stdcall.
I will greatly appreciate your help.
Carlos
-----
Free e-mail group hosting at http://www.eGroups.com/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 9+ messages in thread
* DLL help needed
@ 1998-11-08 2:27 Carlos Albar-Diaz
0 siblings, 0 replies; 9+ messages in thread
From: Carlos Albar-Diaz @ 1998-11-08 2:27 UTC (permalink / raw)
To: gnu-win32
I am not able to use my mingw32-built DLLs from MS Excel. The problem seems to be the DLLs need to use the __stdcall convention, and the instructions/makefiles I have are for _cdecl convention.
How do I make a dll from an .o file that contains a function defined woth __stdcall? How do I find out the mangling of the function name? Mumit's makefiles do all this OK until I put __stdcall in the function.
I have browsed the files but none of the "recipes" I saw work with __stdcall.
I will greatly appreciate your help.
Carlos
-----
Free e-mail group hosting at http://www.eGroups.com/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: DLL help needed...
[not found] <349f7828.48009513@smtp.netzone.com>
@ 1997-12-23 9:32 ` Richard Stanton
0 siblings, 0 replies; 9+ messages in thread
From: Richard Stanton @ 1997-12-23 9:32 UTC (permalink / raw)
To: jeffdb; +Cc: gnu-win32
>>>>> ">>" == Mikey <jeffdbREMOVETHIS@netzone.com> writes:
> [c:\projects\excel]exe
> i 10.000000, j 11.000000, k -1.#IND00
>> Could this help?
>> __attribute__((__stdcall__)) double RHS (double x, double y)
> {
> return (x + y);
> }
Thanks for the suggestion. It makes some difference, but unfortunately
not to the output!
With this change, I no longer need to compile with the -mrtd option,
and I need to change my dll.def file - using -mrtd I need
RHS
RHS@16=RHS
Using the explicit stdcall attribute in the .C file, and compiling
without -mrtd, the DEF file needs to be the other way round:
RHS@16
RHS=RHS@16
However, the program output is the same:
C:\PROJECTS\excel>exe
i 10.000000, j 11.000000, k -1.#IND00
Again, if I use exactly the same files, but replacing every "double"
with a "short", (and RHS@4 instead of RHS@16 where appropriate) the
program runs perfectly.
I just tried again, this time removing all stdcall references. The
program still fails, but this time I get
C:\PROJECTS\excel>exe
i 10.000000, j 11.000000, k 0.000000
(the last number is supposed to be the sum of the other two)
I'm still confused...
Richard Stanton
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 9+ messages in thread
* DLL help needed...
@ 1997-12-22 13:23 Richard Stanton
0 siblings, 0 replies; 9+ messages in thread
From: Richard Stanton @ 1997-12-22 13:23 UTC (permalink / raw)
To: gnu-win32
I'm getting close to creating working DLLs. With a lot of help from
Giandomenico De Sanctis, I've actually created a DLL file that
passes/returns short ints, and can be used in Excel 97, but I'm having
trouble when the functions pass/return double arguments. In fact, I'm
having trouble even in plain C.
Here's a simple example, which produces the following (odd looking)
output
[c:\projects\excel]exe
i 10.000000, j 11.000000, k -1.#IND00
When I pass everything as short instead of double, it all seems to
work OK. Any idea what I'm doing wrong? I attach all the necessary
files to get this to compile.
By the way, I'm compiling this using mingw32.
Thanks a lot.
Richard Stanton
------------------------------------------------------------------------
exe.c:
------------------------------------------------------------------------
#include <stdio.h>
double RHS (double x, double y) __attribute__((stdcall));
int main()
{
double i, j, k;
i = 10;
j = 11;
k = RHS(i,j);
printf ("i %lf, j %lf, k %lf\n", i, j, k);
return 0;
}
------------------------------------------------------------------------
dll.c:
------------------------------------------------------------------------
double RHS (double x, double y)
{
return (x + y);
}
------------------------------------------------------------------------
dll.def:
------------------------------------------------------------------------
EXPORTS
RHS
RHS@16=RHS
------------------------------------------------------------------------
makefile:
------------------------------------------------------------------------
dll.dll: dll.c dll.def
dlltool --def dll.def --output-exp dll.exp --output-lib dll.a --dllname dll.dll -k
gcc -g -o dll.dll dll.c dll.exp -Xlinker --image-base=0x40000000 -dll -mrtd -ggdb3
exe.exe: exe.c dll.dll
gcc exe.c dll.a -g -o exe.exe
------------------------------------------------------------------------
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~1998-11-14 8:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-08 2:27 DLL help needed Carlos Albar-Diaz
-- strict thread matches above, loose matches on Subject: below --
1998-11-10 19:28 Murugan Muthusamy
1998-11-08 2:27 Carlos Albar-Diaz
1998-11-08 2:27 Carlos Albar-Diaz
1998-11-09 7:48 ` Jens Yllman
1998-11-14 3:05 ` Carlos Albar-Diaz
1998-11-14 8:41 ` Mumit Khan
[not found] <349f7828.48009513@smtp.netzone.com>
1997-12-23 9:32 ` Richard Stanton
1997-12-22 13:23 Richard Stanton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).