delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/07/07/11:10:12

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3965F251.726D8AD1@lbl.gov>
Date: Fri, 07 Jul 2000 08:08:01 -0700
From: Jean-Luc Vay <JLVay AT lbl DOT gov>
Organization: Lawrence Berkeley National Laboratory
X-Mailer: Mozilla 4.73 [en]C-CCK-MCD LBNL V4.73 Build 1 (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
To: "cygwin AT sourceware DOT cygnus DOT com" <cygwin AT sourceware DOT cygnus DOT com>
Subject: Re: linking windows dll with cygwin gcc
References: <39611F72 DOT 7D5A4AD0 AT lbl DOT gov> <39636A9C DOT FB8DD08 AT lbl DOT gov>

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 AT 8


Jean-Luc





Jean-Luc Vay wrote:

> I have already sent the following message and got no answer. Am I on
> the wrong discussion list?
>
> I am trying to compile a code running under UNIX on a NT platform.
> The core subroutine are written in FORTRAN90 with C interfaces to
> communicate with the language PYTHON. The graphics under PYTHON
> use the library GIST form the Yorick package. I was able to recompile
> Yorick and Python using cygwin-gcc and the X11 library. The problems
> come when I want to link my FORTRAN objects (compiled with
> Lahey LF95) with the C files compiled with gcc. The FORTRAN objects
> required some .lib libraries not compatible with gcc and the C objects
> need some .a libraries incompatible with lf95. I tried to go around that
> by building .dll libraries.
> I tried to link c files with gcc importing dll libraries created
> with lf95 or with BorlandC++ but when I tried the resulting executable,
> I got the error message "The procedure entry point myprocedure could
> not be located in the dynamic library mydll.dll".
> Does someone have an idea of what the problem is or eventually any
> suggestion of solving the problem in a different way?
> Jean-Luc
>
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

--
-------------------------------------------------
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 AT lbl DOT gov
-------------------------------------------------



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019