This is the mail archive of the cygwin@sources.redhat.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]

Using cygwin import libraries in non-cygwin environments


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@zdodson.com

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