This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: linking windows dll with cygwin gcc


Thanks for posting this; it could prove useful, and the best which may
be done, in spite of being less flexible than I would like.

Tim Prince
----- Original Message -----
From: "Jean-Luc Vay" <JLVay@lbl.gov>
To: <cygwin@sourceware.cygnus.com>
Sent: Friday, July 07, 2000 8:08 AM
Subject: Re: linking windows dll with cygwin gcc


> This is just the solution to my request for anybody who is interested
> to link cygwin-gcc with lahey lf95 under windows. The following
> set of commands is required
>
> lf95 -win -dll -ml msvc demofact.f90 -c
> lf95 demofact.obj -dll
> dlltool -U --def demofact.def --dllname demofact.dll --output-lib
demofact.a
>
> gcc f95_dll2.c demofact.a
>
> demofact.f90, f95_dll2.c and demofact.def are
>
> %%%%%%%%
> demofact.f90:
>         !!  subroutine : FACTORIAL_DEMO taken from Lahey examples
>         !!
>         !!      sets up the factorial demonstration and governs the
>         !!      invocation of 'factorial'
>         !!
>         subroutine factorial_demo(factorials, count)
>             dll_export factorial_demo
>             integer count
>             integer, dimension(count) :: factorials
>             integer * 4 i,factorial
>             i = 1
>             do while (i <= count)
>                 factorials(i) = factorial(i)
>                 i = i + 1
>             enddo
>         end
>
>
>         recursive function factorial(n) result(factresult)
>             integer * 4  n,factresult
>             if (n .eq. 1) then
>                 factresult = 1
>             else
>                 factresult = n * factorial(n - 1)
>             endif
>         end
>
> %%%%%%%
> f95_dll2.c: modified from Lahey examples
> #include <stdio.h>
> #include <stdlib.h>
> #include <ctype.h>
> #include <stdarg.h>
> #include <string.h>
> #include <signal.h>
> #include <limits.h>
> #include <errno.h>
> #include <math.h>
> #include <time.h>
> #include <float.h>
> #include <windows.h>
>
> HANDLE _stdin_handle;
> HANDLE _stdout_handle;
> HANDLE _stderr_handle;
>
> /*
> ** Prototypes used locally.
> */
> void ChooseFactorial(void);
> /*
> int WINAPI WinMain(HANDLE hInstance, HANDLE hPrevInstance,
>     LPSTR lpCmdLine, int nCmdShow)
> */
> int main()
> {
>     printf("debut");
>     ChooseFactorial();
>     return 0;
> }
>
>
/***********************************************************************
**
> **  This is how to define prototype for a Fortran Subroutine.
> **
>
************************************************************************
*/
> /* void __stdcall factorial_demo(long *, long *); */
> void __stdcall factorial_demo(long *, long *);
>
> void ChooseFactorial()
> {
> #define number_of_factorials 12
>     long num_of_factorials = number_of_factorials;
>  long factorials[number_of_factorials];
>  char buffer[81];
>
>     /* Note that both arguments are passed by reference, the '&' is
only
>     ** required on the scalar.
>     */
>  factorial_demo(factorials, &num_of_factorials);
>  printf("%d %d %d %d %d %d\n", factorials[0], factorials[1],
factorials[2],
> \
>     factorials[3], factorials[4], factorials[5]);
>
> }
>
> %%%%%%%%
> demofact.def:
> EXPORTS
> factorial_demo@8
>
>
> Jean-Luc
>
> -------------------------------------------------
> Jean-Luc Vay
> Accelerator and Fusion Research Division
> Lawrence Berkeley National Laboratory - MS 71J
> Berkeley, CA 94720, USA
> Tel: (1) 510-486-4934
> Fax: (1) 510-495-2323
> Email: jlvay@lbl.gov
> -------------------------------------------------



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]