Mail Archives: cygwin/2007/10/17/14:57:54
Hi list,
I have a library originally developed on Linux/FreeBSD that is building
fine on Cygwin. It also works fine if I build executables using this
library inside Cygwin. The goal however is for the resulting DLL to work
outside of Cygwin, for example with Visual Studio. I am running into a
few problems trying to achieve this. I'll first describe what I've
tried, and ask questions below.
Following http://www.cygwin.com/ml/cygwin/2004-03/msg00453.html , I use
this command to link the library:
gcc -shared ${objects} \
-Wl,--output-def=.libs/cygfoo.def \
-Wl,--export-all-symbols \
-Wl,--enable-auto-import \
-Wl,--enable-auto-image-base \
-Wl,--add-stdcall-alias \
-Wl,--enable-stdcall-fixup \
-Wl,--enable-auto-image-base \
-o .libs/cygfoo-0.dll \
-lssl -lcrypto
(The library uses OpenSSL, which I have included in my Cygwin setup.)
I threw out --compat-implib since it no longer seems to exist (per "man
ld"). I originally also used --out-implib to generate an import library,
but like http://www.cygwin.com/ml/cygwin/2000-10/msg01051.html I'd get a
'multiple ".text" sections found with different attributes' warning when
using the resulting implib. (I have also tried the command shown at
http://cygwin.com/cygwin-ug-net/dll.html , with the same result.)
I now instead use MSVC's lib command, which seems to fix that problem:
LIB /machine:ix86 /def:cygfoo.def /out:cygfoo.lib
Given the resulting .dll, .lib, and .def, I can compile a dummy
application in MSVC. However, this executable has two problems. First,
output to stdout/stderr does not appear. A number of people seem to have
noticed this. One related posting recommended the use file I/O instead,
but if I attempt this (or indeed any cross-DLL-boundary calls), the
application crashes. Simpler function calls whose execution paths don't
leave my DLL work fine.
My questions:
- Is there a Cygwin-only way to avoid the MSVC lib command detour, to
avoid the "multiple .text sections" issue?
- I have gleaned from related postings and FAQ 6.12 that the crashes are
due to the use of cygwin1.dll and msvcrt.dll (and/or related Windows
DLLs) in the same executable. Is this correct?
- If so, is there a way to avoid the problem while still building the
library in my cozy Cygwin/POSIX environment? My understanding is that
-mno-cygwin doesn't help in that regard (per FAQ 6.10), and that I have
to keep cygwin1.dll (per FAQ 6.11).
- If getting rid of msvcrt.dll is the answer, what are the implications
for building Windows-native applications? (And, assuming this is
possible, if a kind soul could tell me how I'd go about doing this even
though it's not a question at the heart of this list, that'd be much
appreciated...)
Thanks for any help!
Cheers,
Christian
--
________________________________________________________________________
http://www.icir.org/christian
http://www.whoop.org
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -