Perhaps a silly question or two
Sat Jun 18 11:04:00 GMT 2005
> (1) I've installed cygwin and am building using the C++ compiler - in order
> to get code using the STL to build, do I have to install the Standard
> Template Library in addition to the C++ compiler? I ask because it doesn't
> appear that I can get my STL code calls to build.
No. The library is included in the gcc-g++ package, which you
presumably already have if you are trying to compile with g++. (On a
related note, this is precisely why we ask that you provide the output
of cygcheck in your problem report so that we don't have to guess about
what you may or may not have installed.) You should post an actual
example of what you are trying to compile, the exact command you are
using to compile, and the result. We are not mind readers and cannot
help without details.
> (2) More of a compiler question - does my resulting C++ executable require
> any run time libraries? I ask because I'd like to know what (if any)
> libraries need to be installed on a target system.
If you compile with Cygwin's gcc/g++ then your binary will depend on
cygwin1.dll, and probably many other aspects of the Cygwin environment,
depending on what functions you call. When I say "aspects of the Cygwin
environment", this can mean many things: DLLs, regular files (such as
/usr/share/zoneinfo/* or /etc/passwd), mounts, etc. One example is
calling the system() call: this will require that /bin be mounted and
that there be a sh.exe in that path, since system() calls "/bin/sh -c
command". So if your program used this call, it would not be sufficient
just to package yourbinary.exe and cygwin1.dll and give it to someone.
For this reason it's usually better just to have the person install
Cygwin if you want to distribute a cygwin binary. You've got to
remember that Cygwin emulates a full unix/posix environment, and this
often extends beyond just being a library.
You can see what DLLs a binary depends on with the cygcheck command.
Your binary must also be distributed under the terms of the GPL or
another OSI approved license if it depends on cygwin1.dll. This is the
price that you pay for taking advantage of the posix emulation layer
that Cygwin provides.
If you wish to write native windows binaries that have no dependency on
cygwin1.dll nor any particular licensing restrictions, then you need to
use mingw. If you go to www.mingw.org you can read about the project
and download their binaries. Alternatively, since the "cygwin" and
"mingw" flavors of gcc are so similar there is a shortcut that you can
use to compile using the mingw environment under Cygwin. Install the
appropriate gcc-mingw-* packages and use the -mno-cygwin flag when
But you must always keep in mind that the mingw environment is not
called "minimalist" for nothing. You are more or less limited to
calling functions in the Win32 API or the Microsoft C runtime library
(MSVCRT*.dll) that exists on all windows systems. If the code that
you're building is is written to use unix/posix functions not part of
the C standard library, you will either have to make it a Cygwin program
(with the gotchas mentioned above), or rewrite it to use native win32
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
More information about the Cygwin