* RE: CFORTRAN for cygwin/egcs?
@ 1999-03-16 3:02 Billinghurst, David (RTD)
[not found] ` < A9E96A79C068D211A6A90000C07BDF0D1DE699@CRTSMAIL >
1999-03-31 19:45 ` CFORTRAN for cygwin/egcs? Billinghurst, David (RTD)
0 siblings, 2 replies; 12+ messages in thread
From: Billinghurst, David (RTD) @ 1999-03-16 3:02 UTC (permalink / raw)
To: cygwin; +Cc: Richard Stanton
Yes please. I'd love an example of a DLL callable from Excel
> -----Original Message-----
> From: Mumit Khan [SMTP:khan@xraylith.wisc.EDU]
> Sent: Tuesday 16 March 1999 19:47
> To: Richard Stanton
> Cc: cygwin@sourceware.cygnus.com
> Subject: Re: CFORTRAN for cygwin/egcs?
>
> "Richard Stanton" <stanton@haas.berkeley.edu> writes:
> > It IS trivial to use, I've found, as long as you use version 3.5 rather
> than
> > 2.8. The latter seems to be more easily found. As you say,
> > using -Df2cFortran, and linking with -lg2c, gets the sample program to
> > compile without warnings.
>
> Thank you. That's very useful information, especially since it goes into
> the mailing list archive.
>
> BTW, can I use your Excel DLL as an example (with proper attribution of
> course)? I'd like to create some examples in C, C++ and F77 to create
> DLLs for VB/Excel etc like I've done for Java etc.
>
> Regards,
> Mumit
>
>
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Excel-callable DLL [RE: CFORTRAN for cygwin/egcs?]
[not found] ` < A9E96A79C068D211A6A90000C07BDF0D1DE699@CRTSMAIL >
@ 1999-03-17 9:06 ` Mumit Khan
1999-03-31 19:45 ` Mumit Khan
0 siblings, 1 reply; 12+ messages in thread
From: Mumit Khan @ 1999-03-17 9:06 UTC (permalink / raw)
To: Billinghurst, David (RTD); +Cc: cygwin
On Tue, 16 Mar 1999, Billinghurst, David (RTD) wrote:
> Yes please. I'd love an example of a DLL callable from Excel
I won't get a chance to make an example for a while, but here's the
essential info:
1. You need to tell the compiler that the functions need to use the
stdcall calling convention and not the default cdecl. There are two
ways to do it:
a. You can attach an __attribute__((stdcall)) (or WINAPI or STDCALL
which are macros that expand to the attribute) to each exported
function. This is not possible in g77, so you need to use b.
b. Compile all the to-be-turned-into-DLL files with -mrtd, which tells
the compiler to use stdcall calling convention for all the functions.
In most cases, (b) is the simpler option since you don't need to modify
the source code at all.
2. if you're using Cygwin GCC (no -mno-cygwin), then you need to do supply
"special" entry point so that Cygwin DLL is initialized correctly when
it's loaded by Excel etc. Also, you need to make sure cygwin1.dll is in
your path when Excel loads your DLL.
$ dllwrap --entry __cygwin_noncygwin_dll_entry@12 [rest of the options]
I believe the examples in the dllhelpers package describe the rest.
BTW, this is exactly the same mechanism for creating a Java JNI using
Cygwin DLL. (1) is taken care of automatically since Java headers define
a macro that essentially makes the calling convention stdcall. See my
java-jni-examples package for more info.
Regards,
mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: CFORTRAN for cygwin/egcs?
1999-03-16 3:02 CFORTRAN for cygwin/egcs? Billinghurst, David (RTD)
[not found] ` < A9E96A79C068D211A6A90000C07BDF0D1DE699@CRTSMAIL >
@ 1999-03-31 19:45 ` Billinghurst, David (RTD)
1 sibling, 0 replies; 12+ messages in thread
From: Billinghurst, David (RTD) @ 1999-03-31 19:45 UTC (permalink / raw)
To: cygwin; +Cc: Richard Stanton
Yes please. I'd love an example of a DLL callable from Excel
> -----Original Message-----
> From: Mumit Khan [SMTP:khan@xraylith.wisc.EDU]
> Sent: Tuesday 16 March 1999 19:47
> To: Richard Stanton
> Cc: cygwin@sourceware.cygnus.com
> Subject: Re: CFORTRAN for cygwin/egcs?
>
> "Richard Stanton" <stanton@haas.berkeley.edu> writes:
> > It IS trivial to use, I've found, as long as you use version 3.5 rather
> than
> > 2.8. The latter seems to be more easily found. As you say,
> > using -Df2cFortran, and linking with -lg2c, gets the sample program to
> > compile without warnings.
>
> Thank you. That's very useful information, especially since it goes into
> the mailing list archive.
>
> BTW, can I use your Excel DLL as an example (with proper attribution of
> course)? I'd like to create some examples in C, C++ and F77 to create
> DLLs for VB/Excel etc like I've done for Java etc.
>
> Regards,
> Mumit
>
>
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Excel-callable DLL [RE: CFORTRAN for cygwin/egcs?]
1999-03-17 9:06 ` Excel-callable DLL [RE: CFORTRAN for cygwin/egcs?] Mumit Khan
@ 1999-03-31 19:45 ` Mumit Khan
0 siblings, 0 replies; 12+ messages in thread
From: Mumit Khan @ 1999-03-31 19:45 UTC (permalink / raw)
To: Billinghurst, David (RTD); +Cc: cygwin
On Tue, 16 Mar 1999, Billinghurst, David (RTD) wrote:
> Yes please. I'd love an example of a DLL callable from Excel
I won't get a chance to make an example for a while, but here's the
essential info:
1. You need to tell the compiler that the functions need to use the
stdcall calling convention and not the default cdecl. There are two
ways to do it:
a. You can attach an __attribute__((stdcall)) (or WINAPI or STDCALL
which are macros that expand to the attribute) to each exported
function. This is not possible in g77, so you need to use b.
b. Compile all the to-be-turned-into-DLL files with -mrtd, which tells
the compiler to use stdcall calling convention for all the functions.
In most cases, (b) is the simpler option since you don't need to modify
the source code at all.
2. if you're using Cygwin GCC (no -mno-cygwin), then you need to do supply
"special" entry point so that Cygwin DLL is initialized correctly when
it's loaded by Excel etc. Also, you need to make sure cygwin1.dll is in
your path when Excel loads your DLL.
$ dllwrap --entry __cygwin_noncygwin_dll_entry@12 [rest of the options]
I believe the examples in the dllhelpers package describe the rest.
BTW, this is exactly the same mechanism for creating a Java JNI using
Cygwin DLL. (1) is taken care of automatically since Java headers define
a macro that essentially makes the calling convention stdcall. See my
java-jni-examples package for more info.
Regards,
mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* CFORTRAN for cygwin/egcs?
1999-03-15 10:35 ` CFORTRAN for cygwin/egcs? Richard Stanton
[not found] ` < 000f01be6f12$cf737f60$893a85d1@CONNOR.berkeley.edu >
@ 1999-03-31 19:45 ` Richard Stanton
1 sibling, 0 replies; 12+ messages in thread
From: Richard Stanton @ 1999-03-31 19:45 UTC (permalink / raw)
To: cygwin
There's a rather useful package called CFORTRAN, that makes calling FORTRAN
subroutines from C, and vice versa, very simple, on the machines it knows
about.
Has anyone got this working with egcs gcc/g77 under NT? If so, I'd
appreciate any pointers or examples you may have.
Thanks a lot.
Richard Stanton
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CFORTRAN for cygwin/egcs?
1999-03-16 0:47 ` Mumit Khan
@ 1999-03-31 19:45 ` Mumit Khan
0 siblings, 0 replies; 12+ messages in thread
From: Mumit Khan @ 1999-03-31 19:45 UTC (permalink / raw)
To: Richard Stanton; +Cc: cygwin
"Richard Stanton" <stanton@haas.berkeley.edu> writes:
> It IS trivial to use, I've found, as long as you use version 3.5 rather than
> 2.8. The latter seems to be more easily found. As you say,
> using -Df2cFortran, and linking with -lg2c, gets the sample program to
> compile without warnings.
Thank you. That's very useful information, especially since it goes into
the mailing list archive.
BTW, can I use your Excel DLL as an example (with proper attribution of
course)? I'd like to create some examples in C, C++ and F77 to create
DLLs for VB/Excel etc like I've done for Java etc.
Regards,
Mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CFORTRAN for cygwin/egcs?
1999-03-15 14:27 ` Mumit Khan
[not found] ` < Pine.SUN.3.93.990315162021.2930I-100000@modi.xraylith.wisc.edu >
@ 1999-03-31 19:45 ` Mumit Khan
1 sibling, 0 replies; 12+ messages in thread
From: Mumit Khan @ 1999-03-31 19:45 UTC (permalink / raw)
To: Richard Stanton; +Cc: cygwin
On Mon, 15 Mar 1999, Richard Stanton wrote:
> There's a rather useful package called CFORTRAN, that makes calling FORTRAN
> subroutines from C, and vice versa, very simple, on the machines it knows
> about.
>
> Has anyone got this working with egcs gcc/g77 under NT? If so, I'd
> appreciate any pointers or examples you may have.
Hmmm ... it's been years since I've used, but from what I remember, it
should be pretty trivial to use with gcc/g77 on Windows32. I believe the
magic was to define -Df2cFortran (or something like that) and the rest
just worked.
One potential gotcha, and only applicable if you're using gcc/c++ as the
link driver instead of using g77, is that f77 runtime library bundled with
g77 has been renamed from libf2c.a to libg2c.a, and so you'll need to link
with -lg2c instead of -lf2c.
$ gcc -Df2cFortran -c cfile.c
$ g77 -c ffile.f
$ gcc -o mixedprog ffile.o cfile.o -lg2c
What problems have you had?
Mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: CFORTRAN for cygwin/egcs?
1999-03-15 17:58 ` Richard Stanton
[not found] ` < 000b01be6f50$74ce5a60$9e3a85d1@CONNOR.berkeley.edu >
@ 1999-03-31 19:45 ` Richard Stanton
1 sibling, 0 replies; 12+ messages in thread
From: Richard Stanton @ 1999-03-31 19:45 UTC (permalink / raw)
To: Mumit Khan; +Cc: cygwin
It IS trivial to use, I've found, as long as you use version 3.5 rather than
2.8. The latter seems to be more easily found. As you say,
using -Df2cFortran, and linking with -lg2c, gets the sample program to
compile without warnings.
Thanks.
Richard Stanton
> -----Original Message-----
> From: cygwin-owner@sourceware.cygnus.com
> [ mailto:cygwin-owner@sourceware.cygnus.com]On Behalf Of Mumit Khan
> Sent: Monday, March 15, 1999 2:28 PM
> To: Richard Stanton
> Cc: cygwin@sourceware.cygnus.com
> Subject: Re: CFORTRAN for cygwin/egcs?
>
>
> On Mon, 15 Mar 1999, Richard Stanton wrote:
>
> > There's a rather useful package called CFORTRAN, that makes
> calling FORTRAN
> > subroutines from C, and vice versa, very simple, on the
> machines it knows
> > about.
> >
> > Has anyone got this working with egcs gcc/g77 under NT? If so, I'd
> > appreciate any pointers or examples you may have.
>
> Hmmm ... it's been years since I've used, but from what I remember, it
> should be pretty trivial to use with gcc/g77 on Windows32. I believe the
> magic was to define -Df2cFortran (or something like that) and the rest
> just worked.
>
> One potential gotcha, and only applicable if you're using gcc/c++ as the
> link driver instead of using g77, is that f77 runtime library
> bundled with
> g77 has been renamed from libf2c.a to libg2c.a, and so you'll need to link
> with -lg2c instead of -lf2c.
>
>
> $ gcc -Df2cFortran -c cfile.c
> $ g77 -c ffile.f
> $ gcc -o mixedprog ffile.o cfile.o -lg2c
>
> What problems have you had?
>
> Mumit
>
>
>
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com
>
>
>
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CFORTRAN for cygwin/egcs?
[not found] ` < 000b01be6f50$74ce5a60$9e3a85d1@CONNOR.berkeley.edu >
@ 1999-03-16 0:47 ` Mumit Khan
1999-03-31 19:45 ` Mumit Khan
0 siblings, 1 reply; 12+ messages in thread
From: Mumit Khan @ 1999-03-16 0:47 UTC (permalink / raw)
To: Richard Stanton; +Cc: cygwin
"Richard Stanton" <stanton@haas.berkeley.edu> writes:
> It IS trivial to use, I've found, as long as you use version 3.5 rather than
> 2.8. The latter seems to be more easily found. As you say,
> using -Df2cFortran, and linking with -lg2c, gets the sample program to
> compile without warnings.
Thank you. That's very useful information, especially since it goes into
the mailing list archive.
BTW, can I use your Excel DLL as an example (with proper attribution of
course)? I'd like to create some examples in C, C++ and F77 to create
DLLs for VB/Excel etc like I've done for Java etc.
Regards,
Mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: CFORTRAN for cygwin/egcs?
[not found] ` < Pine.SUN.3.93.990315162021.2930I-100000@modi.xraylith.wisc.edu >
@ 1999-03-15 17:58 ` Richard Stanton
[not found] ` < 000b01be6f50$74ce5a60$9e3a85d1@CONNOR.berkeley.edu >
1999-03-31 19:45 ` Richard Stanton
0 siblings, 2 replies; 12+ messages in thread
From: Richard Stanton @ 1999-03-15 17:58 UTC (permalink / raw)
To: Mumit Khan; +Cc: cygwin
It IS trivial to use, I've found, as long as you use version 3.5 rather than
2.8. The latter seems to be more easily found. As you say,
using -Df2cFortran, and linking with -lg2c, gets the sample program to
compile without warnings.
Thanks.
Richard Stanton
> -----Original Message-----
> From: cygwin-owner@sourceware.cygnus.com
> [ mailto:cygwin-owner@sourceware.cygnus.com]On Behalf Of Mumit Khan
> Sent: Monday, March 15, 1999 2:28 PM
> To: Richard Stanton
> Cc: cygwin@sourceware.cygnus.com
> Subject: Re: CFORTRAN for cygwin/egcs?
>
>
> On Mon, 15 Mar 1999, Richard Stanton wrote:
>
> > There's a rather useful package called CFORTRAN, that makes
> calling FORTRAN
> > subroutines from C, and vice versa, very simple, on the
> machines it knows
> > about.
> >
> > Has anyone got this working with egcs gcc/g77 under NT? If so, I'd
> > appreciate any pointers or examples you may have.
>
> Hmmm ... it's been years since I've used, but from what I remember, it
> should be pretty trivial to use with gcc/g77 on Windows32. I believe the
> magic was to define -Df2cFortran (or something like that) and the rest
> just worked.
>
> One potential gotcha, and only applicable if you're using gcc/c++ as the
> link driver instead of using g77, is that f77 runtime library
> bundled with
> g77 has been renamed from libf2c.a to libg2c.a, and so you'll need to link
> with -lg2c instead of -lf2c.
>
>
> $ gcc -Df2cFortran -c cfile.c
> $ g77 -c ffile.f
> $ gcc -o mixedprog ffile.o cfile.o -lg2c
>
> What problems have you had?
>
> Mumit
>
>
>
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com
>
>
>
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CFORTRAN for cygwin/egcs?
[not found] ` < 000f01be6f12$cf737f60$893a85d1@CONNOR.berkeley.edu >
@ 1999-03-15 14:27 ` Mumit Khan
[not found] ` < Pine.SUN.3.93.990315162021.2930I-100000@modi.xraylith.wisc.edu >
1999-03-31 19:45 ` Mumit Khan
0 siblings, 2 replies; 12+ messages in thread
From: Mumit Khan @ 1999-03-15 14:27 UTC (permalink / raw)
To: Richard Stanton; +Cc: cygwin
On Mon, 15 Mar 1999, Richard Stanton wrote:
> There's a rather useful package called CFORTRAN, that makes calling FORTRAN
> subroutines from C, and vice versa, very simple, on the machines it knows
> about.
>
> Has anyone got this working with egcs gcc/g77 under NT? If so, I'd
> appreciate any pointers or examples you may have.
Hmmm ... it's been years since I've used, but from what I remember, it
should be pretty trivial to use with gcc/g77 on Windows32. I believe the
magic was to define -Df2cFortran (or something like that) and the rest
just worked.
One potential gotcha, and only applicable if you're using gcc/c++ as the
link driver instead of using g77, is that f77 runtime library bundled with
g77 has been renamed from libf2c.a to libg2c.a, and so you'll need to link
with -lg2c instead of -lf2c.
$ gcc -Df2cFortran -c cfile.c
$ g77 -c ffile.f
$ gcc -o mixedprog ffile.o cfile.o -lg2c
What problems have you had?
Mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* CFORTRAN for cygwin/egcs?
[not found] ` < 199903130037.SAA00256@modi.xraylith.wisc.edu >
@ 1999-03-15 10:35 ` Richard Stanton
[not found] ` < 000f01be6f12$cf737f60$893a85d1@CONNOR.berkeley.edu >
1999-03-31 19:45 ` Richard Stanton
0 siblings, 2 replies; 12+ messages in thread
From: Richard Stanton @ 1999-03-15 10:35 UTC (permalink / raw)
To: cygwin
There's a rather useful package called CFORTRAN, that makes calling FORTRAN
subroutines from C, and vice versa, very simple, on the machines it knows
about.
Has anyone got this working with egcs gcc/g77 under NT? If so, I'd
appreciate any pointers or examples you may have.
Thanks a lot.
Richard Stanton
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~1999-03-31 19:45 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-16 3:02 CFORTRAN for cygwin/egcs? Billinghurst, David (RTD)
[not found] ` < A9E96A79C068D211A6A90000C07BDF0D1DE699@CRTSMAIL >
1999-03-17 9:06 ` Excel-callable DLL [RE: CFORTRAN for cygwin/egcs?] Mumit Khan
1999-03-31 19:45 ` Mumit Khan
1999-03-31 19:45 ` CFORTRAN for cygwin/egcs? Billinghurst, David (RTD)
-- strict thread matches above, loose matches on Subject: below --
1999-03-12 16:38 linking and iostreams Mumit Khan
[not found] ` < 199903130037.SAA00256@modi.xraylith.wisc.edu >
1999-03-15 10:35 ` CFORTRAN for cygwin/egcs? Richard Stanton
[not found] ` < 000f01be6f12$cf737f60$893a85d1@CONNOR.berkeley.edu >
1999-03-15 14:27 ` Mumit Khan
[not found] ` < Pine.SUN.3.93.990315162021.2930I-100000@modi.xraylith.wisc.edu >
1999-03-15 17:58 ` Richard Stanton
[not found] ` < 000b01be6f50$74ce5a60$9e3a85d1@CONNOR.berkeley.edu >
1999-03-16 0:47 ` Mumit Khan
1999-03-31 19:45 ` Mumit Khan
1999-03-31 19:45 ` Richard Stanton
1999-03-31 19:45 ` Mumit Khan
1999-03-31 19:45 ` 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).