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

Re: Compiling a windows.exe against cygwin1.dll ?


On Mon, 25 Oct 2004, Wim Van Oudenhove wrote:

> Igor Pechtchanski <pechtcha <at> cs.nyu.edu> writes:
>
> > On Mon, 25 Oct 2004, Wim Van Oudenhove wrote:
> >
> > > > > Is there something I can 'borrow' from cygwin1.dll or some other
> > > > > dll to make my program support these two cases ? (The program is
> > > > > a command line tool written using visual C++)
> > > >
> > > >   Well, yeah: what you're really saying there is that you want a
> > > > cygwin app rather than a 'doze one.  Rewrite it using the standard
> > > > ANSI C stdio functions (f)open, (f)close, (f)read, (f)write
> > > > (assuming it isn't already using them), and use cygwin gcc to
> > > > compile it instead of msvc, and you'll get all that functionality
> > > > for free.
> > >
> > > I would have done that a long time ago if I knew how to use COM under
> > > GCC.
> >
> > Just like you'd use it under MSVC: call the functions.  Nothing
> > prevents a Cygwin program from calling pure Windows functions for the
> > functionality not present in Cygwin -- that's what the w32api effort
> > is for.  Just don't reinvent the wheel and reimplement functionality
> > that's already present in Cygwin.  Many Cygwin programs do that, e.g.,
> > XWin and rxvt.
> >
> > See how the perl libwin32 does it.  Or you could just use cron...
>
> It is cron ;-)

Hmm.  I was about to ask whether there's any reason to not use the
prepackaged version of cron, but I see you've anticipated this question.
Read on...

> > > It also uses some of the AFX CList, CMap, and CArray templates. I'm sure
> > > someone has written equivalents for them in ansi C somewhere, but all
> > > this sounds like too much work for the same purpose.
> >
> > Those are probably more of a problem for gcc than the Win32 functions.  To
> > be pedantic, you want their equivalents in ANSI C++, not ANSI C.  AFAIK,
> > the Cygwin version of gcc comes with an STL implementation -- will that
> > do?
> >
> > > The function it performs is available by default on a unix workstation,
> > > so I doubt that I'll ever need it for another operating system than
> > > windoze.
> >
> > Which function is that?  Perhaps it's also available on Cygwin already?
> > 	Igor
>
> So I've written a program that translates crontab compatible files to
> schedules for the windows scheduler. We've used cron, but that relies on
> the availability of the cygwin stack, which in turn relies on the
> availability of the central repository on the network.

Huh?  How's that?

> We've seen it failing rather frequently due to network outage and that's
> why we decided to use the windows scheduler instead.

Did you try running cron locally on each machine (off a local install,
that is)?

> The first option is the file to use, I load it in a CStdioFile class,
> which I'm sure internally uses fopen, fclose, etc...

If you don't mind borrowing GPL'd code for your app (which will, BTW,
require you to distribute the entire thing under GPL), take a look at
setup.exe sources -- there are functions that translate to/from Cygwin
POSIX paths using the mount information without the need for cygwin1.dll.

> I'm not at all a gcc expert, I only know of it's existence and the fact
> that others use it here in the company. Trying to compile StdAfx.cpp
> doesn't seem to work at all with all that internal windows stuff.

Do you have w32api installed?

> g++ isn't much different.

Not surprisingly, as gcc=g++ (with different default standard libraries).

> How about 'borrowing' gcc's implementation of fopen ? Does that sound
> like a good idea ?

It's not gcc's.  It's newlib's.  And that relies on the "open" syscall,
which is provided by Cygwin.

> I only need to open the file, once I have the handle, I can re- attach
> to it with CStdioFile and keep the rest of my code.

You might try the MinGW option (give a -mno-cygwin argument to g++).  If
you have problems or questions, see the MinGW.org website.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw


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