delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/10/19/18:30:17

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://sources.redhat.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://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
From: Zane Dodson <zdodson AT zdodson DOT com>
Date: Thu, 19 Oct 2000 17:29:17 -0500
To: cygwin AT sources DOT redhat DOT com
Subject: Using cygwin import libraries in non-cygwin environments
Message-ID: <20001019172916.A11722@xi.zdodson.com>
Mime-Version: 1.0
X-Mailer: Mutt 1.0.1i

I have cygwin-1.1.4 installed (with dll_entry.o replaced in
libcygwin.a) on MS-Windows NT 4.0.

I am currently using g77 to compile some Fortran 77 sources and
create a DLL within the cygwin environment.  This DLL exports a
single symbol which is the name of the Fortran subroutine I want to
make available.  A non-cygwin application, compiled with MS VC++,
references the single export, linked in via an import library.

I have succeeded in doing this, but I encountered behavior along
the way which I found perplexing.

If I create the DLL for the Fortran code with
  g77 -c -g *.f
  dllwrap --dllname dassl.dll --def dassl.def --driver-name g77 \
          --output-lib dassl.lib *.o

and then compile a C++ test program (which uses the DLL)
with MS VC++ and link it with the import library, dassl.lib,
generated above
  cl -c sdassl-tst.cpp
  cl -o sdassl-tst.exe sdassl-tst.obj dassl.lib

I obtain an executable which crashes when run.  (The crash occurs
at the point where the Fortran subroutine is invoked.  Also, the
above link does emit a couple of warnings, although the link
succeeds:
  dassl.lib(ds00000.o) : warning LNK4078: multiple ".text" sections found with different attributes (E0000020)
  dassl.lib(ds00000.o) : warning LNK4078: multiple ".bss" sections found with different attributes (C0000000)
  LINK : warning LNK4089: all references to "dh.o" discarded by /OPT:REF
  LINK : warning LNK4089: all references to "ds00000.o" discarded by /OPT:REF
)

However, if I generate the import library with the LIB command
instead
  LIB /machine:ix86 /def:dassl.def /out:dassl.lib

and then relink the executable with this new dassl.lib,
  cl -o sdassl-tst.exe sdassl-tst.obj dassl.lib

The executable runs without problems, correctly invoking the Fortran
subroutine within the DLL compiled with g77.

Should the import libraries generated by cygwin/GNU build tools be
used only with other cygwin/GNU build tools?

Best regards,

-- 
Zane Dodson
zdodson AT zdodson DOT com

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