This is the mail archive of the
mailing list for the Cygwin project.
Re: Using cygwin headers/libraries in MS compiled programs
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 31 Dec 2009 15:28:48 +0000
- Subject: Re: Using cygwin headers/libraries in MS compiled programs
- References: <firstname.lastname@example.org>
> Apologies for the dumb question and please re-direct if there is a better
Not a dumb question, but in fact a rather subtle and tricky one.
> How do I use cygwin *.h and *.dll in MS console programs?
The simple answer: you don't. You write a cygwin console program using gcc
instead. All the standard windows APIs are available /as well/ as the POSIX
ones, but you avoid mixing the C runtimes and life is very very very much simpler.
(Why exactly do you want it to be an "MS console program" in the first
place; is it actually necessary to use the VC runtime for some reason?)
> If I include <sys/cygwin.h> in a MS program I get many conflicts between
> the cygwin CRT and MS CRT stuff. Is my only options to "port" the headers
> to MS and dynamically load the cygwin functions with LoadLibrary()?
The longer answer: it is possible to dynamically load the cygwin1.dll, but
it is tricky because it requires the stack to be carefully prepared by
reserving some memory space at the top of it. See "how-cygload.txt" in the
cygwin dll sources for more info. Note also that this mechanism is little
used and doesn't get a lot of maintenance, so may sometimes suffer some bit-rot.
> What calling conventions do I need for cygwin functions in MS compiled
Cygwin uses your bog-standard cdecl; nothing to worry about there.
> All I really want is cygwin_conv_path() so that my MS programs can accept
> cygwin paths.
This is the sort of simple usage scenario that cygload ought to be able to
handle. If you have trouble, an alternative option might be ripping the guts
out of the cygpath source and hacking it straight into your code.
The real question is, what is it you /really/ want to do in the first place?
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple