This is the mail archive of the cygwin 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]
Other format: [Raw text]

Re: Using cygwin headers/libraries in MS compiled programs

Neil.Mowbray@calgacus wrote:
> Folks,
> Apologies for the dumb question and  please re-direct if there is a better
> forum.

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

  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:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]