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: Problem with DLLs and processes


> -----Original Message-----
> From: cygwin-owner On Behalf Of Przemyslaw Sliwa

> I have a question regarding the dynamically linked libraries 
> in Cygwin.
> When I compile my program under cygwin it uses the dlls. And 
> then during the runtime it loads all the functions from the dll.
> A similar story we have under Linux when one uses the .lo or 
> .so files. However I want to use the compiles program on 
> another machine which does not have the cygwin suite. Under 
> Linux I just specify the option -STATIC and then the program 
> contains all the data needed by the program. I can take it on 
> another machine, which does not have the library and run it. 
> I suppose under cygwin I can do the same, but nowhere in the 
> docs it is written how.
> Could someone tell me how to compile a program so that it 
> contains all the functions needed by it in the exe file???

  Ideally, you'd simply build the cygwin dll from source as a static link
library and add it to your exe.  Unfortunately that turns out not to be
possible because of various internal design features of cygwin.  There are
also licensing implications:

  I don't know if there's any way to statically link a .dll into a .exe in
general.  However, you can simply distribute a copy of cygwin1.dll with your

  This has a slight danger, that the version with your exe might clash with
an existing version of cygwin dll already on the computer.  To avoid this,
you can install your exe and the cygwin dll into a directory of their own.
Then you create a file in that directory that has the exact same name as
your exe with ".local" appended.  This means that when your .exe runs, it
will look in the same directory for its dlls before it looks in the windows
system dir.  That way, your exe gets the version of the dll it expects, but
none of the existing software on the machine you install will interact with
it.  Google for "side-by-side DLLs" if you want to know more.

  Alternatively, you can include the dll as a binary resource and find a way
to extract it at runtime.  Here's an example:

> Can I use my own dlls written in Visual Studio or Borland C++ 
> with the programs compiled under cygwin? Can anyone tell me how ????
  LoadLibrary/GetProcAddress, or link with the .dll's export library, just
the same as usual.  However you'd better make sure it doesn't use any C
runtime functions, as msvcrt and cygwin clash.  It might work if you build
your dll statically linked against the msvc runtime libs and it doesn't do
anything too tricky.

> The next question is regarding the priorities of the 
> processes. Under Linux I can set priorities of the process so 
> that they use less CPU power. Is it possible to do this in 
> cygwin and if yes how????

  Using the nice command, exactly the same way.  Read the man / info page.
Or you can use the windoze task manager.
> The last problem is with the NOHUP command. when I type
> MYPROG.exe > info.txt &nohup
> everything works fine, but when I leave the console (bash) 
> the process is being killed automatically. Does anyone know 
> how to quit console (bash) and keep the process running???

  That's not how you use nohup.  Read the man / info page.  To sum up very
quickly: you want "nohup MYPROG.exe > info.txt &"

Can't think of a witty .sigline today....

Unsubscribe info:
Problem reports:

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