<div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Cygwin FAQ</th></tr></table><hr></div><div lang="en" class="article"><div class="titlepage"><div><div><h2 class="title"><a name="faq"></a>Cygwin FAQ</h2></div></div><hr></div><div class="qandaset"><dl><dt>1.  <a href="faq.html#faq.about">About Cygwin</a></dt><dd><dl><dt>1.1. <a href="faq.html#faq.what.what">What is it?</a></dt><dt>1.2. <a href="faq.html#faq.what.supported">What versions of Windows are supported?</a></dt><dt>1.3. <a href="faq.html#faq.what.where">Where can I get it?</a></dt><dt>1.4. <a href="faq.html#faq.what.free">Is it free software?</a></dt><dt>1.5. <a href="faq.html#faq.what.version">What version of Cygwin is this, anyway?</a></dt><dt>1.6. <a href="faq.html#faq.what.who">Who's behind the project?</a></dt></dl></dd><dt>2.  <a href="faq.html#faq.setup">Setting up Cygwin</a></dt><dd><dl><dt>2.1. <a href="faq.html#faq.setup.setup">What is the recommended installation procedure?</a></dt><dt>2.2. <a href="faq.html#faq.setup.automated">What about an automated Cygwin installation?</a></dt><dt>2.3. <a href="faq.html#faq.setup.cli">Does the Cygwin Setup program accept command-line arguments?</a></dt><dt>2.4. <a href="faq.html#faq.setup.noroot">Can I install Cygwin without administrator rights?</a></dt><dt>2.5. <a href="faq.html#faq.setup.c">Why not install in C:\?</a></dt><dt>2.6. <a href="faq.html#faq.setup.old-versions">Can I use the Cygwin Setup program to get old versions of packages (like gcc-2.95)?</a></dt><dt>2.7. <a href="faq.html#faq.setup.install-security">How does Cygwin secure the installation and update process?</a></dt><dt>2.8. <a href="faq.html#faq.setup.increase-install-security">What else can I do to ensure that my installation and updates are secure?</a></dt><dt>2.9. <a href="faq.html#faq.setup.virus">Is the Cygwin Setup program, or one of the packages, infected with a virus?</a></dt><dt>2.10. <a href="faq.html#faq.setup.hang">My computer hangs when I run Cygwin Setup!</a></dt><dt>2.11. <a href="faq.html#faq.setup.what-packages">What packages should I download? Where are 'make', 'gcc', 'vi', etc?  </a></dt><dt>2.12. <a href="faq.html#faq.setup.everything">How do I just get everything?</a></dt><dt>2.13. <a href="faq.html#faq.setup.disk-space">How much disk space does Cygwin require?</a></dt><dt>2.14. <a href="faq.html#faq.setup.what-upgraded">How do I know which version I upgraded from?</a></dt><dt>2.15. <a href="faq.html#faq.setup.setup-fails">What if the Cygwin Setup program fails?</a></dt><dt>2.16. <a href="faq.html#faq.setup.name-with-space">My Windows logon name has a space in it, will this cause problems?</a></dt><dt>2.17. <a href="faq.html#faq.setup.home">My HOME environment variable is not what I want.</a></dt><dt>2.18. <a href="faq.html#faq.setup.uninstall-packages">How do I uninstall individual packages?</a></dt><dt>2.19. <a href="faq.html#faq.setup.uninstall-service">How do I uninstall a Cygwin service?</a></dt><dt>2.20. <a href="faq.html#faq.setup.uninstall-all">How do I uninstall all of Cygwin?</a></dt><dt>2.21. <a href="faq.html#faq.setup.testrels">How do I install Cygwin test releases?</a></dt><dt>2.22. <a href="faq.html#faq.setup.mirror">Can the Cygwin Setup program maintain a ``mirror''?</a></dt><dt>2.23. <a href="faq.html#faq.setup.cd">How can I make my own portable Cygwin on CD?</a></dt><dt>2.24. <a href="faq.html#faq.setup.registry">How do I save, restore, delete, or modify the Cygwin information stored in the registry?</a></dt></dl></dd><dt>3.  <a href="faq.html#faq.resources">Further Resources</a></dt><dd><dl><dt>3.1. <a href="faq.html#faq.resources.documentation">Where's the documentation?</a></dt><dt>3.2. <a href="faq.html#faq.resources.mailing-lists">What Cygwin mailing lists can I join?</a></dt><dt>3.3. <a href="faq.html#faq.resources.problems">What if I have a problem? (Or: Why won't you/the mailing list answer my questions?)</a></dt></dl></dd><dt>4.  <a href="faq.html#faq.using">Using Cygwin</a></dt><dd><dl><dt>4.1. <a href="faq.html#faq.using.missing-dlls">Why can't my application locate cygncurses-8.dll?  or cygintl-3.dll?  or cygreadline6.dll?  or ...?</a></dt><dt>4.2. <a href="faq.html#faq.using.startup-slow">Starting a new terminal window is slow. What's going on?</a></dt><dt>4.3. <a href="faq.html#faq.using.slow">Why is Cygwin suddenly so slow?</a></dt><dt>4.4. <a href="faq.html#faq.using.shares">Why can't my services access network shares?</a></dt><dt>4.5. <a href="faq.html#faq.using.path">How should I set my PATH?</a></dt><dt>4.6. <a href="faq.html#faq.using.not-found">Bash (or another shell) says "command not found", but it's right there!</a></dt><dt>4.7. <a href="faq.html#faq.using.converting-paths">How do I convert between Windows and UNIX paths?</a></dt><dt>4.8. <a href="faq.html#faq.using.bashrc">Why doesn't bash read my .bashrc file on startup?</a></dt><dt>4.9. <a href="faq.html#faq.using.bash-insensitive">How can I get bash filename completion to be case insensitive?</a></dt><dt>4.10. <a href="faq.html#faq.using.filename-spaces">Can I use paths/filenames containing spaces in them?</a></dt><dt>4.11. <a href="faq.html#faq.using.shortcuts">Why can't I cd into a shortcut to a directory?</a></dt><dt>4.12. <a href="faq.html#faq.using.find">I'm having basic problems with find.  Why?</a></dt><dt>4.13. <a href="faq.html#faq.using.su">Why doesn't su work?</a></dt><dt>4.14. <a href="faq.html#faq.using.man">Why doesn't man -k,
apropos or whatis work?</a></dt><dt>4.15. <a href="faq.html#faq.using.chmod">Why doesn't chmod work?</a></dt><dt>4.16. <a href="faq.html#faq.using.shell-scripts">Why doesn't my shell script work?</a></dt><dt>4.17. <a href="faq.html#faq.using.printing">How do I print under Cygwin?</a></dt><dt>4.18. <a href="faq.html#faq.using.unicode">Why don't international (Unicode) characters work?</a></dt><dt>4.19. <a href="faq.html#faq.using.weirdchars">My application prints international characters but I only
see gray boxes</a></dt><dt>4.20. <a href="faq.html#faq.using.multiple-copies">Is it OK to have multiple copies of the DLL?</a></dt><dt>4.21. <a href="faq.html#faq.using.third-party.multiple-copies">
I read the above but I want to bundle Cygwin with a product, and ship it
to customer sites.  How can I do this without conflicting with any Cygwin
installed by the user?
</a></dt><dt>4.22. <a href="faq.html#faq.using.bundling-cygwin">
Can I bundle Cygwin with my product for free?
</a></dt><dt>4.23. <a href="faq.html#faq.using.older-cygwin-conflict">
But doesn't that mean that if some application installs an older Cygwin
DLL on top of a newer DLL, my application will break?
</a></dt><dt>4.24. <a href="faq.html#faq.using.missing-packages">Why isn't package XYZ available in Cygwin?</a></dt><dt>4.25. <a href="faq.html#faq.using.old-packages">Why is the Cygwin package of XYZ so out of date?</a></dt><dt>4.26. <a href="faq.html#faq.using.accessing-drives">How can I access other drives?</a></dt><dt>4.27. <a href="faq.html#faq.using.copy-and-paste">How can I copy and paste into Cygwin console windows?</a></dt><dt>4.28. <a href="faq.html#faq.using.firewall">What firewall should I use with Cygwin? </a></dt><dt>4.29. <a href="faq.html#faq.using.sharing-files">How can I share files between Unix and Windows?</a></dt><dt>4.30. <a href="faq.html#faq.using.case-sensitive">Is Cygwin case-sensitive??</a></dt><dt>4.31. <a href="faq.html#faq.using.dos-filenames">What about DOS special filenames?</a></dt><dt>4.32. <a href="faq.html#faq.using.sparse-files">Does Cygwin support sparse files?</a></dt><dt>4.33. <a href="faq.html#faq.using.hangs">When it hangs, how do I get it back?</a></dt><dt>4.34. <a href="faq.html#faq.using.directory-structure">Why the weird directory structure?</a></dt><dt>4.35. <a href="faq.html#faq.using.anti-virus">How do anti-virus programs like Cygwin?</a></dt><dt>4.36. <a href="faq.html#faq.using.emacs">Is there a Cygwin port of GNU Emacs?</a></dt><dt>4.37. <a href="faq.html#faq.using.xemacs">Is there a Cygwin port of XEmacs?</a></dt><dt>4.38. <a href="faq.html#faq.using.symlinkstoppedworking">Why don't some of my old symlinks work anymore?</a></dt><dt>4.39. <a href="faq.html#faq.using.symlinks-samba">Why don't symlinks work on Samba-mounted filesystems?</a></dt><dt>4.40. <a href="faq.html#faq.using.ssh-pubkey-stops-working">Why does public key authentication with ssh fail after updating to Cygwin 1.7.34 or later?</a></dt><dt>4.41. <a href="faq.html#faq.using.same-with-rhosts">Why is my .rhosts file not recognized by rlogin anymore after updating to Cygwin 1.7.34?</a></dt><dt>4.42. <a href="faq.html#faq.using.same-with-permissions">Why do my files have extra permissions after updating to Cygwin 1.7.34?</a></dt><dt>4.43. <a href="faq.html#faq.using.tcl-tk">Why do my Tk programs not work anymore?</a></dt><dt>4.44. <a href="faq.html#faq.using.bloda">What applications have been found to interfere with Cygwin?</a></dt><dt>4.45. <a href="faq.html#faq.using.fixing-fork-failures">How do I fix fork() failures?</a></dt><dt>4.46. <a href="faq.html#faq.using.fixing-find_fast_cwd-warnings">How do I fix find_fast_cwd warnings?</a></dt></dl></dd><dt>5.  <a href="faq.html#faq.api">Cygwin API Questions</a></dt><dd><dl><dt>5.1. <a href="faq.html#faq.api.everything">How does everything work?</a></dt><dt>5.2. <a href="faq.html#faq.api.snapshots">Are development snapshots for the Cygwin library available?</a></dt><dt>5.3. <a href="faq.html#faq.api.testrels">Are test releases for the Cygwin library available?</a></dt><dt>5.4. <a href="faq.html#faq.api.cr-lf">How is the DOS/Unix CR/LF thing handled?</a></dt><dt>5.5. <a href="faq.html#faq.api.threads">Is the Cygwin library multi-thread-safe?</a></dt><dt>5.6. <a href="faq.html#faq.api.fork">How is fork() implemented?</a></dt><dt>5.7. <a href="faq.html#faq.api.globbing">How does wildcarding (globbing) work?</a></dt><dt>5.8. <a href="faq.html#faq.api.symlinks">How do symbolic links work?</a></dt><dt>5.9. <a href="faq.html#faq.api.executables">Why do some files, which are not executables have the 'x' type.</a></dt><dt>5.10. <a href="faq.html#faq.api.secure">How secure is Cygwin in a multi-user environment?</a></dt><dt>5.11. <a href="faq.html#faq.api.net-functions">How do the net-related functions work?</a></dt><dt>5.12. <a href="faq.html#faq.api.winsock">I don't want Unix sockets, how do I use normal Windows winsock?</a></dt><dt>5.13. <a href="faq.html#faq.api.versions">What version numbers are associated with Cygwin?</a></dt><dt>5.14. <a href="faq.html#faq.api.timezone">Why isn't my time (or zone) set correctly?</a></dt><dt>5.15. <a href="faq.html#faq.api.mouse">Is there a mouse interface?</a></dt></dl></dd><dt>6.  <a href="faq.html#faq.programming">Programming Questions</a></dt><dd><dl><dt>6.1. <a href="faq.html#faq.programming.packages">How do I contribute a package?</a></dt><dt>6.2. <a href="faq.html#faq.programming.contribute">How do I contribute to Cygwin?</a></dt><dt>6.3. <a href="faq.html#faq.programming.huge-executables">Why are compiled executables so huge?!?</a></dt><dt>6.4. <a href="faq.html#faq.programming.64bitporting">What do I have to look out for when porting applications to 64 bit Cygwin?</a></dt><dt>6.5. <a href="faq.html#faq.programming.64bitporting-fail">My project doesn't build at all on 64 bit Cygwin.  What's up?</a></dt><dt>6.6. <a href="faq.html#faq.programming.64bitporting-cygwin64">Why is __CYGWIN64__ not defined for 64 bit?</a></dt><dt>6.7. <a href="faq.html#faq.programming.glibc">Where is glibc?</a></dt><dt>6.8. <a href="faq.html#faq.programming.objective-c">Where is Objective C?</a></dt><dt>6.9. <a href="faq.html#faq.programming.make-execvp">Why does my make fail on Cygwin with an execvp error? </a></dt><dt>6.10. <a href="faq.html#faq.programming.ipc">How can I use IPC, or why do I get a Bad system call
error?</a></dt><dt>6.11. <a href="faq.html#faq.programming.winmain">Why the undefined reference to WinMain@16?</a></dt><dt>6.12. <a href="faq.html#faq.programming.win32-api">How do I use Windows API calls?</a></dt><dt>6.13. <a href="faq.html#faq.programming.win32-no-cygwin">How do I compile a Windows executable that doesn't use Cygwin?</a></dt><dt>6.14. <a href="faq.html#faq.programming.static-linking">Can I build a Cygwin program that does not require cygwin1.dll at runtime?</a></dt><dt>6.15. <a href="faq.html#faq.programming.msvcrt-and-cygwin">Can I link with both MSVCRT*.DLL and cygwin1.dll?</a></dt><dt>6.16. <a href="faq.html#faq.programming.no-console-window">How do I make the console window go away?</a></dt><dt>6.17. <a href="faq.html#faq.programming.make-spaces">Why does make complain about a "missing separator"?</a></dt><dt>6.18. <a href="faq.html#faq.programming.win32-headers">Why can't we redistribute Microsoft's Windows API headers?</a></dt><dt>6.19. <a href="faq.html#faq.programming.msvs-mingw">How do I use cygwin1.dll with Visual Studio or Mingw-w64?</a></dt><dt>6.20. <a href="faq.html#faq.programming.linking-lib">How do I link against a .lib file?</a></dt><dt>6.21. <a href="faq.html#faq.programming.building-cygwin">How do I build Cygwin on my own?</a></dt><dt>6.22. <a href="faq.html#faq.programming.debugging-cygwin">I may have found a bug in Cygwin, how can I debug it (the symbols in gdb look funny)?</a></dt><dt>6.23. <a href="faq.html#faq.programming.compiling-unsupported">How can I compile Cygwin for an unsupported platform (PowerPC, Alpha, ARM, Itanium)?</a></dt><dt>6.24. <a href="faq.html#faq.programming.adjusting-heap">How can I adjust the heap/stack size of an application?</a></dt><dt>6.25. <a href="faq.html#faq.programming.dll-cygcheck">How can I find out which DLLs are needed by an executable?</a></dt><dt>6.26. <a href="faq.html#faq.programming.dll-building">How do I build a DLL?</a></dt><dt>6.27. <a href="faq.html#faq.programming.breakpoint">How can I set a breakpoint at mainCRTStartup?</a></dt><dt>6.28. <a href="faq.html#faq.programming.debug">How can I debug what's going on?</a></dt><dt>6.29. <a href="faq.html#faq.programming.system-trace">Can I use a system trace mechanism instead?</a></dt><dt>6.30. <a href="faq.html#faq.programming.gdb-signals">How does gdb handle signals?</a></dt><dt>6.31. <a href="faq.html#faq.programming.linker">The linker complains that it can't find something.</a></dt><dt>6.32. <a href="faq.html#faq.programming.stat64">Why do I get an error using struct stat64?</a></dt><dt>6.33. <a href="faq.html#faq.programming.libc">Can you make DLLs that are linked against libc ?</a></dt><dt>6.34. <a href="faq.html#faq.programming.malloc-h">Where is malloc.h?</a></dt><dt>6.35. <a href="faq.html#faq.programming.own-malloc">Can I use my own malloc?</a></dt><dt>6.36. <a href="faq.html#faq.programming.msvc-gcc-objects">Can I mix objects compiled with msvc++ and gcc?</a></dt><dt>6.37. <a href="faq.html#faq.programming.gdb-msvc">Can I use the gdb debugger to debug programs built by VC++?</a></dt><dt>6.38. <a href="faq.html#faq.programming.make-scripts">Shell scripts aren't running properly from my makefiles?</a></dt><dt>6.39. <a href="faq.html#faq.programming.preprocessor">What preprocessor macros do I need to know about?</a></dt><dt>6.40. <a href="faq.html#faq.programming.unix-gui">How should I port my Unix GUI to Windows?</a></dt></dl></dd><dt>7.  <a href="faq.html#faq.copyright">Copyright</a></dt><dd><dl><dt>7.1. <a href="faq.html#faq.what.copyright">What are the copyrights?</a></dt></dl></dd></dl><table border="0" style="width: 100%;"><colgroup><col align="left" width="1%"><col></colgroup><tbody><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="faq.about"></a>1. About Cygwin</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>1.1. <a href="faq.html#faq.what.what">What is it?</a></dt><dt>1.2. <a href="faq.html#faq.what.supported">What versions of Windows are supported?</a></dt><dt>1.3. <a href="faq.html#faq.what.where">Where can I get it?</a></dt><dt>1.4. <a href="faq.html#faq.what.free">Is it free software?</a></dt><dt>1.5. <a href="faq.html#faq.what.version">What version of Cygwin is this, anyway?</a></dt><dt>1.6. <a href="faq.html#faq.what.who">Who's behind the project?</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.what.what"></a><p><b>1.1.</b></p></td><td align="left" valign="top"><p>What is it?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin is a distribution of popular GNU and other Open Source tools
running on Microsoft Windows.  The core part is the Cygwin library which
provides the POSIX system calls and environment these programs expect.
</p><p>The Cygwin distribution contains thousands of packages from the Open
Source world including most GNU tools, many BSD tools, an X server and a full
set of X applications.  If you're a developer you will find tools, headers
and libraries allowing to write Windows console or GUI applications that make
use of significant parts of the POSIX API.  Cygwin allows easy porting of many
Unix programs without the need for extensive changes to the source code.  This
includes configuring and building most of the available GNU or BSD software,
including the packages included with the Cygwin distribution themselves.
They can be used from one of the provided Unix shells like bash, tcsh or zsh.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.what.supported"></a><p><b>1.2.</b></p></td><td align="left" valign="top"><p>What versions of Windows are supported?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin can be expected to run on all modern, released 64 bit versions of
Windows.  This includes Windows 8.1, Windows Server 2012 R2 and all later
versions of Windows on AMD/Intel compatible PCs, as well as under x64 emulation
on ARM PCs running Windows 11. Windows S mode is not supported due to its
limitations, </p><p>Keep in mind that Cygwin can only do as much as the underlying OS
supports.  Because of this, Cygwin will behave differently, and
exhibit different limitations, on the various versions of Windows.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.what.where"></a><p><b>1.3.</b></p></td><td align="left" valign="top"><p>Where can I get it?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The home page for the Cygwin project is
<a class="ulink" href="https://cygwin.com/" target="_top">https://cygwin.com/</a>.
There you should find everything you need for Cygwin, including links
for download and setup, a current list of mirror sites, a User's
Guide, an API Reference, mailing lists and archives.
</p><p>You can find documentation for the individual GNU tools typically
as man pages or info pages as part of the Cygwin net distribution.
Additionally you can get the latest docs at
<a class="ulink" href="http://www.gnu.org/manual" target="_top">http://www.gnu.org/manual</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.what.free"></a><p><b>1.4.</b></p></td><td align="left" valign="top"><p>Is it free software?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes.  Parts are GNU software (gcc, gas, ld, etc...), parts are covered
by the standard X11 license, some of it is public domain, some of
it was written by Red Hat (or the former Cygnus Solutions) and placed under
the GPL.  None of it is shareware.  You don't have to pay anyone to use it
but you should be sure to read the copyright section of the FAQ for more
information on how the GNU General Public License may affect your use of
these tools.
</p><p>Note that when we say "free" we mean freedom, not price.  The goal of
such freedom is that the people who use a given piece of software
should be able to change it to fit their needs, learn from it, share
it with their friends, etc.  The GPL or LGPL licenses allows you those
freedoms, so it is free software.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.what.version"></a><p><b>1.5.</b></p></td><td align="left" valign="top"><p>What version of Cygwin <span class="emphasis"><em>is</em></span> this, anyway?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>To find the version of the Cygwin DLL installed, you can use
<code class="filename">uname</code> <code class="literal">-r</code> as you would for a Unix kernel.
As the Cygwin DLL takes the place of a Unix kernel,
you can also use the Unix compatible command:
<code class="filename">head</code> <code class="filename">/proc/version</code>,
or the Cygwin specific command:
<code class="filename">cygcheck</code> <code class="literal">-V</code>.
Refer to each command's
<code class="literal">--help</code> output and the
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/" target="_top">Cygwin User's Guide</a>
for more information.
</p><p>If you are looking for the version number for the whole Cygwin
release, there is none.
Each package in the Cygwin release has its own version, and the
<code class="literal">cygwin</code> package containing the Cygwin DLL and Cygwin
system specific utilities is just another (but very important!) package.
The packages in Cygwin are continually improving, thanks to
the efforts of volunteers who maintain the Cygwin ports.
Each package has its own version numbers and its own release process.
</p><p>So, how do you get the most up-to-date version of Cygwin?  Easy.  Just
download the Cygwin Setup program by following the
<a class="ulink" href="https://cygwin.com/install.html" target="_top">installation instructions</a>.
The Setup program will handle the task of updating the packages on your system
to the latest version.
For more information about using Cygwin's Setup program, see
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/setup-net.html" target="_top">Setting Up Cygwin</a>
in the Cygwin User's Guide.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.what.who"></a><p><b>1.6.</b></p></td><td align="left" valign="top"><p>Who's behind the project?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p><span class="bold"><strong>(Please note that if you have cygwin-specific
questions, all of these people will appreciate it if you use the cygwin
mailing lists rather than sending personal email.)</strong></span>
</p><p>
Corinna Vinschen is the current project lead,
responsible for the Cygwin library and a lot more.
</p><p>
Yaakov Selkowitz is the guy behind the current build and packaging system
and maintained by far the most packages in the Cygwin distribution.
</p><p>
Jon Turney is maintainer of the Cygwin X server and related packages.
</p><p>
The packages are maintained by a large group of
<a class="ulink" href="https://cygwin.com/cygwin-pkg-maint" target="_top">volunteers</a>.
</p><p>
Please note that all of us volunteering on Cygwin try to be as responsive as
possible and deal with patches and questions as we get them, but
realistically we don't have time to answer all of the email that is sent to
the main mailing list.
Making releases of the tools and packages is an activity in our spare time,
helping people out is not our primary focus, so some email will have to go
unanswered.
</p><p>Many thanks to everyone using the tools for their many contributions in
the form of advice, bug reports, and code fixes.  Keep them coming!
</p></td></tr><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="faq.setup"></a>2. Setting up Cygwin</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>2.1. <a href="faq.html#faq.setup.setup">What is the recommended installation procedure?</a></dt><dt>2.2. <a href="faq.html#faq.setup.automated">What about an automated Cygwin installation?</a></dt><dt>2.3. <a href="faq.html#faq.setup.cli">Does the Cygwin Setup program accept command-line arguments?</a></dt><dt>2.4. <a href="faq.html#faq.setup.noroot">Can I install Cygwin without administrator rights?</a></dt><dt>2.5. <a href="faq.html#faq.setup.c">Why not install in C:\?</a></dt><dt>2.6. <a href="faq.html#faq.setup.old-versions">Can I use the Cygwin Setup program to get old versions of packages (like gcc-2.95)?</a></dt><dt>2.7. <a href="faq.html#faq.setup.install-security">How does Cygwin secure the installation and update process?</a></dt><dt>2.8. <a href="faq.html#faq.setup.increase-install-security">What else can I do to ensure that my installation and updates are secure?</a></dt><dt>2.9. <a href="faq.html#faq.setup.virus">Is the Cygwin Setup program, or one of the packages, infected with a virus?</a></dt><dt>2.10. <a href="faq.html#faq.setup.hang">My computer hangs when I run Cygwin Setup!</a></dt><dt>2.11. <a href="faq.html#faq.setup.what-packages">What packages should I download? Where are 'make', 'gcc', 'vi', etc?  </a></dt><dt>2.12. <a href="faq.html#faq.setup.everything">How do I just get everything?</a></dt><dt>2.13. <a href="faq.html#faq.setup.disk-space">How much disk space does Cygwin require?</a></dt><dt>2.14. <a href="faq.html#faq.setup.what-upgraded">How do I know which version I upgraded from?</a></dt><dt>2.15. <a href="faq.html#faq.setup.setup-fails">What if the Cygwin Setup program fails?</a></dt><dt>2.16. <a href="faq.html#faq.setup.name-with-space">My Windows logon name has a space in it, will this cause problems?</a></dt><dt>2.17. <a href="faq.html#faq.setup.home">My HOME environment variable is not what I want.</a></dt><dt>2.18. <a href="faq.html#faq.setup.uninstall-packages">How do I uninstall individual packages?</a></dt><dt>2.19. <a href="faq.html#faq.setup.uninstall-service">How do I uninstall a Cygwin service?</a></dt><dt>2.20. <a href="faq.html#faq.setup.uninstall-all">How do I uninstall all of Cygwin?</a></dt><dt>2.21. <a href="faq.html#faq.setup.testrels">How do I install Cygwin test releases?</a></dt><dt>2.22. <a href="faq.html#faq.setup.mirror">Can the Cygwin Setup program maintain a ``mirror''?</a></dt><dt>2.23. <a href="faq.html#faq.setup.cd">How can I make my own portable Cygwin on CD?</a></dt><dt>2.24. <a href="faq.html#faq.setup.registry">How do I save, restore, delete, or modify the Cygwin information stored in the registry?</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.setup"></a><p><b>2.1.</b></p></td><td align="left" valign="top"><p>What is the recommended installation procedure?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
There is only one recommended way to install Cygwin, which is to use the
Cygwin Setup program, a GUI installer.
It is flexible and easy to use.
You can pick and choose the packages you wish to install, and update
them individually.  Full source code is available for all packages and
tools.
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/setup-net.html" target="_top">More information</a>
is available on using the Cygwin Setup program.
</p><p>If you do it any other way, you're on your own!
If something doesn't work right for you, and it's not covered here or in
the latest Cygwin test package (see
<a class="xref" href="faq.html#faq.setup.testrels" title="2.21.">Install Test Releases</a>),
then by all means report it to the mailing list.
</p><p>For a searchable list of packages that can be installed with Cygwin,
see <a class="ulink" href="https://cygwin.com/packages/" target="_top">https://cygwin.com/packages/</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.automated"></a><p><b>2.2.</b></p></td><td align="left" valign="top"><p>What about an automated Cygwin installation?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The Cygwin Setup program is designed to be interactive, but there are
a few different ways to automate it. If you are deploying to multiple systems,
the best way is to run through a full installation once, saving the entire 
downloaded package tree. Then, on target systems, run the Cygwin Setup program as a
"Local Install" pointed at your downloaded package tree. You could do this
non-interactively with the command line options
<code class="literal">-q -L -l x:\cygwin-local\</code>, where your downloaded 
package tree is in <code class="literal">x:\cygwin-local\</code> (see the next FAQ for
an explanation of those options.)
</p><p>
For other options, search the mailing lists with terms such as 
<a class="ulink" href="http://www.google.com/search?q=cygwin+automated+setup" target="_top">cygwin automated setup</a> or
<a class="ulink" href="http://www.google.com/search?q=automated+cygwin+install" target="_top">automated cygwin install</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.cli"></a><p><b>2.3.</b></p></td><td align="left" valign="top"><p>Does the Cygwin Setup program accept command-line arguments?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes, run the Cygwin Setup program with option
<code class="literal">--help</code> for an up to date list:
</p><pre class="screen">
    --allow-unsupported-windows    Allow old, unsupported Windows versions
 -a --arch                         Architecture to install (x86_64 or x86)
 -C --categories                   Specify categories to install
    --compact-os                   Compress installed files with Compact OS
                                   (xpress4k, xpress8k, xpress16k, lzx)
 -o --delete-orphans               Remove orphaned packages
 -A --disable-buggy-antivirus      Disable known or suspected buggy anti virus
                                   software packages during execution
 -D --download                     Download packages from internet
 -f --force-current                Select the current version for all packages
 -h --help                         Print help
 -I --include-source               Automatically install source for every
                                   package installed
 -i --ini-basename                 Use a different basename, e.g. "foo",
                                   instead of "setup"
 -U --keep-untrusted-keys          Use untrusted keys and retain all
    --lang                         Specify GUI language langid
 -L --local-install                Install packages from local directory
 -l --local-package-dir            Local package directory
 -m --mirror-mode                  Skip package availability check when
                                   installing from local directory (requires
                                   local directory to be clean mirror!)
 -B --no-admin                     Do not check for and enforce running as
                                   Administrator
 -d --no-desktop                   Disable creation of desktop shortcut
 -r --no-replaceonreboot           Disable replacing in-use files on next reboot
 -n --no-shortcuts                 Disable creation of desktop and start menu
                                   shortcuts
 -N --no-startmenu                 Disable creation of start menu shortcut
 -X --no-verify                    Don't verify setup.ini signatures
    --no-version-check             Suppress checking if a newer version of
                                   setup is available
 -w --no-warn-deprecated-windows   Don't warn about deprecated Windows versions
    --enable-old-keys              Enable old cygwin.com keys
 -O --only-site                    Do not download mirror list.  Only use sites
                                   specified with -s.
 -M --package-manager              Semi-attended chooser-only mode
 -P --packages                     Specify packages to install
 -p --proxy                        HTTP/FTP proxy (host:port)
 -Y --prune-install                Prune the installation to only the requested
                                   packages
 -K --pubkey                       URL or absolute path of extra public key
                                   file (RFC4880 format)
 -q --quiet-mode                   Unattended setup mode
 -c --remove-categories            Specify categories to uninstall
 -x --remove-packages              Specify packages to uninstall
 -R --root                         Root installation directory
 -S --sexpr-pubkey                 Extra DSA public key in s-expr format
 -s --site                         Download site URL
    --symlink-type                 Symlink type (lnk, native, sys, wsl)
 -u --untrusted-keys               Use untrusted saved extra keys
 -g --upgrade-also                 Also upgrade installed packages
    --user-agent                   User agent string for HTTP requests
 -v --verbose                      Verbose output
 -V --version                      Show version
 -W --wait                         When elevating, wait for elevated child
                                   process
</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.noroot"></a><p><b>2.4.</b></p></td><td align="left" valign="top"><p>Can I install Cygwin without administrator rights?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes.  The default installation requests administrator rights because
this allows to set up the Cygwin environment so that all users can start
a Cygwin shell out of the box.  However, if you don't have administrator
rights for your machine, and the admins don't want to install it for you,
you can install Cygwin just for yourself by downloading the Cygwin Setup
program, and then start
it from the command line or via the "Run..." dialog from the start menu
using the <code class="literal">--no-admin</code> option, for instance:</p><p>
</p><pre class="screen">
  setup-x86_64.exe --no-admin
</pre><p>
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.c"></a><p><b>2.5.</b></p></td><td align="left" valign="top"><p>Why not install in C:\?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The Cygwin Setup program will prompt you for a "root" directory.
The default is <code class="literal">C:\cygwin</code>, but you can change it.  You are urged not to
choose something like <code class="literal">C:\</code> (the root directory on the system drive) for
your Cygwin root.  If you do, then critical Cygwin system directories
like <code class="literal">etc</code>, <code class="literal">lib</code> and <code class="literal">bin</code> could easily be corrupted by
other (non-Cygwin) applications or packages that use <code class="literal">\etc</code>,
<code class="literal">\lib</code> or <code class="literal">\bin</code>.  Perhaps there is no conflict now, but who
knows what you might install in the future?  It's also just good common
sense to segregate your Cygwin "filesystems" from the rest of your
Windows system disk.
</p><p>(In the past, there had been genuine bugs that would cause problems
for people who installed in <code class="literal">C:\</code>, but we believe those are gone
now.)
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.old-versions"></a><p><b>2.6.</b></p></td><td align="left" valign="top"><p>Can I use the Cygwin Setup program to get old versions of packages (like gcc-2.95)?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The Cygwin Setup program can be used to install any packages that are on a
Cygwin mirror, which usually includes at least one version previous to the
current one. The complete list may be searched at 
<a class="ulink" href="https://cygwin.com/packages/" target="_top">https://cygwin.com/packages/</a>.  There is no complete archive of
older packages. If you have a problem with the current version of
a Cygwin package, please report it to the mailing list using the 
guidelines at <a class="ulink" href="https://cygwin.com/problems.html" target="_top">https://cygwin.com/problems.html</a>.
</p><p>That said, if you really need an older package, you may be able to find
an outdated or archival mirror by searching the web for an old package
version (for example, <code class="literal">gcc2-2.95.3-10-src.tar.bz2</code>), but keep in
mind that this older version will not be supported by the mailing list
and that installing the older version will not help improve Cygwin.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.install-security"></a><p><b>2.7.</b></p></td><td align="left" valign="top"><p>How does Cygwin secure the installation and update process?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
Here is how Cygwin secures the installation and update process to counter
<a class="ulink" href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack" target="_top">man-in-the-middle (MITM) attacks</a>:
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>The Cygwin website provides the Cygwin Setup program
using HTTPS (SSL/TLS).
This authenticates that the Cygwin Setup program
came from the Cygwin website
(users simply use their web browsers to download the Cygwin Setup program).
You can use tools like Qualsys' SSL Server Test,
<a class="ulink" href="https://www.ssllabs.com/ssltest/" target="_top">https://www.ssllabs.com/ssltest/</a>,
to check the HTTPS configuration of Cygwin.
The cygwin.com site supports HTTP Strict Transport Security (HSTS),
which forces the browser to keep using HTTPS once the browser has seen
it before (this counters many downgrade attacks).
</p></li><li class="listitem"><p>The Cygwin Setup program has the
Cygwin public key embedded in it.
The Cygwin public key is protected from attacker subversion
during transmission by the previous step, and this public
key is then used to protect all later steps.
You can confirm that the key is in the Cygwin Setup program by looking at the setup project
(<a class="ulink" href="http://sourceware.org/cygwin-apps/setup.html" target="_top">http://sourceware.org/cygwin-apps/setup.html</a>)
source code file <code class="literal">cyg-pubkey.h</code>
(the key is automatically generated from file <code class="literal">cygwin.pub</code>).
</p></li><li class="listitem"><p>The Cygwin Setup program downloads
the package list <code class="literal">setup.ini</code> from a mirror
and checks its digital signature.
The package list is in the files
<code class="filename">setup.xz</code>, <code class="filename">setup.zst</code>,
<code class="literal">setup.bz2</code> (compressed) or
<code class="literal">setup.ini</code> (uncompressed) on the selected mirror.
The package list includes for every official Cygwin package
the package name, cryptographic hash, and length (in bytes).
The Cygwin Setup program also gets the relevant <code class="literal">.sig</code>
(signature) file for that package list, and checks that the package list
is properly signed with the Cygwin public key embedded in the Setup program.
A mirror could corrupt the package list and/or signature, but this
would be detected by the Cygwin Setup program's signature detection
(unless you use the <code class="literal">-X</code> option to disable signature checking).
The Cygwin Setup program also checks the package list
timestamp/version and reports to the user if the file
goes backwards in time; that process detects downgrade attacks
(e.g., where an attacker subverts a mirror to send a signed package list
that is older than the currently-downloaded version).
</p></li><li class="listitem"><p>The packages to be installed
(which may be updates) are downloaded and both their
lengths and cryptographic hashes
(from the signed <code class="filename">setup.xz/.zst/.bz2/.ini</code> file) are checked.
Non-matching packages are rejected, countering any attacker's
attempt to subvert the files on a mirror.
Cygwin currently uses the cryptographic hash function SHA-512
for the <code class="literal">setup.ini</code> files.
</p></li></ol></div><p>
Cygwin uses the cryptographic hash algorithm SHA-512 as of 2015-03-23.
The earlier 2015-02-06 update of the setup program added support for SHA-512
(Cygwin previously used MD5).
There are no known practical exploits of SHA-512 (SHA-512 is part of the
widely-used SHA-2 suite of cryptographic hashes).
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.increase-install-security"></a><p><b>2.8.</b></p></td><td align="left" valign="top"><p>What else can I do to ensure that my installation and updates are secure?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
To best secure your installation and update process, download
the Cygwin Setup program, and then
check its signature (using a signature-checking tool you trust)
using the Cygwin public key
(<a class="ulink" href="https://cygwin.com/key/pubring.asc" target="_top">https://cygwin.com/key/pubring.asc</a>).
This was noted on the front page for installing and updating.
</p><p>
If you use the actual Cygwin public key, and have an existing secure
signature-checking process, you will counter many other
attacks such as subversion of the Cygwin website and
malicious certificates issued by untrustworthy certificate authorities (CAs).
One challenge, of course, is ensuring that
you have the actual Cygwin public key.
You can increase confidence in the Cygwin public key by checking older copies
of the Cygwin public key (to see if it's been the same over time).
Another challenge is having a secure signature-checking process.
You can use GnuPG to check signatures; if you have a trusted Cygwin
installation you can install GnuPG.
Otherwise, to check the signature you must use an existing trusted tool or
install a signature-checking tool you can trust.
</p><p>
Not everyone will go through this additional effort,
but we make it possible for those who want that extra confidence.
We also provide automatic mechanisms
(such as our use of HTTPS) for those with limited time and
do not want to perform the signature checking on the Cygwin Setup program itself.
Once the correct Setup program is running, it will counter other attacks
as described in
<a class="xref" href="faq.html#faq.setup.install-security" title="2.7.">Q: 2.7</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.virus"></a><p><b>2.9.</b></p></td><td align="left" valign="top"><p>Is the Cygwin Setup program, or one of the packages, infected with a virus?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Unlikely.  Unless you can confirm it, please don't report it to the
mailing list.  Anti-virus products have been known to detect false
positives when extracting compressed tar archives.  If this causes
problems for you, consider disabling your anti-virus software when
running the Cygwin Setup program.  Read the next entry for a fairly safe way to do
this.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.hang"></a><p><b>2.10.</b></p></td><td align="left" valign="top"><p>My computer hangs when I run Cygwin Setup!</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Both Network Associates (formerly McAfee) and Norton anti-virus
products have been reported to "hang" when extracting Cygwin tar
archives.  If this happens to you, consider disabling your anti-virus
software when running the Cygwin Setup program.  The following procedure should be
a fairly safe way to do that:
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Download the Cygwin Setup program and scan it explicitly.
</p></li><li class="listitem"><p>Turn off the anti-virus software.
</p></li><li class="listitem"><p>Run the Cygwin Setup program to download and install or upgrade
all desired packages.
</p></li><li class="listitem"><p>Re-activate your anti-virus software and scan everything
in C:\cygwin (or wherever you chose to install), or your entire hard
disk if you are paranoid.
</p></li></ol></div><p>This should be safe, but only if the Cygwin Setup program is not substituted by
something malicious.
See also
<a class="xref" href="faq.html#faq.setup.install-security" title="2.7.">Q: 2.7</a>
for a description of how the
Cygwin project counters man-in-the-middle (MITM) attacks.
</p><p>See also <a class="xref" href="faq.html#faq.using.bloda" title="4.44.">BLODA</a>
for a list of applications that have been known, at one time or another, to
interfere with the normal functioning of Cygwin.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.what-packages"></a><p><b>2.11.</b></p></td><td align="left" valign="top"><p>What packages should I download? Where are 'make', 'gcc', 'vi', etc?  </p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>When using the Cygwin Setup program for the first time, the default is to install
a minimal subset of all available packages.  If you want anything beyond that,
you will have to select it explicitly.  See 
<a class="ulink" href="https://cygwin.com/packages/" target="_top">https://cygwin.com/packages/</a> for a searchable list of available
packages, or use <code class="literal">cygcheck -p </code> as described in the Cygwin
User's Guide at
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/cygcheck.html" target="_top">https://cygwin.com/cygwin-ug-net/cygcheck.html</a>.
</p><p>If you want to build programs, of course you'll need <code class="literal">gcc</code>,
<code class="literal">binutils</code>, <code class="literal">make</code> and probably other packages from the
``Devel'' category. Text editors can be found under ``Editors''.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.everything"></a><p><b>2.12.</b></p></td><td align="left" valign="top"><p>How do I just get everything?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Long ago, the default was to install everything, much to the
irritation of most users.  Now the default is to install only a basic
core of packages. The Cygwin Setup program is designed to make it easy to browse
categories and select what you want to install or omit from those
categories.
There are now more than 10000 Cygwin packages requiring more than 150GB
of disk space just to download and hundreds of GB more to install so you
are strongly advised not to attempt to
<a class="ulink" href="https://cygwin.com/install.html#everything" target="_top">install everything</a>
at once, unless you have a lot of free disk space, a very high speed network
connection, and the system will not be required for any other purpose for
many hours (or days) until installation completes.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.disk-space"></a><p><b>2.13.</b></p></td><td align="left" valign="top"><p>How much disk space does Cygwin require?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>That depends, obviously, on what you've chosen to download and
install.  A full installation today is many hundreds of GB
installed, not including the package archives themselves nor the source
code.
</p><p>After installation, the package archives remain in your ``Local
Package Directory''.  By default the location of the Cygwin Setup program.
You may conserve disk space by
deleting the subdirectories there.  These directories will have very weird
looking names, being encoded with their URLs
(named <code class="literal">http%3a%2f...cygwin...%2f</code>).
</p><p>Of course, you can keep them around in case you want to reinstall a
package. If you want to clean out only the outdated packages, Michael Chase
has written a script called <code class="literal">clean_setup.pl</code>, available
at <code class="filename">unsupported/clean_setup.pl</code> in a Cygwin mirror.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.what-upgraded"></a><p><b>2.14.</b></p></td><td align="left" valign="top"><p>How do I know which version I upgraded from?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Detailed logs of the most recent Cygwin Setup session can be found in
<code class="filename">/var/log/setup.log.full</code> and less verbose information about
prior actions is in <code class="filename">/var/log/setup.log</code>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.setup-fails"></a><p><b>2.15.</b></p></td><td align="left" valign="top"><p>What if the Cygwin Setup program fails?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>First, make sure that you are using the latest version of the Cygwin Setup program.
The latest version is always available from the Cygwin Home Page at
<a class="ulink" href="https://cygwin.com/" target="_top">https://cygwin.com/</a>.
</p><p>If you are downloading from the Internet, setup will fail if it cannot
download the list of mirrors at <a class="ulink" href="https://cygwin.com/mirrors.lst" target="_top">https://cygwin.com/mirrors.lst</a>.
It could be that the network is too busy.  Something similar could be the
cause of a download site not working.  Try another mirror, or try again
later.
</p><p>If the Cygwin Setup program refuses to download a package that you know needs to be
upgraded, try deleting that package's entry from /etc/setup.  If you are
reacting quickly to an announcement on the mailing list, it could be
that the mirror you are using doesn't have the latest copy yet.  Try
another mirror, or try again tomorrow.
</p><p>If the Cygwin Setup program has otherwise behaved strangely, check the files
<code class="filename">setup.log</code> and <code class="filename">setup.log.full</code> in
<code class="filename">/var/log</code> (<code class="filename">C:\cygwin\var\log</code> by
default).  It may provide some clues as to what went wrong and why.
</p><p>If you're still baffled, search the Cygwin mailing list for clues.
Others may have the same problem, and a solution may be posted there.
If that search proves fruitless, send a query to the Cygwin mailing
list.  You must provide complete details in your query: version of
the Cygwin Setup program, options you selected, contents of setup.log and setup.log.full,
what happened that wasn't supposed to happen, etc.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.name-with-space"></a><p><b>2.16.</b></p></td><td align="left" valign="top"><p>My Windows logon name has a space in it, will this cause problems?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Most definitely yes!  UNIX shells (and thus Cygwin) use the space
character as a word delimiter.  Under certain circumstances, it is
possible to get around this with various shell quoting mechanisms, but
you are much better off if you can avoid the problem entirely.
</p><p>You have two choices:
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>You can rename the user in the Windows User Manager GUI.
</p></li><li class="listitem"><p>If that's not possible, you can create an /etc/passwd file
using the <span class="command"><strong>mkpasswd</strong></span> command.  Then you can simply edit your
Cygwin user name (first field). It's also a good idea to avoid spaces in the
home directory.
</p></li></ol></div></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.home"></a><p><b>2.17.</b></p></td><td align="left" valign="top"><p>My <code class="literal">HOME</code> environment variable is not what I want.</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>When starting Cygwin from Windows, <code class="literal">HOME</code> is determined
as follows:
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>If <code class="literal">HOME</code> is set in the Windows environment,
translated to POSIX form.
</p></li><li class="listitem"><p>Otherwise, use the pw_home field from the passwd entry as
returned by <span class="command"><strong>getent passwd</strong></span>.  If you want to learn how this
field is set by Cygwin and how you can change it, this is explained in great
detail in the Cygwin User's Guide at
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/ntsec.html" target="_top">https://cygwin.com/cygwin-ug-net/ntsec.html</a>.
</p></li></ol></div><p>When using Cygwin from a network login (via ssh for instance),
<code class="literal">HOME</code> is always taken from the passwd entry.
</p><p>If your <code class="literal">HOME</code> is set to a value such as /cygdrive/c,
it is likely that it was set in Windows. Start a DOS Command Window and type 
"set HOME" to verify if this is the case.
</p><p>Access to shared drives is often restricted when starting from the
network, thus Domain users may wish to have a different <code class="literal">HOME</code>
in the Windows environment (on shared drive) than in Cygwin (on local drive).
Note that ssh only considers the account information as retrieved by
getpwnam(3), disregarding <code class="literal">HOME</code>. 
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.uninstall-packages"></a><p><b>2.18.</b></p></td><td align="left" valign="top"><p>How do I uninstall individual packages?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Run the Cygwin Setup program as you would to install packages.  In the
``Select packages to install'' dialog, choose ``Up To Date'' in the
<code class="literal">View</code> drop-down menu, and locate the package.  Choose the
``Uninstall'' action from the drop-down menu in the ``New'' column. Proceed by
clicking ``Next''.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.uninstall-service"></a><p><b>2.19.</b></p></td><td align="left" valign="top"><p>How do I uninstall a Cygwin service?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>List all services you have installed with 
<code class="literal">cygrunsrv -L</code>. If you do not have 
<code class="literal">cygrunsrv</code> installed, skip this FAQ.
</p></li><li class="listitem"><p>Before removing the service, you should stop it with 
<code class="literal">cygrunsrv --stop <em class="replaceable"><code>service_name</code></em></code>. 
If you have <code class="literal">inetd</code> configured to run as a standalone
service, it will not show up in the list, but 
<code class="literal">cygrunsrv --stop inetd</code> will work to stop it as 
well.
</p></li><li class="listitem"><p>Lastly, remove the service with
<code class="literal">cygrunsrv --remove <em class="replaceable"><code>service_name</code></em></code>.
</p></li></ol></div></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.uninstall-all"></a><p><b>2.20.</b></p></td><td align="left" valign="top"><p>How do I uninstall <span class="bold"><strong>all</strong></span> of Cygwin?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Setup has no automatic uninstall facility.  The recommended method to remove all 
of Cygwin is as follows:
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>If you have any Cygwin services running, remove by repeating 
the instructions in <a class="ulink" href="https://cygwin.com/faq/faq.html#faq.setup.uninstall-service" target="_top">https://cygwin.com/faq/faq.html#faq.setup.uninstall-service</a> for
all services that you installed.  Common services that might have been
installed are <code class="literal">cygsshd</code>, <code class="literal">cron</code>, 
<code class="literal">cygserver</code>, <code class="literal">inetd</code>, <code class="literal">apache</code>, 
<code class="literal">postgresql</code>, and so on.
</p></li><li class="listitem"><p>Stop the X11 server if it is running, and terminate any Cygwin programs 
that might be running in the background.  Exit the command prompt and ensure
that no Cygwin processes remain.  Note: If you want to save your mount points for a later 
reinstall, first save the output of <code class="literal">mount -m</code> as described at 
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/mount.html" target="_top">https://cygwin.com/cygwin-ug-net/mount.html</a>.
</p></li><li class="listitem"><p>If you installed <code class="literal">cyglsa.dll</code> by running the
shell script <code class="literal">/usr/bin/cyglsa-config</code> as described in
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/ntsec.html" target="_top">https://cygwin.com/cygwin-ug-net/ntsec.html</a>, then you need to
configure Windows to stop using the LSA authentication package.  You do so by
editing the registry and restoring
<code class="literal">/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Lsa/Authentication Packages</code>
back to it's original value of <code class="literal">msv1_0</code>, and then rebooting.
</p></li><li class="listitem"><p>Delete the Cygwin root folder and all subfolders.  If you get
an error that an object is in use, then ensure that you've stopped all services
and closed all Cygwin programs.  If you get a 'Permission Denied' error then
you will need to modify the permissions and/or ownership of the files or
folders that are causing the error.  For example, sometimes files used by
system services end up owned by the SYSTEM account and not writable by regular
users.</p><p>The quickest way to delete the entire tree if you run into this problem
is to take ownership of all files and folders to your account.  To do
this in Windows Explorer, right click on the root Cygwin folder, choose
Properties, then the Security tab.  If you are using Simple File Sharing, you
will need to boot into Safe Mode to access the Security tab.  Select Advanced,
then go to the Owner tab and make sure your account is listed as the owner.
Select the 'Replace owner on subcontainers and objects' checkbox and press Ok.
After Explorer applies the changes you should be able to delete the entire tree
in one operation.  Note that you can also achieve by using other tools such as
<code class="literal">icacls.exe</code> or directly from Cygwin by using
<code class="literal">chown</code>.  Please note that you shouldn't use the
recursive form of chown on directories that have other file systems
mounted under them (specifically you must avoid
<code class="literal">/proc</code>) since you'd change ownership of the files under those
mount points as well.
</p></li><li class="listitem"><p>Delete the Cygwin shortcuts on the Desktop and Start Menu, and
anything left by the Cygwin Setup program in the download directory.  However, if you
plan to reinstall Cygwin it's a good idea to keep your
download directory since you can reinstall the packages left in its cache
without redownloading them.
</p></li><li class="listitem"><p>If you added Cygwin to your system path, you should remove it unless you 
plan to reinstall Cygwin to the same location.  Similarly, if you set your 
CYGWIN environment variable system-wide and don't plan to reinstall, you should 
remove it.
</p></li><li class="listitem"><p>Finally, if you want to be thorough you can delete the registry tree 
<code class="literal">Software\Cygwin</code> under <code class="literal">HKEY_LOCAL_MACHINE</code> and/or 
<code class="literal">HKEY_CURRENT_USER</code>.  However, if you followed the directions above you 
will have already removed everything important.  Typically only the installation
directory has been stored in the registry at all.
</p></li></ol></div></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.testrels"></a><p><b>2.21.</b></p></td><td align="left" valign="top"><p>How do I install Cygwin test releases?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>You can install Cygwin test releases just like test releases of
any other package using the Cygwin Setup program.  Ideally, you install
not only the <span class="bold"><strong>cygwin</strong></span> test package, but
also the <span class="bold"><strong>cygwin-debuginfo</strong></span> test package
with the same version number.  The cygwin-debuginfo package allows source
code debugging using gdb.  Install the
<span class="bold"><strong>cygwin-devel</strong></span> test package, if you also
want to test building against a new API.
</p><p>However, are you sure you want to do this?  Test releases are risky.
They have only been marginally tested most of the time.  Use them
<span class="bold"><strong>only</strong></span> if there is a feature or bugfix that
you need to try, and you are willing to deal with any problems, or at the
request of a Cygwin developer.
</p><p>The operative word in trying the test releases is
"<span class="emphasis"><em>trying</em></span>".  If you notice a problem with the snapshot
that was not present in the release DLL (what we call a "regression"),
please report it to the Cygwin mailing list
(see <a class="ulink" href="https://cygwin.com/problems.html" target="_top">https://cygwin.com/problems.html</a> for problem
reporting guidelines).  If you wish to go back to the most recent non-test
release of the Cygwin DLL, close all Cygwin processes, as usual, start the
Cygwin Setup program and choose the most recent non-test release of the
cygwin package, as well as the cygwin-debuginfo and cygwin-devel packages.
That's all there is to it.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.mirror"></a><p><b>2.22.</b></p></td><td align="left" valign="top"><p>Can the Cygwin Setup program maintain a ``mirror''?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>NO. The Cygwin Setup program cannot do this for you.  Use a tool designed for
this purpose.  See <a class="ulink" href="http://rsync.samba.org/" target="_top">http://rsync.samba.org/</a>,
<a class="ulink" href="http://www.gnu.org/software/wget/" target="_top">http://www.gnu.org/software/wget/</a> for utilities that can do this for you.
For more information on setting up a custom Cygwin package server, see
the <a class="ulink" href="https://cygwin.com/package-server.html.html" target="_top">Cygwin Package Server page</a>.

</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.cd"></a><p><b>2.23.</b></p></td><td align="left" valign="top"><p>How can I make my own portable Cygwin on CD?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>While some users have successfully done this, for example Indiana
University's XLiveCD <a class="ulink" href="http://racinfo.indiana.edu/research/xlivecd.php" target="_top">http://racinfo.indiana.edu/research/xlivecd.php</a>, there is no
easy way to do it. Full instructions for constructing a portable Cygwin
on CD by hand can be found on the mailing list at
<a class="ulink" href="https://www.cygwin.com/ml/cygwin/2003-07/msg01117.html" target="_top">https://www.cygwin.com/ml/cygwin/2003-07/msg01117.html</a>
(Thanks to fergus at bonhard dot uklinux dot net for these instructions.)
Please note that these instructions are very old and are referring to the
somewhat different setup of a Cygwin 1.5.x release.  As soon as somebody set
this up for recent Cygwin releases, we might add this information here.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.setup.registry"></a><p><b>2.24.</b></p></td><td align="left" valign="top"><p>How do I save, restore, delete, or modify the Cygwin information stored in the registry?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin doesn't store anything important in the registry anymore for
quite some time.  There's no reason to save, restore or delete it.
</p></td></tr><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="faq.resources"></a>3. Further Resources</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>3.1. <a href="faq.html#faq.resources.documentation">Where's the documentation?</a></dt><dt>3.2. <a href="faq.html#faq.resources.mailing-lists">What Cygwin mailing lists can I join?</a></dt><dt>3.3. <a href="faq.html#faq.resources.problems">What if I have a problem? (Or: Why won't you/the mailing list answer my questions?)</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.resources.documentation"></a><p><b>3.1.</b></p></td><td align="left" valign="top"><p>Where's the documentation?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you have installed Cygwin, you can find lots of documentation in
<code class="literal">/usr/share/doc/</code>.  Some packages have Cygwin specific
instructions in a file
<code class="literal">/usr/share/doc/Cygwin/<em class="replaceable"><code>package_name</code></em>.README</code>.
In addition, many packages ship with standard documentation, which you can
find in
<code class="literal">/usr/share/doc/<em class="replaceable"><code>package_name</code></em></code> or
by using the <code class="literal">man</code> or <code class="literal">info</code> tools. (Hint:
use <code class="literal">cygcheck -l <em class="replaceable"><code>package_name</code></em></code> to
list what man pages the package includes.)  Some older packages still keep
their documentation in <code class="literal">/usr/doc/</code>
instead of <code class="literal">/usr/share/doc/</code>.
</p><p>There are links to quite a lot of documentation on the main Cygwin
project web page, <a class="ulink" href="https://cygwin.com/" target="_top">https://cygwin.com/</a>, including this FAQ.
Be sure to at least read any 'Release Notes' or 'Readme' or 'read this'
links on the main web page, if there are any.
</p><p>There is a comprehensive Cygwin User's Guide at
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/cygwin-ug-net.html" target="_top">https://cygwin.com/cygwin-ug-net/cygwin-ug-net.html</a>
and an API Reference at
<a class="ulink" href="https://cygwin.com/cygwin-api/cygwin-api.html" target="_top">https://cygwin.com/cygwin-api/cygwin-api.html</a>.
</p><p>You can find documentation for the individual GNU tools at
<a class="ulink" href="http://www.gnu.org/manual/" target="_top">http://www.gnu.org/manual/</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.resources.mailing-lists"></a><p><b>3.2.</b></p></td><td align="left" valign="top"><p>What Cygwin mailing lists can I join?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Comprehensive information about the Cygwin mailing lists can be found at
<a class="ulink" href="https://cygwin.com/lists.html" target="_top">https://cygwin.com/lists.html</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.resources.problems"></a><p><b>3.3.</b></p></td><td align="left" valign="top"><p>What if I have a problem? (Or: Why won't you/the mailing list answer my questions?)</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Comprehensive information about reporting problems with Cygwin can be found at <a class="ulink" href="https://cygwin.com/problems.html" target="_top">https://cygwin.com/problems.html</a>.
</p></td></tr><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="faq.using"></a>4. Using Cygwin</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>4.1. <a href="faq.html#faq.using.missing-dlls">Why can't my application locate cygncurses-8.dll?  or cygintl-3.dll?  or cygreadline6.dll?  or ...?</a></dt><dt>4.2. <a href="faq.html#faq.using.startup-slow">Starting a new terminal window is slow. What's going on?</a></dt><dt>4.3. <a href="faq.html#faq.using.slow">Why is Cygwin suddenly so slow?</a></dt><dt>4.4. <a href="faq.html#faq.using.shares">Why can't my services access network shares?</a></dt><dt>4.5. <a href="faq.html#faq.using.path">How should I set my PATH?</a></dt><dt>4.6. <a href="faq.html#faq.using.not-found">Bash (or another shell) says "command not found", but it's right there!</a></dt><dt>4.7. <a href="faq.html#faq.using.converting-paths">How do I convert between Windows and UNIX paths?</a></dt><dt>4.8. <a href="faq.html#faq.using.bashrc">Why doesn't bash read my .bashrc file on startup?</a></dt><dt>4.9. <a href="faq.html#faq.using.bash-insensitive">How can I get bash filename completion to be case insensitive?</a></dt><dt>4.10. <a href="faq.html#faq.using.filename-spaces">Can I use paths/filenames containing spaces in them?</a></dt><dt>4.11. <a href="faq.html#faq.using.shortcuts">Why can't I cd into a shortcut to a directory?</a></dt><dt>4.12. <a href="faq.html#faq.using.find">I'm having basic problems with find.  Why?</a></dt><dt>4.13. <a href="faq.html#faq.using.su">Why doesn't su work?</a></dt><dt>4.14. <a href="faq.html#faq.using.man">Why doesn't man -k,
apropos or whatis work?</a></dt><dt>4.15. <a href="faq.html#faq.using.chmod">Why doesn't chmod work?</a></dt><dt>4.16. <a href="faq.html#faq.using.shell-scripts">Why doesn't my shell script work?</a></dt><dt>4.17. <a href="faq.html#faq.using.printing">How do I print under Cygwin?</a></dt><dt>4.18. <a href="faq.html#faq.using.unicode">Why don't international (Unicode) characters work?</a></dt><dt>4.19. <a href="faq.html#faq.using.weirdchars">My application prints international characters but I only
see gray boxes</a></dt><dt>4.20. <a href="faq.html#faq.using.multiple-copies">Is it OK to have multiple copies of the DLL?</a></dt><dt>4.21. <a href="faq.html#faq.using.third-party.multiple-copies">
I read the above but I want to bundle Cygwin with a product, and ship it
to customer sites.  How can I do this without conflicting with any Cygwin
installed by the user?
</a></dt><dt>4.22. <a href="faq.html#faq.using.bundling-cygwin">
Can I bundle Cygwin with my product for free?
</a></dt><dt>4.23. <a href="faq.html#faq.using.older-cygwin-conflict">
But doesn't that mean that if some application installs an older Cygwin
DLL on top of a newer DLL, my application will break?
</a></dt><dt>4.24. <a href="faq.html#faq.using.missing-packages">Why isn't package XYZ available in Cygwin?</a></dt><dt>4.25. <a href="faq.html#faq.using.old-packages">Why is the Cygwin package of XYZ so out of date?</a></dt><dt>4.26. <a href="faq.html#faq.using.accessing-drives">How can I access other drives?</a></dt><dt>4.27. <a href="faq.html#faq.using.copy-and-paste">How can I copy and paste into Cygwin console windows?</a></dt><dt>4.28. <a href="faq.html#faq.using.firewall">What firewall should I use with Cygwin? </a></dt><dt>4.29. <a href="faq.html#faq.using.sharing-files">How can I share files between Unix and Windows?</a></dt><dt>4.30. <a href="faq.html#faq.using.case-sensitive">Is Cygwin case-sensitive??</a></dt><dt>4.31. <a href="faq.html#faq.using.dos-filenames">What about DOS special filenames?</a></dt><dt>4.32. <a href="faq.html#faq.using.sparse-files">Does Cygwin support sparse files?</a></dt><dt>4.33. <a href="faq.html#faq.using.hangs">When it hangs, how do I get it back?</a></dt><dt>4.34. <a href="faq.html#faq.using.directory-structure">Why the weird directory structure?</a></dt><dt>4.35. <a href="faq.html#faq.using.anti-virus">How do anti-virus programs like Cygwin?</a></dt><dt>4.36. <a href="faq.html#faq.using.emacs">Is there a Cygwin port of GNU Emacs?</a></dt><dt>4.37. <a href="faq.html#faq.using.xemacs">Is there a Cygwin port of XEmacs?</a></dt><dt>4.38. <a href="faq.html#faq.using.symlinkstoppedworking">Why don't some of my old symlinks work anymore?</a></dt><dt>4.39. <a href="faq.html#faq.using.symlinks-samba">Why don't symlinks work on Samba-mounted filesystems?</a></dt><dt>4.40. <a href="faq.html#faq.using.ssh-pubkey-stops-working">Why does public key authentication with ssh fail after updating to Cygwin 1.7.34 or later?</a></dt><dt>4.41. <a href="faq.html#faq.using.same-with-rhosts">Why is my .rhosts file not recognized by rlogin anymore after updating to Cygwin 1.7.34?</a></dt><dt>4.42. <a href="faq.html#faq.using.same-with-permissions">Why do my files have extra permissions after updating to Cygwin 1.7.34?</a></dt><dt>4.43. <a href="faq.html#faq.using.tcl-tk">Why do my Tk programs not work anymore?</a></dt><dt>4.44. <a href="faq.html#faq.using.bloda">What applications have been found to interfere with Cygwin?</a></dt><dt>4.45. <a href="faq.html#faq.using.fixing-fork-failures">How do I fix fork() failures?</a></dt><dt>4.46. <a href="faq.html#faq.using.fixing-find_fast_cwd-warnings">How do I fix find_fast_cwd warnings?</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.missing-dlls"></a><p><b>4.1.</b></p></td><td align="left" valign="top"><p>Why can't my application locate cygncurses-8.dll?  or cygintl-3.dll?  or cygreadline6.dll?  or ...?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Well, something has gone wrong somehow...
</p><p>To repair the damage, you must run the Cygwin Setup program again, and re-install the
package which provides the missing DLL package.
</p><p>If you already installed the package at one point, the Cygwin Setup
program won't show the option to install the package by default.  In the
``Select packages to install'' dialog, choose ``Full'' in the
<code class="literal">View</code> drop-down menu.  This lists all packages, even those
that are already installed.  Scroll down to locate the missing package, for
instance <code class="literal">libncurses8</code>.  Choose the ``Reinstall'' action from
the drop-down menu in the ``New'' column.  Continue with the installation.
</p><p>For a detailed explanation of the general problem, and how to extend
it to other missing DLLs and identify their containing packages, see
<a class="ulink" href="https://cygwin.com/ml/cygwin/2002-01/msg01619.html" target="_top">https://cygwin.com/ml/cygwin/2002-01/msg01619.html</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.startup-slow"></a><p><b>4.2.</b></p></td><td align="left" valign="top"><p>Starting a new terminal window is slow. What's going on?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>There are many possible causes for this.</p><p>If your terminal windows suddenly began starting slowly after a
Cygwin upgrade, it may indicate issues in the authentication
setup.</p><p>For almost all its lifetime, Cygwin has used Unix-like
<code class="filename">/etc/passwd</code> and <code class="filename">/etc/group</code>
files to mirror the contents of the Windows SAM and AD databases.
Although these files can still be used, since Cygwin 1.7.34, new
installations now use the SAM/AD databases directly.</p><p>To switch to the new method, move these two files out of the way
and restart the Cygwin terminal. That runs Cygwin in its new default
mode.</p><p>If you are on a system that isn't using AD domain logins, this
makes Cygwin use the native Windows SAM database directly, which may be
faster than the old method involving <code class="filename">/etc/passwd</code>
and such. At worst, it will only be a bit slower. (The speed difference
you see depends on which benchmark you run.) For the AD case, it can be
slower than the old method, since it is trading a local file read for a
network request. Version 1.7.35 will reduce the number of AD server
requests the DLL makes relative to 1.7.34, with the consequence that you
will now have to alter <code class="filename">/etc/nsswitch.conf</code> in order
to change your Cygwin home directory, instead of being able to change it
from the AD configuration.</p><p>If you are still experiencing very slow shell startups, there are
a number of other things you can look into:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>One common cause of slow Cygwin Terminal starts is a bad DNS
    setup. This particularly affects AD clients, but there may be other
    things in your Cygwin startup that depend on getting fast answers
    back from a network server.</p><p>Keep in mind that this may affect Cygwin even when the domain
    controller is on the same machine as Cygwin, or is on a nearby
    server. A bad DNS server IP can cause long delays while the local
    TCP/IP stack times out on a connection to a server that simply isn't
    there, for example.</p></li><li class="listitem"><p>Another cause for AD client system is slow DC replies,
    commonly observed in configurations with remote DC access. The
    Cygwin DLL queries information about every group you're in to
    populate the local cache on startup. You may speed up this process a
    little by caching your own information in local files. Run these
    commands in a Cygwin terminal with write access to
    <code class="filename">/etc</code>:</p><pre class="screen">getent passwd $(id -u) &gt; /etc/passwd
getent group $(id -G) &gt; /etc/group</pre><p>Also, set <code class="filename">/etc/nsswitch.conf</code> as
    follows:</p><pre class="screen">passwd: files db
group:  files db</pre><p>This will limit the need for Cygwin to contact the AD domain
    controller (DC) while still allowing for additional information to
    be retrieved from DC, such as when listing remote
    directories.</p></li><li class="listitem"><p>Either in addition to the previous item or instead of it, you
    can run <a class="ulink" href="https://cygwin.com/cygwin-ug-net/using-cygserver.html" target="_top"><span class="command"><strong>cygserver</strong></span></a>
    as a local caching service to speed up DC requests.</p><p>Cygwin programs will check with <span class="command"><strong>cygserver</strong></span>
    before trying to query the DC directly.</p></li><li class="listitem"><p>A less preferable option is to create a static read-only cache
    of the authentication data. This is the old-fashioned method of
    making Cygwin integrate with AD, the only method available in
    releases before 1.7.34. To do this, run <span class="command"><strong>mkpasswd</strong></span>
    and <span class="command"><strong>mkgroup</strong></span>, then put the following into
    <code class="filename">/etc/nsswitch.conf</code> to make Cygwin treat these
    files as the only sources of user and group information:</p><pre class="screen">passwd: files
group:  files</pre><p>By leaving out the <code class="computeroutput">db</code> option,
    we are telling the Cygwin DLL not to even try to do AD lookups. If
    your AD servers are slow, this local cache will speed things up. The
    downside is that you open yourself up to the <a class="ulink" href="http://en.wikipedia.org/wiki/Cache_(computing)" target="_top">stale cache
    problem</a>: any time the AD databases change, your local cache
    will go out of date until you update the files manually.</p></li></ol></div><p>If none of the above helps, the best troubleshooting method is to
run your startup scripts in debug mode. Right-click your Cygwin Terminal
icon, go to Properties, and edit the command. It should be something
like <span class="command"><strong>C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico
-</strong></span>.  Assuming you are using Bash for your login shell, change
it to <span class="command"><strong>C:\cygwin\bin\mintty /bin/bash -lx</strong></span> then try
running Cygwin Terminal again. The <code class="option">-x</code> option tells Bash
to write every command it runs to the terminal before launching it. If
the terminal immediately starts filling with lines of text but then
pauses, the line where the output paused is your clue as to what's going
on. The Cygwin DLL proper probably isn't the cause of the slowdown in
this case, since those delays happen before the first line of text
appears in the terminal.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.slow"></a><p><b>4.3.</b></p></td><td align="left" valign="top"><p>Why is Cygwin suddenly <span class="emphasis"><em>so</em></span> slow?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If suddenly <span class="emphasis"><em>every</em></span> command takes a
<span class="emphasis"><em>very</em></span> long time, then something is probably attempting to 
access a network share.  You may have the obsolete <code class="literal">//c</code>
notation in your PATH or startup files.  Using <code class="literal">//c</code> means
to contact the <span class="emphasis"><em>network server</em></span> <code class="literal">c</code>, which
will slow things down tremendously if it does not exist.  
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.shares"></a><p><b>4.4.</b></p></td><td align="left" valign="top"><p>Why can't my services access network shares?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If your service is one of those which switch the user context
(cygsshd, inetd, etc), then it depends on the method used to switch to
another user.  This problem as well as its solution is described in
detail in the Cygwin User's Guide, see
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/ntsec.html" target="_top">https://cygwin.com/cygwin-ug-net/ntsec.html</a>.
</p><p>Workarounds include using public network share that does not require
authentication (for non-critical files), providing your password to a
<span class="command"><strong>net use</strong></span> command, or running the service as your own
user with <code class="literal">cygrunsrv -u</code> (see
<code class="literal">/usr/share/doc/Cygwin/cygrunsrv.README</code> for more
information).
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.path"></a><p><b>4.5.</b></p></td><td align="left" valign="top"><p>How should I set my PATH?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>This is done for you in the file /etc/profile, which is sourced by bash
when you start it from the Desktop or Start Menu shortcut, created by
the Cygwin Setup program. The line is
</p><pre class="screen">
	PATH="/usr/local/bin:/usr/bin:/bin:$PATH"
</pre><p>Effectively, this <span class="bold"><strong>prepends</strong></span> /usr/local/bin and /usr/bin to your
Windows system path.  If you choose to reset your PATH, say in
$HOME/.bashrc, or by editing etc/profile directly, then you should
follow this rule.  You <span class="bold"><strong>must</strong></span> have <code class="literal">/usr/bin</code> in your PATH
<span class="bold"><strong>before</strong></span> any Windows system directories.  (And you must not omit
the Windows system directories!)  Otherwise you will likely encounter
all sorts of problems running Cygwin applications.
</p><p>If you're using another shell than bash (say, tcsh), the mechanism
is the same, just the names of the login scripts are different.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.not-found"></a><p><b>4.6.</b></p></td><td align="left" valign="top"><p>Bash (or another shell) says "command not found", but it's right there!</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you compile a program, you might find that you can't run it:
</p><pre class="screen">
	bash$ gcc -o hello hello.c
        bash$ hello
        bash: hello: command not found
</pre><p>Unlike the Windows default behaviour, Unix shells like bash do not look for programs in <code class="literal">.</code> (the current
directory) by default.  You can add <code class="literal">.</code> to your PATH (see above),
but this is not recommended (at least on UNIX) for security reasons.
Just tell bash where to find it, when you type it on the command line:
</p><pre class="screen">
	bash$ gcc -o hello hello.c
        bash$ ./hello
        Hello World!
</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.converting-paths"></a><p><b>4.7.</b></p></td><td align="left" valign="top"><p>How do I convert between Windows and UNIX paths?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Use the 'cygpath' utility.  Type '<code class="literal">cygpath --help</code>' for
information.  For example (on my installation):
</p><pre class="screen">
	bash$ cygpath --windows ~/.bashrc
        D:\starksb\.bashrc
        bash$ cygpath --unix C:/cygwin/bin/ls.exe
        /usr/bin/ls.exe
        bash$ cygpath --unix C:\\cygwin\\bin\\ls.exe
        /usr/bin/ls.exe
</pre><p>
Note that bash interprets the backslash '\' as an escape character, so
you must type it twice in the bash shell if you want it to be recognized
as such.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.bashrc"></a><p><b>4.8.</b></p></td><td align="left" valign="top"><p>Why doesn't bash read my .bashrc file on startup?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Your .bashrc is read from your home directory specified by the HOME
environment variable.  It uses /.bashrc if HOME is not set.  So you need
to set HOME (and the home dir in your passwd account information) correctly.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.bash-insensitive"></a><p><b>4.9.</b></p></td><td align="left" valign="top"><p>How can I get bash filename completion to be case insensitive?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Add the following to your <code class="literal">~/.bashrc</code> file:
</p><pre class="screen">
	shopt -s nocaseglob
</pre><p>and add the following to your <code class="literal">~/.inputrc</code> file:
</p><pre class="screen">
	set completion-ignore-case on
</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.filename-spaces"></a><p><b>4.10.</b></p></td><td align="left" valign="top"><p>Can I use paths/filenames containing spaces in them?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin does support spaces in filenames and paths.  That said, some
utilities that use the library may not, since files don't typically
contain spaces in Unix.  If you stumble into problems with this, you
will need to either fix the utilities or stop using spaces in filenames
used by Cygwin tools.
</p><p>In particular, bash interprets space as a word separator.  You would have
to quote a filename containing spaces, or escape the space character.
For example:
</p><pre class="screen">
	bash-2.03$ cd '/cygdrive/c/Program Files'
</pre><p>
or
</p><pre class="screen">
	bash-2.03$ cd /cygdrive/c/Program\ Files
</pre><p>
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.shortcuts"></a><p><b>4.11.</b></p></td><td align="left" valign="top"><p>Why can't I cd into a shortcut to a directory?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin does not follow MS Windows Explorer Shortcuts
(*.lnk files).  It sees a shortcut as a regular file and this you
cannot "cd" into it.
</p><p>Cygwin is also capable to create POSIX symlinks as Windows shortcuts 
(see the CYGWIN environment variable option "winsymlinks"), but these
shortcuts are different from shortcuts created by native Windows
applications.  Windows applications can usually make use of Cygwin
shortcuts but not vice versa.  This is by choice.  The reason is that
Windows shortcuts may contain a bunch of extra information which would
get lost, if, for example, Cygwin tar archives and extracts them as
symlinks.
</p><p>Changing a Cygwin shortcut in Windows Explorer usually changes a Cygwin
shortcut into a Windows native shortcut.  Afterwards, Cygwin will not
recognize it as symlink anymore.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.find"></a><p><b>4.12.</b></p></td><td align="left" valign="top"><p>I'm having basic problems with find.  Why?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Make sure you are using the find that came with Cygwin and that you
aren't picking up the Win32 find command instead.  You can verify that
you are getting the right one by doing a "type find" in bash.
</p><p>If the path argument to find, including current directory (default), is
itself a symbolic link, then find will not traverse it unless you
specify the <code class="literal">-follow</code> option.  This behavior is different than most
other UNIX implementations, but is not likely to change.
</p><p>If find does not seem to be producing enough results, or seems to be
missing out some directories, you may be experiencing a problem with one
of find's optimisations.  The absence of <code class="literal">.</code> and <code class="literal">..</code>
directories on some filesystems, such as DVD-R UDF, can confuse find.
See the documentation for the option <code class="literal">-noleaf</code> in the man page.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.su"></a><p><b>4.13.</b></p></td><td align="left" valign="top"><p>Why doesn't <code class="literal">su</code> work?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The <code class="literal">su</code> command has been in and out of Cygwin distributions, but
it has not been ported to Cygwin and has never worked.  It is
currently installed as part of the sh-utils, but again, it does not work.
</p><p>You should rather install <code class="literal">sshd</code> as a service
(the service will be called <code class="literal">cygsshd</code> so as not to
collide with the Microsoft <code class="literal">sshd</code> service) and use
<code class="literal">ssh username@localhost</code> as a <code class="literal">su</code>
replacement.
</p><p>For some technical background into why <code class="literal">su</code> doesn't
work, read
<a class="ulink" href="https://www.cygwin.com/ml/cygwin/2003-06/msg00897.html" target="_top">https://www.cygwin.com/ml/cygwin/2003-06/msg00897.html</a> and
related messages.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.man"></a><p><b>4.14.</b></p></td><td align="left" valign="top"><p>Why doesn't <code class="literal">man -k</code>,
<code class="literal">apropos</code> or <code class="literal">whatis</code> work?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Before you can use <code class="literal">man -k</code>, <code class="literal">apropos</code>
or <code class="literal">whatis</code>, you
must create the whatis database.  Just run the command
</p><pre class="screen">
	mandb
</pre><p>(it may take a few minutes to complete).
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.chmod"></a><p><b>4.15.</b></p></td><td align="left" valign="top"><p>Why doesn't <code class="literal">chmod</code> work?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you're using FAT32 instead of NTFS, <code class="literal">chmod</code> 
will fail since FAT32 does not provide any permission information.
You should really consider converting the drive to NTFS with
<code class="literal">CONVERT.EXE</code>.  FAT and FAT32 are barely good enough
for memory cards or USB sticks to exchange pictures...
</p><p>For other cases, understand that Cygwin attempts to show UNIX 
permissions based on the security features of Windows, so the Windows 
ACLs are likely the source of your problem.  See the Cygwin User's 
Guide at <a class="ulink" href="https://cygwin.com/cygwin-ug-net/ntsec.html" target="_top">https://cygwin.com/cygwin-ug-net/ntsec.html</a>
for more information on how Cygwin maps Windows permissions.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.shell-scripts"></a><p><b>4.16.</b></p></td><td align="left" valign="top"><p>Why doesn't my shell script work?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>There are two basic problems you might run into.  One is the fact that
<span class="command"><strong>/bin/sh</strong></span> is really <span class="command"><strong>bash</strong></span>.
It could be missing some features you might expect in
<span class="command"><strong>/bin/sh</strong></span>, if you are used to <span class="command"><strong>/bin/sh</strong></span>
actually being <span class="command"><strong>zsh</strong></span> (MacOS X "Panther") or
<span class="command"><strong>ksh</strong></span> (Tru64).  
</p><p>Or, it could be a permission problem, and Cygwin doesn't understand
that your script is executable.  On NTFS or NFS just make the script
executable using <code class="literal">chmod +x</code>.  However,
<code class="literal">chmod</code> may not work due to restrictions of the
filesystem (see FAQ entry above).  In this case Cygwin must read the
contents of files to determine if they are executable.  If your script
does not start with
</p><pre class="screen">
	#! /bin/sh
</pre><p>(or any path to a script interpreter, it does not have to be /bin/sh)
then Cygwin will not know it is an executable script.  The Bourne shell
idiom
</p><pre class="screen">
	:
	# This is the 2nd line, assume processing by /bin/sh
</pre><p>also works.
</p><p>Note that you can use the filesystem flag <code class="literal">cygexec</code> in
<code class="filename">/etc/fstab</code> to force Cygwin to treat all files
under the mount point as executable.  This can be used for individual
files as well as directories.  Then Cygwin will not bother to read files
to determine whether they are executable.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.printing"></a><p><b>4.17.</b></p></td><td align="left" valign="top"><p>How do I print under Cygwin?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>lpr is available in the cygutils package.  Some <a class="ulink" href="https://cygwin.com/ml/cygwin/2008-05/msg00123.html" target="_top">usage hints</a> are available courtesy of Rodrigo Medina.
</p><p>Jason Tishler has written a couple of messages that explain how to use
a2ps (for nicely formatted text in PostScript) and ghostscript (to print
PostScript files on non-PostScript Windows printers).  Start at
<a class="ulink" href="https://cygwin.com/ml/cygwin/2001-04/msg00657.html" target="_top">https://cygwin.com/ml/cygwin/2001-04/msg00657.html</a>.  Note that
these are old mails and <span class="command"><strong>a2ps</strong></span> as well as
<span class="command"><strong>file</strong></span> are long available as part of the Cygwin distribution.
</p><p>Alternatively, you can use the Windows <span class="command"><strong>print</strong></span>
command.  Type
</p><pre class="screen">
	bash$ print /\?
</pre><p>for usage instructions (note the <code class="literal">?</code> must be escaped
from the shell).
</p><p>Finally, you can simply <span class="command"><strong>cat</strong></span> the file to the printer's share name:
</p><pre class="screen">
	bash$ cat myfile &gt; //host/printer
</pre><p>You may need to press the formfeed button on your printer or append the
formfeed character to your file.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.unicode"></a><p><b>4.18.</b></p></td><td align="left" valign="top"><p>Why don't international (Unicode) characters work?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Internationalization is a complex issue. The short answer is that
Cygwin relies on the setting of the setting of LANG/LC_xxx environment
variables. The long answer can be found in the User's Guide in the
section <a class="ulink" href="https://cygwin.com/cygwin-ug-net/setup-locale.html" target="_top">Internationalization</a>
</p><p> Cygwin uses UTF-8 by default.  To use a different character set, you
need to set the LC_ALL, LC_CTYPE or LANG environment variables.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.weirdchars"></a><p><b>4.19.</b></p></td><td align="left" valign="top"><p>My application prints international characters but I only
see gray boxes</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>In the case of Cygwin programs, this likely means that the
character set as determined by the LC_ALL, LC_CTYPE or LANG environment
variables does not match the one set on the Text page of the Cygwin Terminal's
options.  Setting the locale in the terminal's options will set the LANG
variable accordingly.</p><p>Non-Cygwin programs in the Cygwin Terminal do not usually take
heed of the locale environment variables.  Instead, they often use the
so-called console codepage, which can be determined with the command
<span class="command"><strong>cmd /c chcp</strong></span> followed by the appropriate Windows
codepage number.  The codepage number for Cygwin's default UTF-8 character
set is 65001.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.multiple-copies"></a><p><b>4.20.</b></p></td><td align="left" valign="top"><p>Is it OK to have multiple copies of the DLL?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes, as long as they are used in strictly separated installations.</p><p>The Cygwin DLL has to handle various sharing situations between
multiple processes.  It has to keep a process table.  It has to maintain
a mount table which is based on the installation path of the Cygwin DLL.</p><p>For that reason, the Cygwin DLL maintains shared resources based on
a hash value created from its own installation path.  Each Cygwin DLL
on the machine constitutes a Cygwin installation, with the directory
the Cygwin DLL resides in treated as "/bin", the parent directory as "/".
</p><p>Therefore, you can install two or more separate Cygwin distros on
a single machine.  Each of these installations use their own Cygwin DLL,
and they don't share the default POSIX paths, nor process tables, nor
any other shared resource used to maintain the installation.</p><p>However, a clean separation requires that you don't try to run
executables of one Cygwin installation from processes running in another
Cygwin installation.  This may or may not work, but the chances that the
result is not what you expect are pretty high.</p><p>If you get the error "shared region is corrupted" or "shared region
version mismatch" it means you have multiple versions of cygwin1.dll
running at the same time which conflict with each other.  Apart from
mixing executables of different Cygwin installations, this could also happen
if you have one a single Cygwin installation, for example, if you update the
Cygwin package without exiting <span class="emphasis"><em>all</em></span> Cygwin apps (including
services like cygsshd) beforehand.</p><p>The only DLL that is sanctioned by the Cygwin project is the one that
you get by running the <a class="ulink" href="https://cygwin.com/install.html" target="_top">Cygwin Setup program</a>,
installed in a directory controlled by this program.  If you have other
versions on your system and desire help from the cygwin project, you should
delete or rename all DLLs that are not installed by
the Cygwin Setup program.
</p><p>If you're trying to find multiple versions of the DLL that are causing
this problem, reboot first, in case DLLs still loaded in memory are the
cause.  Then use the Windows System find utility to search your whole
machine, not just components in your PATH (as 'type' would do) or
cygwin-mounted filesystems (as Cygwin 'find' would do).
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.third-party.multiple-copies"></a><p><b>4.21.</b></p></td><td align="left" valign="top"><p>
I read the above but I want to bundle Cygwin with a product, and ship it
to customer sites.  How can I do this without conflicting with any Cygwin
installed by the user?
</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
Usually, if you keep your installation separate, nothing bad should happen.
However, for the user's convenience, and to avoid potential problems which
still can occur, consider to integrate your product with an already existing
Cygwin installation on the user's machine, or, if there is none, consider
to install the official Cygwin distro on behalf of the user and integrate
your tools from there.  (If you write a tool to make this easy, consider
contributing it for others to use)
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.bundling-cygwin"></a><p><b>4.22.</b></p></td><td align="left" valign="top"><p>
Can I bundle Cygwin with my product for free?
</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
Starting with Cygwin version 2.5.2, which is LGPL licensed, yes, albeit
it's not recommended for interoperability reasons.</p><p>Cygwin versions prior to 2.5.2 were GPL licensed.
If you choose to distribute an older cygwin1.dll, you must be willing to
distribute the exact source code used to build that copy of cygwin1.dll
as per the terms of the GPL.  If you ship applications that link with
older cygwin1.dll, you must provide those applications' source code
under a GPL-compatible license.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.older-cygwin-conflict"></a><p><b>4.23.</b></p></td><td align="left" valign="top"><p>
But doesn't that mean that if some application installs an older Cygwin
DLL on top of a newer DLL, my application will break?
</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
It depends on what you mean by "break".  If the application installs a
version of the Cygwin DLL in another location than Cygwin's /bin
directory then the rules in
<a class="xref" href="faq.html#faq.using.third-party.multiple-copies" title="4.21.">Q: 4.21</a> apply. 
If the application installs an older version of the DLL in /bin then you
should complain loudly to the application provider.
</p><p>
Remember that the Cygwin DLL strives to be backwards compatible so a
newer version of the DLL should always work with older executables.  So,
in general, it is always best to keep one version of the DLL on your
system and it should always be the latest version which matches your
installed distribution.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.missing-packages"></a><p><b>4.24.</b></p></td><td align="left" valign="top"><p>Why isn't package XYZ available in Cygwin?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Probably because there is nobody willing or able to maintain it.  It
takes time, and the priority for the Cygwin Team is the Cygwin package.
The rest is a volunteer effort.  Want to contribute?  See
<a class="ulink" href="https://cygwin.com/packaging.html" target="_top">https://cygwin.com/packaging.html</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.old-packages"></a><p><b>4.25.</b></p></td><td align="left" valign="top"><p>Why is the Cygwin package of XYZ so out of date?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>(Also: Why is the version of package XYZ older than the version that I
can download from the XYZ web site?  Why is the version of package XYZ
older than the version that I installed on my linux system?  Is there
something special about Cygwin which requires that only an older version
of package XYZ will work on it?)
</p><p>Every package in the Cygwin distribution has a maintainer who is
responsible for sending out updates of the package.  This person is a
volunteer who is rarely the same person as the official developer of the
package.  If you notice that a version of a package seems to be out of
date, the reason is usually pretty simple -- the person who is
maintaining the package hasn't gotten around to updating it yet. Rarely,
the newer package actually requires complex changes that the maintainer
is working out. 
</p><p>If you urgently need an update, sending a polite message to the cygwin
mailing list pinging the maintainer is perfectly acceptable.  There are
no guarantees that the maintainer will have time to update the package
or that you'll receive a response to your request, however.
</p><p>Remember that the operative term here is "volunteer".
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.accessing-drives"></a><p><b>4.26.</b></p></td><td align="left" valign="top"><p>How can I access other drives?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>You have some flexibility here.
</p><p>Cygwin has a builtin "cygdrive prefix" for drives that are not mounted.
You can access any drive, say Z:, as '/cygdrive/z/'.
</p><p>In some applications (notably bash), you can use the familiar windows
&lt;drive&gt;:/path/, using posix forward-slashes ('/') instead of Windows
backward-slashes ('\').  (But see the warning below!)  This maps in the
obvious way to the Windows path, but will be converted internally to use
the Cygwin path, following mounts (default or explicit).  For example:
</p><pre class="screen">
	bash$ cd C:/Windows
	bash$ pwd
        /cygdrive/c/Windows
</pre><p>
and
</p><pre class="screen">
	bash$ cd C:/cygwin
	bash$ pwd
        /
</pre><p>
for a default setup.  You could also use backward-slashes in the
Windows path, but these would have to be escaped from the shell.
</p><p><span class="bold"><strong>Warning:</strong></span> There is some ambiguity in going from a Windows path
to the posix path, because different posix paths, through different
mount points, could map to the same Windows directory.  This matters
because different mount points may be binmode or textmode, so the
behavior of Cygwin apps will vary depending on the posix path used to
get there.
</p><p>You can avoid the ambiguity of Windows paths, and avoid typing
"/cygdrive", by explicitly mounting drives to posix paths.  For example:
</p><pre class="screen">
	bash$ mkdir /c
	bash$ mount c:/ /c
	bash$ ls /c
</pre><p>
Then <code class="literal">/cygdrive/c/Windows</code> becomes <code class="literal">/c/Windows</code> which is a
little less typing.
</p><p>Note that you have to enter the mount point into the
<code class="filename">/etc/fstab</code> file to keep it indefinitely. 
The mount command will only add the mount point for the lifetime
of your current Cygwin session.
</p><p>You can change the default <code class="literal">cygdrive</code> prefix and whether it is binmode or textmode using the <code class="filename">/etc/fstab</code> file
as well.  See the Cygwin User's Guide at
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/using.html#mount-table" target="_top">https://cygwin.com/cygwin-ug-net/using.html#mount-table</a>
for more details.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.copy-and-paste"></a><p><b>4.27.</b></p></td><td align="left" valign="top"><p>How can I copy and paste into Cygwin console windows?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>First, consider using mintty instead of the standard console
window.  In mintty, selecting with the left-mouse also copies,
and middle-mouse pastes.  It couldn't be easier!
</p><p>In Windows's console window, open the properties dialog.
The options contain a toggle button, named "Quick edit mode".  It must
be ON.  Save the properties.
</p><p>You can also bind the insert key to paste from the clipboard by adding 
the following line to your .inputrc file: 
</p><pre class="screen">
	"\e[2~": paste-from-clipboard 
</pre><p>
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.firewall"></a><p><b>4.28.</b></p></td><td align="left" valign="top"><p>What firewall should I use with Cygwin? </p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>We have had good reports about Kerio Personal Firewall, ZoneLabs
Integrity Desktop, and the Windows built-in firewall. Other well-known
products including ZoneAlarm and Norton Internet Security have caused
problems for some users but work fine for others. At last report,
Agnitum Outpost did not work with Cygwin.  If you are having strange
connection-related problems, disabling the firewall is a good
troubleshooting step (as is closing or disabling all other running
applications, especially resource-intensive processes such as indexed
search).
</p><p>On the whole, Cygwin doesn't care which firewall is used.  The few rare
exceptions have to do with socket code.
Cygwin uses sockets to implement many of its functions, such as IPC.
Some overzealous firewalls install themselves deeply into the winsock
stack (with the 'layered service provider' API) and install hooks
throughout.  Sadly the mailing list archives are littered with examples
of poorly written firewall-type software that causes things to break.
Note that with many of these products, simply disabling the firewall
does not remove these changes; it must be completely uninstalled.
</p><p>See also <a class="xref" href="faq.html#faq.using.bloda" title="4.44.">BLODA</a>
for a list of applications that have been known, at one time or another, to 
interfere with the normal functioning of Cygwin.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.sharing-files"></a><p><b>4.29.</b></p></td><td align="left" valign="top"><p>How can I share files between Unix and Windows?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>During development, we have Linux boxes running Samba and NFS as well
as Windows machines.  We often build with cross-compilers under Linux and copy
binaries and source to the Windows system or just toy with them
directly off the Samba-mounted partition.  Or, we use the Microsoft NFS
client and just use NFS shares on Linux from Windows.  And then there are
tools like <code class="literal">scp</code>, <code class="literal">ftp</code>,
<code class="literal">rsync</code>, ...
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.case-sensitive"></a><p><b>4.30.</b></p></td><td align="left" valign="top"><p>Is Cygwin case-sensitive??</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Several Unix programs expect to be able to use to filenames
spelled the same way, but with different case.  A prime example
of this is perl's configuration script, which wants
<code class="literal">Makefile</code> and <code class="literal">makefile</code>.  Windows can't
tell the difference between files with just different case, so the
configuration fails.
</p><p>To help with this problem, Cygwin supports case sensitivity.  For a
detailed description how to use that feature see the Cygwin User's Guide at
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/using-specialnames.html" target="_top">https://cygwin.com/cygwin-ug-net/using-specialnames.html</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.dos-filenames"></a><p><b>4.31.</b></p></td><td align="left" valign="top"><p>What about DOS special filenames?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>In Windows, files cannot be named com1, lpt1, or aux (to name a few);
either as the root filename or as the extension part.  If you do, you'll have
trouble.  Unix programs don't avoid these names which can make things
interesting.  E.g., the perl distribution has a file called
<code class="literal">aux.sh</code>.  The perl configuration tries to make sure that
<code class="literal">aux.sh</code> is there, but an operation on a file with the magic
letters 'aux' in it will hang.
</p><p>At least that's what happens when using native Windows tools.  Cygwin
can deal with these filenames just fine.  Again, see the User's Guide at
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/using-specialnames.html" target="_top">https://cygwin.com/cygwin-ug-net/using-specialnames.html</a>
for a detailed description of what's possible with filenames and what is not.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.sparse-files"></a><p><b>4.32.</b></p></td><td align="left" valign="top"><p>Does Cygwin support sparse files?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Filesystems of Unix-like operating systems traditionally provide
automatic support for sparse files: no disk blocks are allocated for file
regions which are not explicitly written.  The Windows NTFS filesystem
supports sparse files, but requires to enable it for individual files via
<code class="literal">FILE_ATTRIBUTE_SPARSE_FILE</code>.  If the mount option
<code class="literal">sparse</code> is used or the mount point is on a solid state
device, Cygwin heuristically detects skipped file regions and sets this
attribute then.  Independent of mount option or SSD, sparse files may also
be created if an application uses the related POSIX functionality
(<code class="literal">FALLOC_FL_PUNCH_HOLE</code>) as the <code class="literal">cp</code>
command does if <code class="literal">--sparse=always</code> is specified.  In some use
cases requiring only a single sparse file, for example creating disk images
with <code class="literal">dd</code> or <code class="literal">ddrescue</code>, it is also
possible to preset the sparse attribute with <code class="literal">chattr</code>.
</p><p>Example (<code class="literal">sparse</code> not set, no SSD):
</p><pre class="screen">
	$ mkdir 0
	$ &gt; 0/is_sparse
	$ chattr +S 0/is_sparse
	$ dd if=/dev/zero bs=1M count=1 of=0/is_sparse conv=sparse,notrunc
	$ echo EOF &gt;&gt; 0/is_sparse
	$ dd if=/dev/zero bs=1M count=1 of=0/maybe_sparse conv=sparse
	$ echo EOF &gt;&gt; 0/maybe_sparse
	$ dd if=/dev/zero bs=1M count=1 of=0/not_sparse
	$ echo EOF &gt;&gt; 0/not_sparse
	$ cp -a 0 1
	$ cp -a --sparse=always 0 2
	$ ls -hls ?/*
	 64K -rw-r--r-- 1 user group 1.1M Feb 22 12:42 0/is_sparse
	1.1M -rw-r--r-- 1 user group 1.1M Feb 22 12:42 0/maybe_sparse
	1.1M -rw-r--r-- 1 user group 1.1M Feb 22 12:42 0/not_sparse
	1.1M -rw-r--r-- 1 user group 1.1M Feb 22 12:42 1/is_sparse
	1.1M -rw-r--r-- 1 user group 1.1M Feb 22 12:42 1/maybe_sparse
	1.1M -rw-r--r-- 1 user group 1.1M Feb 22 12:42 1/not_sparse
	 64K -rw-r--r-- 1 user group 1.1M Feb 22 12:42 2/is_sparse
	 64K -rw-r--r-- 1 user group 1.1M Feb 22 12:42 2/maybe_sparse
	 64K -rw-r--r-- 1 user group 1.1M Feb 22 12:42 2/not_sparse
	$ lsattr ?/*
	---a-S-------- 0/is_sparse
	---a---------- 0/maybe_sparse
	---a---------- 0/not_sparse
	---a---------- 1/is_sparse
	---a---------- 1/maybe_sparse
	---a---------- 1/not_sparse
	---a-S-------- 2/is_sparse
	---a-S-------- 2/maybe_sparse
	---a-S-------- 2/not_sparse
	$ lssparse -H 0/is_sparse # from cygutils-extra package
	Hole range[1]: offset=0x0,      length=0x100000
	Data range[2]: offset=0x100000, length=0x4
	$ lssparse -H 0/not_sparse
	Data range[1]: offset=0x0,      length=0x100004
</pre><p>With <code class="literal">sparse</code> mount option or a SSD, all
<code class="literal">?/maybe_sparse</code> files would be sparse.
</p><p>Note that the detection of solid state devices may be false negative in
various configurations, for example RAID volumes, USB flash drives, very old
SATA SSDs, or SSDs behind USB docking stations.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.hangs"></a><p><b>4.33.</b></p></td><td align="left" valign="top"><p>When it hangs, how do I get it back?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If something goes wrong and the tools hang on you for some reason (easy
to do if you try and read a file called aux.sh), first try hitting ^C to
return to bash or the cmd prompt.
</p><p>If you start up another shell, and applications don't run, it's a good
bet that the hung process is still running somewhere.  Use the Task
Manager, pview, or a similar utility to kill the process.
</p><p>And, if all else fails, there's always the reset button/power switch.
In theory this should never be necessary, though.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.directory-structure"></a><p><b>4.34.</b></p></td><td align="left" valign="top"><p>Why the weird directory structure?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Why do /lib and /usr/lib (and /bin, /usr/bin) point to the same thing?
</p><p>Why use mounts instead of symbolic links?
</p><p>Can I use a disk root (e.g., C:\) as Cygwin root?  Why is this discouraged?
</p><p>After a new installation in the default location, your mount points will
look something like this:
</p><pre class="screen">
	bash$ mount
	C:\cygwin\bin on /usr/bin type ntfs (binary,auto)
	C:\cygwin\lib on /usr/lib type ntfs (binary,auto)
	C:\cygwin on / type ntfs (binary,auto)
	C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
</pre><p>Note that /bin and /usr/bin point to the same location, as do /lib and
/usr/lib.  This is intentional, and you should not undo these mounts
unless you <span class="emphasis"><em>really</em></span> know what you are doing.
</p><p>Various applications and packages may expect to be installed in /lib or
/usr/lib (similarly /bin or /usr/bin).  Rather than distinguish between
them and try to keep track of them (possibly requiring the occasional
duplication or symbolic link), it was decided to maintain only one
actual directory, with equivalent ways to access it.
</p><p>Symbolic links had been considered for this purpose, but were dismissed
because they do not always work on Samba drives.  Also, mounts are
faster to process because no disk access is required to resolve them.
</p><p>Note that non-cygwin applications will not observe Cygwin mounts (or
most symlinks for that matter).  For example, if you use WinZip to unpack the
tar distribution of a Cygwin package, it may not get installed to the
correct Cygwin path.  <span class="emphasis"><em>So don't do this!</em></span>
</p><p>It is strongly recommended not to make the Cygwin root directory the
same as your drive's root directory, unless you know what you are doing
and are prepared to deal with the consequences.  It is generally easier
to maintain the Cygwin hierarchy if it is isolated from, say, C:\.  For
one thing, you avoid possible collisions with other (non-cygwin)
applications that may create (for example) \bin and \lib directories.
(Maybe you have nothing like that installed now, but who knows about
things you might add in the future?)
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.anti-virus"></a><p><b>4.35.</b></p></td><td align="left" valign="top"><p>How do anti-virus programs like Cygwin?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Users have reported that NAI (formerly McAfee) VirusScan for NT (and
others?) is incompatible with Cygwin.  This is because it tries to scan
the newly loaded shared memory in cygwin1.dll, which can cause fork() to
fail, wreaking havoc on many of the tools.  (It is not confirmed that
this is still a problem, however.)
</p><p>There have been several reports of NAI VirusScan causing the system to
hang when unpacking tar.gz archives.  This is surely a bug in VirusScan,
and should be reported to NAI.  The only workaround is to disable
VirusScan when accessing these files.  This can be an issue during
Setup, and is discussed in that FAQ entry.
</p><p>Some users report a significant performance hit using Cygwin when their
anti-virus software is enabled.  Rather than disable the anti-virus
software completely, it may be possible to specify directories whose
contents are exempt from scanning.  In a default installation, this
would be <code class="literal">C:\cygwin\bin</code>.  Obviously, this could be
exploited by a hostile non-Cygwin program, so do this at your own risk.
</p><p>Anti-virus software typically reduce the speed of Windows
<code class="literal">CreateProcess</code> calls which are used by Cygwin to provide
<code class="literal">fork()</code> and <code class="literal">exec()</code>.  This in particular
slows down shell scripts.  In the simple speed test shown below, the first
column shows the number of <code class="literal">date</code> commands run per second.
Anti-virus was turned off at the line marked with <code class="literal">***</code>.
</p><pre class="screen">
	bash$ while :; do date +%s; done | uniq -c
	...
	122 1741712430
	118 1741712431
	118 1741712432
	121 1741712433
	142 1741712434  ***
	140 1741712435
	141 1741712436
	144 1741712437
	...
</pre><p>See also <a class="xref" href="faq.html#faq.using.bloda" title="4.44.">BLODA</a>
for a list of applications that have been known, at one time or another, to
interfere with the normal functioning of Cygwin.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.emacs"></a><p><b>4.36.</b></p></td><td align="left" valign="top"><p>Is there a Cygwin port of GNU Emacs?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes.  Install the emacs package.  This provides everything you
need in order to run GNU emacs in a terminal window.  If you also want
to be able to use the X11
(<a class="ulink" href="https://x.cygwin.com/" target="_top">https://x.cygwin.com/</a>)
GUI, install the emacs-X11 package.  In either case, you run emacs by
typing 'emacs' or '/usr/bin/emacs'.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.xemacs"></a><p><b>4.37.</b></p></td><td align="left" valign="top"><p>Is there a Cygwin port of XEmacs?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes.  It can be used in three different modes:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>X11 (<a class="ulink" href="https://x.cygwin.com/" target="_top">https://x.cygwin.com/</a>) GUI</p></li></ul></div><p>You have to <span class="emphasis"><em>set</em></span> the DISPLAY environment variable
before starting xemacs.</p><pre class="screen">
	bash$ DISPLAY=127.0.0.1:0 xemacs &amp;
</pre><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Windows native GUI</p></li></ul></div><p>You have to <span class="emphasis"><em>unset</em></span> the DISPLAY environment variable
before starting xemacs.</p><pre class="screen">
	bash$ DISPLAY= xemacs &amp;
</pre><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Console mode</p></li></ul></div><p>Start xemacs with -nw in a terminal (native or X11) window</p><pre class="screen">
	bash$ xemacs -nw
</pre><p>To use all the standard packages with XEmacs you should download the following
two packages:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>xemacs-sumo - XEmacs standard packages</p></li><li class="listitem"><p>xemacs-mule-sumo - XEmacs MULE (MUlti Lingual Emacs) packages</p></li></ul></div></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.symlinkstoppedworking"></a><p><b>4.38.</b></p></td><td align="left" valign="top"><p>Why don't some of my old symlinks work anymore?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin supports multiple character sets.  Symlinks created with Cygwin
are using the UTF-16 character set, which is portable across all character
sets.  Old symlinks were written using your current Windows codepage, which
is not portable across all character sets.  If the target of the symlink
doesn't resolve anymore, it's very likely that the symlink points to a target
filename using native, non-ASCII characters, and you're now using another
character set than way back when you created the symlink.</p><p>Solution: Delete the symlink and create it again under you new Cygwin.
The new symlink will be correctly point to the target no matter what character
set you're using in future.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.symlinks-samba"></a><p><b>4.39.</b></p></td><td align="left" valign="top"><p>Why don't symlinks work on Samba-mounted filesystems?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Default symlinks on Samba are marked with DOS SYSTEM file
attribute.  Samba does not enable this attribute by default.  To enable
it, consult your Samba documentation and then add these lines to your
samba configuration file:
</p><pre class="screen">
	map system = yes
	create mask = 0775
</pre><p>Note that the 0775 can be anything as long as the 0010 bit is set.
</p><p>Alternatively, use Windows shortcuts as symlinks.  See the CYGWIN
environment variable option "winsymlinks:lnk"
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/using-cygwinenv.html" target="_top">https://cygwin.com/cygwin-ug-net/using-cygwinenv.html</a>
Note that Samba does not support reparse points so some methods to
create symlinks are just not available.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.ssh-pubkey-stops-working"></a><p><b>4.40.</b></p></td><td align="left" valign="top"><p>Why does public key authentication with ssh fail after updating to Cygwin 1.7.34 or later?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
This is the result of fixing a long-standing security problem in Cygwin's
POSIX ACL handling.  IEEE 1003.1e draft 17 defines that the permissions
of secondary user and group entries in an ACL are reflected in the group
permission mask by or'ing the permissions of the file's primary group with
all permissions of secondary users and groups in the ACL.  The background
is that this way the standard POSIX permission bits reflect the fact that
<span class="bold"><strong>somebody else</strong></span> has additional, otherwise
potentially invisible permissions on the file.  This relatively complex
interface has been defined in order to ensure that applications that are
compliant with IEEE 1003.1 (“POSIX.1”) will still function as expected on
systems with ACLs.</p><p>So, what does that mean for your situation?  Typically this means the
private key file, for instance <code class="filename">~/.ssh/id_rsa</code>, has too
open permissions.  OpenSSH expects the permissions of the private key file
to be 0600.  Let's use the default SSH2 RSA keyfile as example:</p><pre class="screen">
  $ ls -l .ssh/id_rsa
  -rw-------  1 user group 1766 Aug 26  2013 .ssh/id_rsa
</pre><p>However, if other accounts can read the file, the key is potentially
compromised.  Consider the file has additional rw- permissions for a group
<code class="literal">bad_guys</code>.  Up to Cygwin 1.7.33 that would have looked
like this:</p><pre class="screen">
  $ ls -l .ssh/id_rsa
  -rw-------+ 1 user group 1766 Aug 26  2013 .ssh/id_rsa
</pre><p>Notice the extra <span class="bold"><strong>+</strong></span> character following
the permission string.  This shows that additional ACL entries are in the ACL.
But an application only checking the POSIX permission bits (and ssh is one of
them!), will not notice the fact, because it gets the permissions 0600 for the
file.</p><p>Starting with Cygwin 1.7.34, the extra permissions are reflected in
the group permission bits per IEEE 1003.1e draft 17:</p><pre class="screen">
  $ ls -l .ssh/id_rsa
  -rw-rw----+ 1 user group 1766 Aug 26  2013 .ssh/id_rsa
</pre><p>So now ssh will notice that the file has extra permissions and it will
complain.  The same problem occurs if the file
<code class="filename">~/.ssh/authorized_keys</code> has too open permissions.  On
the client side you won't get any helping text, though, other than that you're
suddenly asked for a password.  That's a rather good hint to have a closer
look at the server's <code class="filename">~/.ssh/authorized_keys</code> file.</p><p>To fix the permissions of your private key file or your
<code class="filename">~/.ssh/authorized_keys</code> file, simply use the
<span class="command"><strong>setfacl</strong></span> command with the <code class="literal">-b</code> option. 
This removes all additional ACL entries and thus fixes the permissions to
be not too open:</p><pre class="screen">
  $ ls -l .ssh/id_rsa
  -rw-rw----+ 1 user group 1766 Aug 26  2013 .ssh/id_rsa
  $ setfacl -b .ssh/id_rsa
  $ ls -l .ssh/id_rsa
  -rw-------  1 user group 1766 Aug 26  2013 .ssh/id_rsa
</pre><p>If the second <span class="command"><strong>ls</strong></span> command still gives you
<code class="computeroutput">-rw-rw----</code> permissions after running
the above commands, it is proably because the file's primary group
is your user's personal group:</p><pre class="screen">
  $ ls -l .ssh/id_rsa
  -rw-rw----  1 Fred Fred 1766 Aug 26  2013 .ssh/id_rsa
</pre><p>Since the Windows security system treats groups and users as
much the same thing, a change to the user or group permissions on
such a file reflects the change to both user and group. In effect,
mode 0600 becomes mode 0660. Because we are saying we want these
files to be readable only by our user, the fix for this is easy:</p><pre class="screen">
  $ chgrp `id -g` ~/.ssh/*
</pre><p>That resets the group on these files to your default group
which should be something like <code class="computeroutput">Users</code>,
depending on your local configuration. If that doesn't work, you can
try something like this instead:</p><pre class="screen">
  $ chgrp None ~/.ssh/*
</pre><p>That group always exists, but its name is different on
non-English versions of Windows. You might also want to use a
domain group instead of a local group if your site uses Windows
domains. For example, you might want to use the <code class="computeroutput">Domain
Users</code> group instead.</p><p>For more information on <span class="command"><strong>setfacl</strong></span>, see
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/setfacl.html" target="_top">https://cygwin.com/cygwin-ug-net/setfacl.html</a></p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.same-with-rhosts"></a><p><b>4.41.</b></p></td><td align="left" valign="top"><p>Why is my .rhosts file not recognized by rlogin anymore after updating to Cygwin 1.7.34?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The problem is exactly the same as with the key files of SSH.  See
<a class="xref" href="faq.html#faq.using.ssh-pubkey-stops-working" title="4.40.">Q: 4.40</a>.</p><p>The solution is the same:</p><pre class="screen">
  $ ls -l .rhosts
  -rw-rw----+ 1 user group 42 Nov 12  2010 .rhosts
  $ setfacl -b .rhosts
  $ ls -l .rhosts
  -rw-------  1 user group 42 Nov 12  2010 .rhosts
</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.same-with-permissions"></a><p><b>4.42.</b></p></td><td align="left" valign="top"><p>Why do my files have extra permissions after updating to Cygwin 1.7.34?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The problem is exactly the same as with the key files of SSH.  See
<a class="xref" href="faq.html#faq.using.ssh-pubkey-stops-working" title="4.40.">Q: 4.40</a>.</p><p>The solution is the same:</p><pre class="screen">
  $ ls -l *
  -rw-rwxr--+ 1 user group 42 Nov 12  2010 file1
  -rw-rwxr--+ 1 user group 42 Nov 12  2010 file2
  $ setfacl -b *
  $ ls -l *
  -rw-r--r--  1 user group 42 Nov 12  2010 file1
  -rw-r--r--  1 user group 42 Nov 12  2010 file2
</pre><p>You may find that newly-created files also have unexpected
permissions:</p><pre class="screen">
  $ touch foo
  $ ls -l foo
  -rw-rwxr--+ 1 user group 42 Nov 12  2010 foo
</pre><p>This probably means that the directory in which you're creating
the files has unwanted default ACL entries that are inherited by
newly-created files and subdirectories.  The solution is again the
same:</p><pre class="screen">
  $ setfacl -b .
  $ touch bar
  $ ls -l bar
  -rw-r--r--  1 user group 42 Nov 12  2010 bar
</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.tcl-tk"></a><p><b>4.43.</b></p></td><td align="left" valign="top"><p>Why do my Tk programs not work anymore?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Previous versions of Tcl/Tk distributed with Cygwin (e.g. tclsh84.exe,
wish84.exe) were not actually "Cygwin versions" of those tools.
They were built as native libraries, which means they did not understand
Cygwin mounts or symbolic links. This lead to all sorts of problems interacting
with true Cygwin programs.</p><p>As of February 2012, this was replaced with a version of Tcl/Tk which
uses Cygwin's POSIX APIs and X11 for GUI functionality.  If you get a message
such as this when trying to start a Tk app:</p><pre class="screen">
  Application initialization failed: couldn't connect to display ""
</pre><p>Then you need to start an X server, or if one is already running, set the
<code class="literal">DISPLAY</code> variable to the proper value.  The Cygwin distribution
includes an X server; please see the <a class="ulink" href="https://x.cygwin.com/docs/ug/cygwin-x-ug.html" target="_top">Cygwin/X User Guide</a>
for installation and startup instructions.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.bloda"></a><p><b>4.44.</b></p></td><td align="left" valign="top"><p>What applications have been found to interfere with Cygwin?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>From time to time, people have reported strange failures and problems in
Cygwin and Cygwin packages that seem to have no rational explanation.  Among
the most common symptoms they report are fork failures, memory leaks, and file
access denied problems.  These problems, when they have been traced, often appear
to be caused by interference from other software installed on the same PC.  Security
software, in particular, such as anti-virus, anti-spyware, and firewall applications,
often implements its functions by installing hooks into various parts of the system,
including both the Explorer shell and the underlying kernel.  Sometimes these hooks
are not implemented in an entirely transparent fashion, and cause changes in the
behaviour which affect the operation of other programs, such as Cygwin.
</p><p>Among the software that has been found to cause difficulties are:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>AR Soft RAM Disk</p></li><li class="listitem"><p>ATI Catalyst (some versions)</p></li><li class="listitem"><p>AVAST (disable FILESYSTEM and BEHAVIOR realtime shields)</p></li><li class="listitem"><p>Avira AntiVir</p></li><li class="listitem"><p>BeyondTrust PowerBroker</p></li><li class="listitem"><p>BitDefender</p></li><li class="listitem"><p>Bufferzone from Trustware</p></li><li class="listitem"><p>ByteMobile laptop optimization client</p></li><li class="listitem"><p>COMODO Firewall Pro</p></li><li class="listitem"><p>COMODO Internet Security</p></li><li class="listitem"><p>ConEmu (try disabling "Inject ConEmuHk" or see <a class="ulink" href="https://conemu.github.io/en/ConEmuHk.html#Third_party_problems" target="_top">ConEmuHk documentation</a>)</p></li><li class="listitem"><p>Citrix Metaframe Presentation Server/XenApp (see <a class="ulink" href="http://support.citrix.com/article/CTX107825" target="_top">Citrix Support page</a>)</p></li><li class="listitem"><p>Credant Guardian Shield</p></li><li class="listitem"><p>CylancePROTECT</p></li><li class="listitem"><p>Earthlink Total-Access</p></li><li class="listitem"><p>Forefront TMG</p></li><li class="listitem"><p>Google Desktop</p></li><li class="listitem"><p>Iolo System Mechanic/AntiVirus/Firewall</p></li><li class="listitem"><p>Kerio, Agnitum or ZoneAlarm Personal Firewall</p></li><li class="listitem"><p>LanDesk</p></li><li class="listitem"><p>Lavasoft Web Companion</p></li><li class="listitem"><p>Lenovo IPS Core Service (ipssvc)</p></li><li class="listitem"><p>Lenovo RapidBoot Shield</p></li><li class="listitem"><p>Logitech webcam software with "Logitech process monitor" service</p></li><li class="listitem"><p>MacType</p></li><li class="listitem"><p>NOD32 Antivirus</p></li><li class="listitem"><p>NVIDIA GeForce (some versions)</p></li><li class="listitem"><p>Norton/McAfee/Symantec antivirus or antispyware</p></li><li class="listitem"><p>PC Tools Spyware Doctor</p></li><li class="listitem"><p>Panda Internet Security</p></li><li class="listitem"><p>Sonic Solutions burning software containing DLA component (when DLA disabled)</p></li><li class="listitem"><p>Sophos Anti-Virus 7</p></li><li class="listitem"><p>Spybot S&amp;D TeaTimer</p></li><li class="listitem"><p>Various programs by Wave Systems Corp using wxvault.dll, including Embassy Trust Suite and Embassy Security Center</p></li><li class="listitem"><p>Webroot Spy Sweeper with Antivirus</p></li><li class="listitem"><p>Windows Defender </p></li><li class="listitem"><p>Windows LiveOneCare</p></li><li class="listitem"><p>IBM Security Trusteer Rapport (see <a class="ulink" href="http://www-03.ibm.com/software/products/en/trusteer-rapport" target="_top">its home page</a>)</p></li></ul></div><p>Sometimes these problems can be worked around, by temporarily or partially
disabling the offending software.  For instance, it may be possible to disable
on-access scanning in your antivirus, or configure it to ignore files under the
Cygwin installation root.  Often, unfortunately, this is not possible; even disabling
the software may not work, since many applications that hook the operating system
leave their hooks installed when disabled, and simply set them into what is intended
to be a completely transparent pass-through mode.  Sometimes this pass-through is not
as transparent as all that, and the hooks still interfere with Cygwin; in these cases,
it may be necessary to uninstall the software altogether to restore normal operation.
</p><p>Some of the symptoms you may experience are:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Random fork() failures</p><p>Caused by hook DLLs that load themselves into every process in the
system.  POSIX fork() semantics require that the memory map of the child process
must be an exact duplicate of the parent process' layout.  If one of these DLLs
loads itself at a different base address in the child's memory space as compared
to the address it was loaded at in the parent, it can end up taking the space that
belonged to a different DLL in the parent.  When Cygwin can't load the original
DLL at that same address in the child, the fork() call has to fail.
</p></li><li class="listitem"><p>File access problems</p><p>Some programs (e.g., virus scanners with on-access scanning) scan or
otherwise operate on every file accessed by all the other software running on
your computer.  In some cases they may retain an open handle on the file even
after the software that is really using the file has closed it.  This has been
known to cause operations such as deletes, renames and moves to fail with
access denied errors.  In extreme cases it has been known for scanners to leak
file handles, leading to kernel memory starvation.
</p></li><li class="listitem"><p>Networking issues</p><p>Firewall software sometimes gets a bit funny about Cygwin.  It's not
currently understood why; Cygwin only uses the standard Winsock2 API, but
perhaps in some less-commonly used fashion that doesn't get as well tested
by the publishers of firewalls.  Symptoms include mysterious failures to
connect, or corruption of network data being sent or received.</p></li><li class="listitem"><p>Memory and/or handle leaks</p><p>Some applications that hook into the Windows operating system exhibit
bugs when interacting with Cygwin that cause them to leak allocated memory
or other system resources.  Symptoms include complaints about out-of-memory
errors and even virtual memory exhaustion dialog boxes from the O/S; it is
often possible to see the excess memory allocation using a tool such as
Task Manager or Sysinternals' Process Explorer, although interpreting the
statistics they present is not always straightforward owing to complications
such as virtual memory paging and file caching.</p></li></ul></div></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.fixing-fork-failures"></a><p><b>4.45.</b></p></td><td align="left" valign="top"><p>How do I fix <code class="literal">fork()</code> failures?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Unfortunately, Windows does not use the fork/exec model of process creation
  found in UNIX-like OSes, so it is difficult for Cygwin to implement a reliable and
  correct <code class="literal">fork()</code>, which can lead to error messages such as:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">unable to remap <span class="emphasis"><em>somedll</em></span> to same address as parent</li><li class="listitem">couldn't allocate heap</li><li class="listitem">died waiting for dll loading</li><li class="listitem">child -1 - died waiting for longjmp before initialization</li><li class="listitem">STATUS_ACCESS_VIOLATION</li><li class="listitem">resource temporarily unavailable</li></ul></div><p>Potential solutions for the above errors:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Restart whatever process is trying (and failing) to use
    <code class="literal">fork()</code>. Sometimes Windows sets up a process
    environment that is even more hostile to <code class="literal">fork()</code> than usual.</li><li class="listitem">Ensure that you have eliminated (not just disabled) all
    software on the <a class="xref" href="faq.html#faq.using.bloda" title="4.44.">BLODA</a>.
    </li><li class="listitem">Switch from 32-bit Cygwin to 64-bit Cygwin, if your OS and CPU support that.
    With the bigger address space <code class="literal">fork()</code> is less likely to fail.</li><li class="listitem"><p>
      Try setting the environment variable CYGWIN to "detect_bloda", which
      enables some extra debugging, which may indicate what other software is
      causing the problem.
      </p><p>
      See <a class="ulink" href="https://cygwin.com/ml/cygwin/2012-02/msg00797.html" target="_top">this
      mail</a> for more information.
      </p></li><li class="listitem"><p>
	Force a full rebase: Run <span class="command"><strong>rebase-trigger fullrebase</strong></span>,
	exit all Cygwin programs and run the Cygwin Setup program.
      </p><p>
	By default, the Cygwin Setup program automatically performs an incremental
	rebase of newly installed files.  Forcing a full rebase causes the
	rebase map to be cleared before doing the rebase.
      </p><p>
	See <code class="literal">/usr/share/doc/rebase/README</code> and
	<code class="literal">/usr/share/doc/Cygwin/_autorebase.README</code> for more
	details.
      </p><p>Please note that installing new packages or updating existing
      ones undoes the effects of rebase and often causes fork() failures to
      reappear.
      </p></li></ul></div><p>See the <a class="ulink" href="https://cygwin.com/cygwin-ug-net/highlights.html#ov-hi-process" target="_top">
  process creation</a> section of the User's Guide for the technical reasons it is so
  difficult to make <code class="literal">fork()</code> work reliably.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.using.fixing-find_fast_cwd-warnings"></a><p><b>4.46.</b></p></td><td align="left" valign="top"><p>How do I fix <code class="literal">find_fast_cwd</code> warnings?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Older Cygwin releases asked users to report problems to the mailing
	list with the message:</p><pre class="screen">
	find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer. Please report
	this problem to the public mailing list <a class="ulink" href="mailto:cygwin@cygwin.com" target="_top">cygwin@cygwin.com</a></pre><p>Recent Cygwin releases changed this to the message:</p><pre class="screen">
	This typically occurs if you're using an older Cygwin version on a newer Windows.
	Please update to the latest available Cygwin version from <a class="ulink" href="https://cygwin.com/" target="_top">https://cygwin.com/</a>.
	If the problem persists, please see <a class="ulink" href="https://cygwin.com/problems.html" target="_top">https://cygwin.com/problems.html</a>.</pre><p>This is not serious, just a warning that Cygwin may not always be
	able to exactly emulate all aspects of Unix current directory handling
	under your Windows release.</p><p>Unfortunately some projects and products still distribute older
	Cygwin releases which may not fully support newer Windows releases,
	instead of installing the current release from the Cygwin project.
	They also may not provide any obvious way to keep the Cygwin packages
	their application uses up to date with fixes for security issues and
	upgrades.</p><p>The solution is simply downloading and running the Cygwin Setup program,
	following the instructions in the
	<a class="ulink" href="https://cygwin.com/cygwin-ug-net/setup-net.html#internet-setup" target="_top">
	Internet Setup</a> section of ``Setting Up Cygwin'' in the
	Cygwin User's Guide.</p><p>Please exit from all applications before running the Cygwin Setup program.
	When running Setup, you should not change most of the values presented,
	just select the <code class="literal">Next</code> button in most cases, as you
	already have a Cygwin release installed, and only want to upgrade your
	current installation.
	You should make your own selection if the internet connection to your
	system requires a proxy; and you must always pick an up to date Cygwin
	download (mirror) site, preferably the site nearest to your system for
	faster downloads, as shown, with more details to help you choose, on the
	<a class="ulink" href="https://cygwin.com/mirrors.html" target="_top">
	    Mirror Sites</a> web page.</p><p>The Cygwin Setup program will download and apply upgrades to all packages
	required for Cygwin itself and installed applications.
	Any problems with applying updates, or the application after updates,
	should be reported to the project or product supplier for remedial
	action.</p><p>As Cygwin is a volunteer project, unable to provide support for older
	releases installed by projects or products, it would be helpful to let
	other users know what project or product you installed, in a quick
	<a class="ulink" href="mailto:cygwin@cygwin.com?subject=Application%20with%20old%20Cygwin%20warning%20about%20FAST_CWD" target="_top">
	    email</a>.</p></td></tr><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="faq.api"></a>5. Cygwin API Questions</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>5.1. <a href="faq.html#faq.api.everything">How does everything work?</a></dt><dt>5.2. <a href="faq.html#faq.api.snapshots">Are development snapshots for the Cygwin library available?</a></dt><dt>5.3. <a href="faq.html#faq.api.testrels">Are test releases for the Cygwin library available?</a></dt><dt>5.4. <a href="faq.html#faq.api.cr-lf">How is the DOS/Unix CR/LF thing handled?</a></dt><dt>5.5. <a href="faq.html#faq.api.threads">Is the Cygwin library multi-thread-safe?</a></dt><dt>5.6. <a href="faq.html#faq.api.fork">How is fork() implemented?</a></dt><dt>5.7. <a href="faq.html#faq.api.globbing">How does wildcarding (globbing) work?</a></dt><dt>5.8. <a href="faq.html#faq.api.symlinks">How do symbolic links work?</a></dt><dt>5.9. <a href="faq.html#faq.api.executables">Why do some files, which are not executables have the 'x' type.</a></dt><dt>5.10. <a href="faq.html#faq.api.secure">How secure is Cygwin in a multi-user environment?</a></dt><dt>5.11. <a href="faq.html#faq.api.net-functions">How do the net-related functions work?</a></dt><dt>5.12. <a href="faq.html#faq.api.winsock">I don't want Unix sockets, how do I use normal Windows winsock?</a></dt><dt>5.13. <a href="faq.html#faq.api.versions">What version numbers are associated with Cygwin?</a></dt><dt>5.14. <a href="faq.html#faq.api.timezone">Why isn't my time (or zone) set correctly?</a></dt><dt>5.15. <a href="faq.html#faq.api.mouse">Is there a mouse interface?</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.everything"></a><p><b>5.1.</b></p></td><td align="left" valign="top"><p>How does everything work?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>There's a C library which provides a POSIX-style API.  The
applications are linked with it and voila - they run on Windows.
</p><p>The aim is to add all the goop necessary to make your apps run on
Windows into the C library.  Then your apps should (ideally) run on POSIX
systems (Unix/Linux) and Windows with no changes at the source level.
</p><p>The C library is in a DLL, which makes basic applications quite small.
And it allows relatively easy upgrades to the Windows/POSIX translation
layer, providing that DLL changes stay backward-compatible.
</p><p>For a good overview of Cygwin, you may want to read the Cygwin
User's Guide.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.snapshots"></a><p><b>5.2.</b></p></td><td align="left" valign="top"><p>Are development snapshots for the Cygwin library available?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Starting December 2022, the old developer snapshots have been
deprecated by regular, automated test releases.  See the next FAQ entry
<a class="xref" href="faq.html#faq.api.testrels" title="5.3.">Test Releases</a>
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.testrels"></a><p><b>5.3.</b></p></td><td align="left" valign="top"><p>Are test releases for the Cygwin library available?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes.  Starting December 2022, regular, automated test releases
are created whenever a significant patch is pushed to the Cygwin git
repo at <a class="ulink" href="https://cygwin.com/cgit/newlib-cygwin/" target="_top">https://cygwin.com/cgit/newlib-cygwin/</a>.
You can download the cygwin package test releases just like any other
test release for any Cgywin package using the Cygwin Setup program.
For more info, see
<a class="xref" href="faq.html#faq.setup.testrels" title="2.21.">Install Test Releases</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.cr-lf"></a><p><b>5.4.</b></p></td><td align="left" valign="top"><p>How is the DOS/Unix CR/LF thing handled?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Let's start with some background.
</p><p>On POSIX systems, a file is a file and what the file contains is
whatever the program/programmer/user told it to put into it.  In Windows,
a file is also a file and what the file contains depends not only on the
program/programmer/user but also the file processing mode.
</p><p>When processing in text mode, certain values of data are treated
specially.  A \n (new line, NL) written to the file will prepend a \r
(carriage return, CR) so that if you `printf("Hello\n") you in fact get
"Hello\r\n".  Upon reading this combination, the \r is removed and the
number of bytes returned by the read is 1 less than was actually read.
This tends to confuse programs dependent on ftell() and fseek().  A
Ctrl-Z encountered while reading a file sets the End Of File flags even
though it truly isn't the end of file.
</p><p>One of Cygwin's goals is to make it possible to mix Cygwin-ported
POSIX programs with generic Windows programs.  As a result, Cygwin allows
to open files in text mode.  In the accompanying tools, tools that deal
with binaries (e.g. objdump) operate in POSIX binary mode and many (but
not all) tools that deal with text files (e.g. bash) operate in text mode.
There are also some text tools which operate in a mixed mode.  They read
files always in text mode, but write files in binary mode, or they write
in the mode (text or binary) which is specified by the underlying mount
point.  For a description of mount points, see the Cygwin User's Guide.
</p><p>Actually there's no really good reason to do text mode processing
since it only slows down reading and writing files.  Additionally many
Windows applications can deal with POSIX \n line endings just fine
(unfortunate exception: Notepad).  So we suggest to use binary mode
as much as possible and only convert files from or to DOS text mode
using tools specifically created to do that job, for instance, dos2unix and
unix2dos from the dos2unix package.
</p><p>It is rather easy for the porter of a Unix package to fix the source
code by supplying the appropriate file processing mode switches to the
open/fopen functions.  Treat all text files as text and treat all binary
files as binary.  To be specific, you can select binary mode by adding
<code class="literal">O_BINARY</code> to the second argument of an
<code class="literal">open</code> call, or <code class="literal">"b"</code> to second argument
of an <code class="literal">fopen</code> call.  You can also call
<code class="literal">setmode (fd, O_BINARY)</code>.  To select text mode add
<code class="literal">O_TEXT</code> to the second argument of an <code class="literal">open</code>
call, or <code class="literal">"t"</code> to second argument of an
<code class="literal">fopen</code> call, or just call
<code class="literal">setmode (fd, O_TEXT)</code>.
</p><p>You can also avoid to change the source code at all by linking
an additional object file to your executable.  Cygwin provides various
object files in the <code class="filename">/usr/lib</code> directory which,
when linked to an executable, changes the default open modes of any
file opened within the executed process itself.  The files are
</p><pre class="screen">
  binmode.o      - Open all files in binary mode.
  textmode.o     - Open all files in text mode.
  textreadmode.o - Open all files opened for reading in text mode.
  automode.o     - Open all files opened for reading in text mode,
                   all files opened for writing in binary mode.
</pre><p>
</p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
  Linking against these object files does <span class="emphasis"><em>not</em></span> change
  the open mode of files propagated to a process by its parent process,
  for instance, if the process is part of a shell pipe expression.
</div><p>
</p><p>Note that of the above flags only the "b" fopen flags are defined by
ANSI.  They exist under most flavors of Unix.  However, using O_BINARY,
O_TEXT, or the "t" flag is non-portable.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.threads"></a><p><b>5.5.</b></p></td><td align="left" valign="top"><p>Is the Cygwin library multi-thread-safe?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes.
</p><p>There is also extensive support for 'POSIX threads', see the file
<code class="literal">cygwin.din</code> for the list of POSIX thread functions provided.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.fork"></a><p><b>5.6.</b></p></td><td align="left" valign="top"><p>How is fork() implemented?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin fork() essentially works like a non-copy on write version
of fork() (like old Unix versions used to do).  Because of this it
can be a little slow.  In most cases, you are better off using the
spawn family of calls if possible.
</p><p>Here's how it works:
</p><p>Parent initializes a space in the Cygwin process table for child.
Parent creates child suspended using Windows CreateProcess call, giving
the same path it was invoked with itself.  Parent calls setjmp to save
its own context and then sets a pointer to this in the Cygwin shared
memory area (shared among all Cygwin tasks).  Parent fills in the child's
.data and .bss subsections by copying from its own address space into
the suspended child's address space.  Parent then starts the child.
Parent waits on mutex for child to get to safe point.  Child starts and
discovers if has been forked and then longjumps using the saved jump
buffer.  Child sets mutex parent is waiting on and then blocks on
another mutex waiting for parent to fill in its stack and heap.  Parent
notices child is in safe area, copies stack and heap from itself into
child, releases the mutex the child is waiting on and returns from the
fork call.  Child wakes from blocking on mutex, recreates any mmapped
areas passed to it via shared area and then returns from fork itself.
</p><p>When the executable or any dll in use by the parent was renamed or
moved into the hidden recycle bin, fork retries with creating hardlinks
for the old executable and any dll into per-user subdirectories in the
/var/run/cygfork/ directory, when that one exists and resides on NTFS.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.globbing"></a><p><b>5.7.</b></p></td><td align="left" valign="top"><p>How does wildcarding (globbing) work?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If the DLL thinks it was invoked from a DOS style prompt, it runs a
`globber' over the arguments provided on the command line.  This means
that if you type <code class="literal">LS *.EXE</code> from DOS, it will do what you might
expect.
</p><p>Beware: globbing uses <code class="literal">malloc</code>.  If your application defines
<code class="literal">malloc</code>, that will get used.  This may do horrible things to you.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.symlinks"></a><p><b>5.8.</b></p></td><td align="left" valign="top"><p>How do symbolic links work?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin knows of five ways to create symlinks.  This is really
complicated stuff since we started out way back when Windows didn't
know symlinks at all.  The rest is history...
</p><div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: disc; "><li class="listitem"><p>
Starting with Cygwin 3.1.5 in 2020, symlinks are created by default as a
special reparse point type known as "WSL symlinks".  These have been
introduced on Windows 10 with the advent of WSL, "Windows Subsystem for
Linux".  WSL symlinks created by Cygwin are understood by WSL and vice
versa.  They contain a normal POSIX path as used in the Cygwin and WSL
environments.  Windows itself recognizes them as arbitrary reparse
points (CMD's "dir" command shows them as "[JUNCTION]") but it doesn't
know how to follow them to the target.  Older Windows versions handle
these symlinks exactly the same way, so there's no point using different
symlink types on older Windows.  These symlinks only work on filesystems
supporting reparse points, but fortunately there's another symlink type
Cygwin creates, right the next bullet point...
</p></li><li class="listitem"><p>
The original default method creating symlinks in Cygwin since pre-2000
generates symlinks as simple files with a magic header and the DOS
SYSTEM attribute set.  When you open a file or directory through such a
symlink, Cygwin opens the file, checks the magic header, and if it's
correct, reads the target of the symlink from the remainder of the file.
Because we don't want having to open every referenced file to check
symlink status, Cygwin only opens files with DOS SYSTEM attribute set to
inspect them for being a Cygwin symlink.  These symlinks also work
on filesystems not supporting reparse points, i. e., FAT/FAT32/ExFAT.
</p></li><li class="listitem"><p>
A very special case are NFS filesystems, supported by Cygwin since 2008
via the Microsoft NFS driver, unfortunately only available in Enterprise
versions of Windows.  Filesystems shared via NFS usually support symlinks
all by themselves, and the Microsoft driver has special functionality to
support them.  Cygwin utilizes this interface to create "real" symlinks
on filesystems mounted via NFS.
</p></li><li class="listitem"><p>
Starting 2013, Cygwin also supports NTFS symlinks, introduced with
Windows Vista.  These symlinks are reparse points containing a Windows
path.  Creating them is enabled by setting 'winsymlinks:native' or
'winsymlinks:nativestrict' in the environment variable CYGWIN.  The
upside of this symlink type is that the path is stored as Windows path
so they are understood by non-Cygwin Windows tools as well.  The downsides
are:
</p><div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: circle; "><li class="listitem"><p>
The path is stored as Windows path, so the path has perhaps to be rearranged
to result in a valid path.  This may result in a divergence from the original
POSIX path the user intended.
</p></li><li class="listitem"><p>
Creating NTFS symlinks require administrative privileges by default.  You
have to make certain settings in the OS (depending on the Windows version)
to allow creating them as a non-privileged user.
</p></li><li class="listitem"><p>
NTFS symlinks have a type.  They are either a "file" or a "directory",
depending on the target file type.  This information is utilized especially
by Windows Explorer to show the correct file or directory icon in file
listings without having to check on the target file and to know what
actions are provided by clicking on the symlink.  However, if a NTFS
symlink points to a file "foo", and "foo" is deleted and replaced by
a directory "foo", the symlink type of an NTFS symlink pointing to "foo"
is unchanged and subsequently Windows Explorer will misbehave.
Consequentially, creating dangling NTFS symlinks is a nuisance, since
the library does not know what type the still-to-be-created symlink
target will be.  Cygwin will not create dangling NTFS symlinks, but
fallback to creating the default symlink type (winsymlinks:native) or
just fail (winsymlinks:nativestrict).
</p></li></ul></div><p>
</p></li><li class="listitem"><p>
Another method, available since 2001, is enabled if `winsymlinks'  or
'winsymlinks:lnk' is set in the environment variable CYGWIN.  Using this
method, Cygwin generates symlinks by creating Windows shortcuts .
Cygwin created shortcuts have a special header (which is never created
by Explorer that way) and the DOS READONLY attribute set.  A Windows
path is stored in the shortcut as usual and the POSIX path is stored in
the remainder of the file.  While the POSIX path is stored as is, the
Windows path has perhaps to be rearranged to result in a valid path.
This may result in a divergence between the Windows and the POSIX path
when symlinks are moved crossing mount points.  When a user changes the
shortcut, this will be detected by Cygwin and it will only use the
Windows path then.  While Cygwin shortcuts are shown without the ".lnk"
suffix in `ls' output, non-Cygwin shortcuts are shown with the suffix.
</p><p>For enabling this or the preceeding symlink type, see
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/using-cygwinenv.html" target="_top">https://cygwin.com/cygwin-ug-net/using-cygwinenv.html</a>
</p></li></ul></div></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.executables"></a><p><b>5.9.</b></p></td><td align="left" valign="top"><p>Why do some files, which are not executables have the 'x' type.</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>When working out the POSIX-style attribute bits on a file stored on
certain filesystems (FAT, FAT32), the library has to fill out some information
not provided by these filesystems.
</p><p>It guesses that files ending in .exe and .bat are executable, as are
ones which have a "#!" as their first characters.  This guessing doesn't
take place on filesystems providing real permission information (NTFS, NFS),
unless you switch the permission handling off using the mount flag "noacl"
on these filesystems.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.secure"></a><p><b>5.10.</b></p></td><td align="left" valign="top"><p>How secure is Cygwin in a multi-user environment?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>As of version 1.5.13, the Cygwin developers are not aware of any feature
in the cygwin dll that would allow users to gain privileges or to access
objects to which they have no rights under Windows. However there is no
guarantee that Cygwin is as secure as the Windows it runs on.  Cygwin
processes share some variables and are thus easier targets of denial of
service type of attacks.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.net-functions"></a><p><b>5.11.</b></p></td><td align="left" valign="top"><p>How do the net-related functions work?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The network support in Cygwin is supposed to provide the POSIX API, not
the Winsock API.
</p><p>There are differences between the semantics of functions with the same
name under the API.
</p><p>E.g., the POSIX select system call can wait on a standard file handles
and handles to sockets.  The select call in Winsock can only wait on
sockets.  Because of this, the Cygwin dll does a lot of nasty stuff behind
the scenes, trying to persuade various Winsock/Windows functions to do what
a Unix select would do.
</p><p>If you are porting an application which already uses Winsock, then
porting the application to Cygwin means to port the application to using
the POSIX net functions.  You should never mix Cygwin net functions with
direct calls to Winsock functions.  If you use Cygwin, use the POSIX API.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.winsock"></a><p><b>5.12.</b></p></td><td align="left" valign="top"><p>I don't want Unix sockets, how do I use normal Windows winsock?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>You don't.  Look for the Mingw-w64 project to port applications using
native Windows API/Winsock functions.  Cross compilers packages to build Mingw-w64
targets are available in the Cygwin distro.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.versions"></a><p><b>5.13.</b></p></td><td align="left" valign="top"><p>What version numbers are associated with Cygwin?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin versioning is relatively complicated because of its status as a
shared library.  First of all, since October 1998 every Cygwin DLL has
been named <code class="literal">cygwin1.dll</code> and has a 1 in the release name.
Additionally, there are DLL major and minor numbers that correspond to
the name of the release, and a release number. In other words,
cygwin-2.4.1-1 is <code class="literal">cygwin1.dll</code>, major version 2, minor
version 4, release 1.  -1 is a subrelease number required by the distro
versioning scheme.  It's not actually part of the Cygwin DLL version number.
</p><p>The <code class="literal">cygwin1.dll</code> major version number gets incremented
only when a change is made that makes existing software incompatible. For
example, the first major version 5 release, cygwin-1.5.0-1, added 64-bit
file I/O operations, which required many libraries to be recompiled and
relinked.  The minor version changes every time we make a new backward
compatible Cygwin release available.  There is also a
<code class="literal">cygwin1.dll</code> release version number.  The release number
is only incremented if we update an existing release in a way that does not
effect the DLL (like a missing header file).
</p><p>There are also Cygwin API major and minor numbers.  The major number
tracks important non-backward-compatible interface changes to the API.
An executable linked with an earlier major number will not be compatible
with the latest DLL.  The minor number tracks significant API additions
or changes that will not break older executables but may be required by
newly compiled ones.
</p><p>Then there is a shared memory region compatibility version number.  It is
incremented when incompatible changes are made to the shared memory
region or to any named shared mutexes, semaphores, etc.  For more exciting
Cygwin version number details, check out the
<code class="literal">/usr/include/cygwin/version.h</code> file.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.timezone"></a><p><b>5.14.</b></p></td><td align="left" valign="top"><p>Why isn't my time (or zone) set correctly?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Daylight saving (Summer time) and other time zone changes are
decided on by politicians, and announced by government officials,
sometimes with short or no notice, so time zone updates are released at
least a few, and sometimes several, times a year.
Details of changes are not known until they are announced publicly by
officials, often in foreign languages.
Those details then have to be noticed, possibly translated, passed to,
picked up, and applied by the official <code class="filename">tzdata</code>
source package maintainers.
That information has to be compiled, checked, and released publicly in
an update to the official <code class="filename">tzdata</code> source package.
Then those changes have to be picked up and applied to the Cygwin
<code class="filename">tzdata</code> package, which has to be updated, built,
tested, and released publicly.
</p><p>Time zone settings are updates to the daylight saving (Summer
time) rules for dates of changes, hour offsets from UTC of time zones,
and the geographic regions to which those rules and offsets apply,
provided in the <code class="filename">tzdata</code> package included in all
Cygwin installations.
Have you run the Cygwin Setup program recently to update at least
the <code class="filename">tzdata</code> package?
</p><p>Are you developing applications using times which may be affected
by time zones?
Since the <code class="literal">ctime()</code>, <code class="literal">localtime()</code>,
<code class="literal">mktime()</code>, and <code class="literal">strftime()</code> functions
are required to set time zone information as if by calling
<code class="literal">tzset()</code>, there is no need for an explicit
<code class="literal">tzset()</code> call before using these functions.
However, if none of the above functions are called first, applications
should ensure <code class="literal">tzset()</code> is called explicitly before
using any other time functions, or checking or using time zone
information.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.api.mouse"></a><p><b>5.15.</b></p></td><td align="left" valign="top"><p>Is there a mouse interface?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you're using X then use the X API to handle mouse events.
In a Windows console window you can enable and capture mouse events
using the xterm escape sequences for mouse events.
</p></td></tr><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="faq.programming"></a>6. Programming Questions</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>6.1. <a href="faq.html#faq.programming.packages">How do I contribute a package?</a></dt><dt>6.2. <a href="faq.html#faq.programming.contribute">How do I contribute to Cygwin?</a></dt><dt>6.3. <a href="faq.html#faq.programming.huge-executables">Why are compiled executables so huge?!?</a></dt><dt>6.4. <a href="faq.html#faq.programming.64bitporting">What do I have to look out for when porting applications to 64 bit Cygwin?</a></dt><dt>6.5. <a href="faq.html#faq.programming.64bitporting-fail">My project doesn't build at all on 64 bit Cygwin.  What's up?</a></dt><dt>6.6. <a href="faq.html#faq.programming.64bitporting-cygwin64">Why is __CYGWIN64__ not defined for 64 bit?</a></dt><dt>6.7. <a href="faq.html#faq.programming.glibc">Where is glibc?</a></dt><dt>6.8. <a href="faq.html#faq.programming.objective-c">Where is Objective C?</a></dt><dt>6.9. <a href="faq.html#faq.programming.make-execvp">Why does my make fail on Cygwin with an execvp error? </a></dt><dt>6.10. <a href="faq.html#faq.programming.ipc">How can I use IPC, or why do I get a Bad system call
error?</a></dt><dt>6.11. <a href="faq.html#faq.programming.winmain">Why the undefined reference to WinMain@16?</a></dt><dt>6.12. <a href="faq.html#faq.programming.win32-api">How do I use Windows API calls?</a></dt><dt>6.13. <a href="faq.html#faq.programming.win32-no-cygwin">How do I compile a Windows executable that doesn't use Cygwin?</a></dt><dt>6.14. <a href="faq.html#faq.programming.static-linking">Can I build a Cygwin program that does not require cygwin1.dll at runtime?</a></dt><dt>6.15. <a href="faq.html#faq.programming.msvcrt-and-cygwin">Can I link with both MSVCRT*.DLL and cygwin1.dll?</a></dt><dt>6.16. <a href="faq.html#faq.programming.no-console-window">How do I make the console window go away?</a></dt><dt>6.17. <a href="faq.html#faq.programming.make-spaces">Why does make complain about a "missing separator"?</a></dt><dt>6.18. <a href="faq.html#faq.programming.win32-headers">Why can't we redistribute Microsoft's Windows API headers?</a></dt><dt>6.19. <a href="faq.html#faq.programming.msvs-mingw">How do I use cygwin1.dll with Visual Studio or Mingw-w64?</a></dt><dt>6.20. <a href="faq.html#faq.programming.linking-lib">How do I link against a .lib file?</a></dt><dt>6.21. <a href="faq.html#faq.programming.building-cygwin">How do I build Cygwin on my own?</a></dt><dt>6.22. <a href="faq.html#faq.programming.debugging-cygwin">I may have found a bug in Cygwin, how can I debug it (the symbols in gdb look funny)?</a></dt><dt>6.23. <a href="faq.html#faq.programming.compiling-unsupported">How can I compile Cygwin for an unsupported platform (PowerPC, Alpha, ARM, Itanium)?</a></dt><dt>6.24. <a href="faq.html#faq.programming.adjusting-heap">How can I adjust the heap/stack size of an application?</a></dt><dt>6.25. <a href="faq.html#faq.programming.dll-cygcheck">How can I find out which DLLs are needed by an executable?</a></dt><dt>6.26. <a href="faq.html#faq.programming.dll-building">How do I build a DLL?</a></dt><dt>6.27. <a href="faq.html#faq.programming.breakpoint">How can I set a breakpoint at mainCRTStartup?</a></dt><dt>6.28. <a href="faq.html#faq.programming.debug">How can I debug what's going on?</a></dt><dt>6.29. <a href="faq.html#faq.programming.system-trace">Can I use a system trace mechanism instead?</a></dt><dt>6.30. <a href="faq.html#faq.programming.gdb-signals">How does gdb handle signals?</a></dt><dt>6.31. <a href="faq.html#faq.programming.linker">The linker complains that it can't find something.</a></dt><dt>6.32. <a href="faq.html#faq.programming.stat64">Why do I get an error using struct stat64?</a></dt><dt>6.33. <a href="faq.html#faq.programming.libc">Can you make DLLs that are linked against libc ?</a></dt><dt>6.34. <a href="faq.html#faq.programming.malloc-h">Where is malloc.h?</a></dt><dt>6.35. <a href="faq.html#faq.programming.own-malloc">Can I use my own malloc?</a></dt><dt>6.36. <a href="faq.html#faq.programming.msvc-gcc-objects">Can I mix objects compiled with msvc++ and gcc?</a></dt><dt>6.37. <a href="faq.html#faq.programming.gdb-msvc">Can I use the gdb debugger to debug programs built by VC++?</a></dt><dt>6.38. <a href="faq.html#faq.programming.make-scripts">Shell scripts aren't running properly from my makefiles?</a></dt><dt>6.39. <a href="faq.html#faq.programming.preprocessor">What preprocessor macros do I need to know about?</a></dt><dt>6.40. <a href="faq.html#faq.programming.unix-gui">How should I port my Unix GUI to Windows?</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.packages"></a><p><b>6.1.</b></p></td><td align="left" valign="top"><p>How do I contribute a package?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you are willing to be a package maintainer, great!  We urgently need
volunteers to prepare and maintain packages, because the priority of the
Cygwin Team is Cygwin itself.
</p><p>The Cygwin Package Contributor's Guide at
<a class="ulink" href="https://cygwin.com/packages.html" target="_top">https://cygwin.com/packages.html</a> details everything you need to know
about Cygwin packaging.
</p><p>For questions about package maintenance, use the cygwin-apps mailing
list (start at <a class="ulink" href="https://cygwin.com/lists.html" target="_top">https://cygwin.com/lists.html</a>) <span class="emphasis"><em>after</em></span>
searching and browsing the cygwin-apps list archives, of course.  Be
sure to look at the <span class="emphasis"><em>Submitting a package</em></span> checklist at
<a class="ulink" href="https://cygwin.com/packaging-contributors-guide.html#submitting" target="_top">https://cygwin.com/packaging-contributors-guide.html#submitting</a>
before sending an ITP (Intent To Package) email to cygwin-apps.
</p><p>You should also announce your intentions to the general cygwin list, in
case others were thinking the same thing.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.contribute"></a><p><b>6.2.</b></p></td><td align="left" valign="top"><p>How do I contribute to Cygwin?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you want to contribute to Cygwin itself, see
<a class="ulink" href="https://cygwin.com/contrib.html" target="_top">https://cygwin.com/contrib.html</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.huge-executables"></a><p><b>6.3.</b></p></td><td align="left" valign="top"><p>Why are compiled executables so huge?!?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>By default, gcc compiles in all symbols.  You'll also find that gcc
creates large executables on UNIX.
</p><p>If that bothers you, just use the 'strip' program, part of the binutils
package.  Or compile with the <code class="literal">-s</code> option to gcc.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.64bitporting"></a><p><b>6.4.</b></p></td><td align="left" valign="top"><p>What do I have to look out for when porting applications to 64 bit Cygwin?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The Cygwin x86_64 toolchain is using the
<a class="ulink" href="http://en.wikipedia.org/wiki/LLP64#64-bit_data_models" target="_top">LP64</a>
data model.  That means, in contrast to Windows, which uses an
<a class="ulink" href="http://en.wikipedia.org/wiki/LLP64#64-bit_data_models" target="_top">LLP64</a>
data model, sizeof(long) != sizeof(int), just as on Linux.</p><p>For comparison:</p><pre class="screen">
                 Cygwin   Windows  Cygwin
                 Linux    x86_64   Linux
                 Windows           x86_64
                 i686

sizeof(int)         4        4        4
sizeof(long)        4        4        8
sizeof(size_t)      4        8        8
sizeof(void*)       4        8        8
</pre><p>This difference can result in interesting problems, especially when
using Windows API functions using pointers to Windows
datatypes like LONG, ULONG, DWORD.  Given that Windows is LLP64, all of
the aforementioned types are 4 byte in size, on 32 as well as on 64 bit
Windows, while `long' on 64 bit Cygwin is 8 bytes.</p><p>Take the example ReadFile:</p><pre class="screen">
  ReadFile (HANDLE, LPVOID, DWORD, LPDWORD, LPOVERLAPPED);
</pre><p>In the 32 bit Cygwin and Mingw-w64 environments, as well as in the 64 bit
Mingw-w64 environment, it is no problem to substitute DWORD with unsigned
long:</p><pre class="screen">
  unsigned long number_of_bytes_read;
  [...]
  ReadFile (fhdl, buf, buflen, &amp;number_of_bytes_read, NULL);
</pre><p>However, in 64 bit Cygwin, using LP64, number_of_bytes_read is 8 bytes
in size.  But since ReadFile expects a pointer to a 4 byte type, the function
will only change the lower 4 bytes of number_of_bytes_read on return, while
the content of the upper 4 bytes stays undefined.</p><p>Here are a few <span class="emphasis"><em>donts</em></span> which should help porting
applications from the known ILP32 data model of 32 bit Cygwin, to the LP64
data model of 64 bit Cygwin.  Note that these are not Cygwin-only problems.
Many Linux applications suffered the same somewhat liberal handling of
datatypes when the AMD64 CPU was new.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; "><li class="listitem" style="list-style-type: disc"><p>
<span class="emphasis"><em>Don't</em></span> mix up int and long in printf/scanf.  This:

</p><pre class="screen">
    int i; long l;
    printf ("%d %ld\n", l, i);
</pre><p>

may not print what you think it should.  Enable the gcc options -Wformat or
-Wall, which warn about type mismatches in printf/scanf functions.

</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>Using -Wall (optionally with -Werror to drive the point home) makes a
lot of sense in general, not only when porting code to a new platform.</div><p>
</p></li><li class="listitem" style="list-style-type: disc"><p>
<span class="emphasis"><em>Don't</em></span> mix int and long pointers.

</p><pre class="screen">
    long *long_ptr = (long *) &amp;my_int; /* Uh oh! */
    *long_ptr = 42;
</pre><p>

The assignment will write 8 bytes to the address of my_int.  Since my_int
is only 4 bytes, <span class="emphasis"><em>something else</em></span> gets randomly overwritten.
Finding this kind of bug is very hard, because you will often see a problem
which has no immediate connection to the actual bug.
</p></li><li class="listitem" style="list-style-type: disc"><p>
<span class="emphasis"><em>Don't</em></span> mix int and pointers at all!  This will
<span class="emphasis"><em>not</em></span> work as expected anymore:

</p><pre class="screen">
    void *ptr;
    printf ("Pointer value is %x\n", ptr);
</pre><p>

%x denotes an int argument.  The value printed by printf is a 4 byte value,
so on x86_64 the printed pointer value is missing its upper 4 bytes; the output
is very likely wrong.  Use %p instead, which portable across architectures:

</p><pre class="screen">
    void *ptr;
    printf ("Pointer value is %p\n", ptr);
</pre><p>
</p></li><li class="listitem" style="list-style-type: disc"><p>
Along the same lines <span class="emphasis"><em>don't</em></span> use the type int in
pointer arithmetic.  Don't cast pointers to int, don't cast pointer
differences to int, and don't store pointer differences in an int type.
Use the types <code class="literal">intptr_t</code>, <code class="literal">uintptr_t</code>
and <code class="literal">ptrdiff_t</code> instead, they are designed for performing
architecture-independent pointer arithmetic.
</p></li><li class="listitem" style="list-style-type: disc"><p>
<span class="emphasis"><em>Don't</em></span> make blind assumptions about the size of a POSIX
type.  For instance, <code class="literal">time_t</code> is 8 bytes on 64 bit Cygwin,
while it is (still, at the time of writing this) 4 bytes on 32 bit Cygwin,
since time_t is based on the type long.
</p></li><li class="listitem" style="list-style-type: disc"><p>
<span class="emphasis"><em>Don't</em></span> use functions returning pointers without declaration.
For instance

</p><pre class="screen">
    printf ("Error message is: %s\n", strerror (errno));
</pre><p>

This code will <span class="emphasis"><em>crash</em></span>, unless you included
<code class="filename">string.h</code>.  The implicit rule in C is that an undeclared
function is of type int.  But int is 4 byte and pointers are 8 byte, so the
string pointer given to printf is missing the upper 4 bytes.
</p></li><li class="listitem" style="list-style-type: disc"><p>
<span class="emphasis"><em>Don't</em></span> use C base types together with Windows API functions.
Keep in mind that DWORD, LONG, ULONG are <span class="emphasis"><em>not</em></span> the same
as long and unsigned long.  Try to use only Windows datatypes in conjunction
with Windows API function calls to avoid type problems.  See the above
ReadFile example.  Windows functions in printf calls should be treated
carefully as well.  This code is common for 32 bit code, but probably prints
the wrong value on 64 bit:

</p><pre class="screen">
    printf ("Error message is: %lu\n", GetLastError ());
</pre><p>

Using gcc's -Wformat option would warn about this.  Casting to the requested
base type helps in this case:

</p><pre class="screen">
    printf ("Error message is: %lu\n", (unsigned long) GetLastError ());
</pre><p>
</p></li><li class="listitem" style="list-style-type: disc"><p>
<span class="emphasis"><em>Don't</em></span> mix Windows datatypes with POSIX type-specific
MIN/MAX values.

</p><pre class="screen">
    unsigned long l_max = ULONG_MAX;    /* That's right. */
    ULONG w32_biggest = ULONG_MAX;	/* Hey, wait!  What? */
    ULONG w32_biggest = UINT_MAX;	/* Ok, but borderline. */
</pre><p>

Again, keep in mind that ULONG (or DWORD) is <span class="emphasis"><em>not</em></span> unsigned
long but rather unsigned int on 64 bit.
</p></li></ul></div></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.64bitporting-fail"></a><p><b>6.5.</b></p></td><td align="left" valign="top"><p>My project doesn't build at all on 64 bit Cygwin.  What's up?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Typically reasons for that are:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; "><li class="listitem" style="list-style-type: disc"><p><code class="literal">__CYGWIN32__</code> is not defined in the
64 bit toolchain.  This may hit a few projects which are around since before
Y2K.  Check your project for occurences of <code class="literal">__CYGWIN32__</code>
and change them to <code class="literal">__CYGWIN__</code>, which is defined in the
Cygwin toolchain since 1998, to get the same Cygwin-specific code changes done.
</p></li><li class="listitem" style="list-style-type: disc"><p>The project maintainers took it for granted that Cygwin is
running only on i686 CPUs and the code is making this assumption blindly.
You have to check the code for such assumptions and fix them.
</p></li><li class="listitem" style="list-style-type: disc"><p>The project is using autotools, the
<code class="filename">config.sub</code> and <code class="filename">config.guess</code> files
are hopelessly outdated and don't recognize
<code class="literal">x86_64-{pc,unknown}-cygwin</code> as valid target.  Update the
project configury (cygport will do this by default) and try again.
</p></li><li class="listitem" style="list-style-type: disc"><p>The project uses Windows functions on Cygwin and it's suffering
from the problems described in the preceeding FAQ entry.
</p></li></ul></div><p>In all of this cases, please make sure to fix that upstream, or send
your patches to the upstream maintainers, so the problems get fixed for the
future.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.64bitporting-cygwin64"></a><p><b>6.6.</b></p></td><td align="left" valign="top"><p>Why is __CYGWIN64__ not defined for 64 bit?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>There is no <code class="literal">__CYGWIN64__</code> because we would like to
have a unified way to handle Cygwin code in portable projects.  Using
<code class="literal">__CYGWIN32__</code> and <code class="literal">__CYGWIN64__</code> only
complicates the code for no good reason.  Along the same lines you won't
find predefined macros <code class="literal">__linux32__</code> and
<code class="literal">__linux64__</code> on Linux.</p><p>If you really have to differ between 32 and 64 bit in some way, you have
three choices.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; "><li class="listitem" style="list-style-type: disc"><p>If your code depends on the CPU architecture, use the
predefined compiler definition for the architecture, like this:</p><pre class="screen">
#ifdef __CYGWIN__
# ifdef __x86_64__	/* Alternatively __x86_64, __amd64__, __amd64 */
    /* Code specific for AMD64 CPU */
# elif __X86__
    /* Code specific for ix86 CPUs */
# else
#   error Unsupported Architecture
# endif
#endif
</pre></li><li class="listitem" style="list-style-type: disc"><p>If your code depends on differences in the data model, you
should consider to use the <code class="literal">__LP64__</code> definition
instead:</p><pre class="screen">
#ifdef __CYGWIN__
# ifdef __LP64__	/* Alternatively _LP64 */
    /* Code specific for 64 bit CPUs */
# else
    /* Code specific for 32 bit CPUs */
# endif
#endif
</pre></li><li class="listitem" style="list-style-type: disc"><p>If your code uses Windows functions, and some of the
functionality is 64 bit Windows-specific, use <code class="literal">_WIN64</code>,
which is defined on 64 bit Cygwin, as soon as you include
<code class="filename">windows.h</code>.  This should only be used in the most
desperate of occasions, though, and <span class="emphasis"><em>only</em></span> if it's
really about a difference in Windows API functionality!</p><pre class="screen">
#ifdef __CYGWIN__
# ifdef _WIN64
    /* Code specific for 64 bit Windows */
# else
    /* Code specific for 32 bit Windows */
# endif
#endif
</pre></li></ul></div></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.glibc"></a><p><b>6.7.</b></p></td><td align="left" valign="top"><p>Where is glibc?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin does not provide glibc.  It uses newlib instead, which provides
much (but not all) of the same functionality.  Porting glibc to Cygwin
would be difficult.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.objective-c"></a><p><b>6.8.</b></p></td><td align="left" valign="top"><p>Where is Objective C?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Support for compiling Objective C is available in the <code class="literal">gcc-objc</code>
package; resulting binaries will depend on the <code class="literal">libobjc2</code>
package at runtime.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.make-execvp"></a><p><b>6.9.</b></p></td><td align="left" valign="top"><p>Why does my make fail on Cygwin with an execvp error? </p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Beware of using non-portable shell features in your Makefiles (see tips
at <a class="xref" href="faq.html#faq.using.shell-scripts" title="4.16.">Using Shell Scripts</a>).
</p><p>Errors of <code class="literal">make: execvp: /bin/sh: Illegal Argument</code> or 
<code class="literal">make: execvp: /bin/sh: Argument list too long</code> are often
caused by the command-line being to long for the Windows execution model.
To circumvent this, mount the path of the executable using the -X switch
to enable cygexec for all executables in that folder; you will also need
to exclude non-cygwin executables with the -x switch. Enabling cygexec
causes cygwin executables to talk directly to one another, which increases
the command-line limit. To enable cygexec for <code class="literal">/bin</code> and 
<code class="literal">/usr/bin</code>, you can add or change these entries in /etc/fstab:
</p><pre class="screen">
C:/cygwin/bin /bin ntfs binary,cygexec 0 0
C:/cygwin/bin /usr/bin ntfs binary,cygexec 0 0
</pre><p>If you have added other non-Cygwin programs to a path you want to mount
cygexec, you can find them with a script like this:
</p><pre class="screen">
#!/bin/sh
cd /bin; for f in `find . -type f -name '*.exe'`; do
	cygcheck $f | (grep -Fqi cygwin1.dll || echo $f)
done
</pre><p>
See <a class="ulink" href="https://cygwin.com/cygwin-ug-net/using.html#mount-table" target="_top">https://cygwin.com/cygwin-ug-net/using.html#mount-table</a> 
for more information on using mount.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.ipc"></a><p><b>6.10.</b></p></td><td align="left" valign="top"><p>How can I use IPC, or why do I get a <code class="literal">Bad system call</code>
error?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
Try running cygserver.  Read 
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/using-cygserver.html" target="_top">https://cygwin.com/cygwin-ug-net/using-cygserver.html</a>. If you're
trying to use PostgreSQL, also read 
<code class="literal">/usr/share/doc/Cygwin/postgresql-*.README</code>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.winmain"></a><p><b>6.11.</b></p></td><td align="left" valign="top"><p>Why the undefined reference to <code class="literal">WinMain@16</code>?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you're using <code class="literal">gcc</code>, try adding an empty main() function to one
of your sources.  Or, perhaps you have <code class="literal">-lm</code> too early in the
link command line.  It should be at the end:
</p><pre class="screen">
    bash$ gcc hello.c -lm
    bash$ ./a.exe
    Hello World!
</pre><p>works, but
</p><pre class="screen">
    bash$  gcc -lm hello.c
    /c/TEMP/ccjLEGlU.o(.text+0x10):hello.c: multiple definition of `main'
    /usr/lib/libm.a(libcmain.o)(.text+0x0):libcmain.c: first defined here
    /usr/lib/libm.a(libcmain.o)(.text+0x6a):libcmain.c: undefined reference to `WinMain@16'
    collect2: ld returned 1 exit status
</pre><p>If you're using GCJ, you need to pass a "--main" flag:
</p><pre class="screen">
gcj --main=Hello Hello.java
</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.win32-api"></a><p><b>6.12.</b></p></td><td align="left" valign="top"><p>How do I use Windows API calls?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Cygwin tools require that you explicitly link the import libraries
for whatever Windows API functions that you are going to use, with the exception
of kernel32, which is linked automatically (because the startup and/or
built-in code uses it).
</p><p>For example, to use graphics functions (GDI) you must link
with gdi32 like this:
</p><p>gcc -o foo.exe foo.o bar.o -lgdi32
</p><p>or (compiling and linking in one step):
</p><p>gcc -o foo.exe foo.c bar.c -lgdi32
</p><p>The regular setup allows you to use the option -mwindows on the
command line to include a set of the basic libraries (and also
make your program a GUI program instead of a console program),
including user32, gdi32 and comdlg32.
</p><p>It is a good idea to put import libraries last on your link line,
or at least after all the object files and static libraries that reference them.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>There are a few restrictions for calls to the Windows API.
For details, see the User's Guide section
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/setup-env.html#setup-env-win32" target="_top">Restricted Win32 environment</a>,
as well as the User's Guide section
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/using.html#pathnames-win32-api" target="_top">Using the Win32 file API in Cygwin applications</a>.</p></div></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.win32-no-cygwin"></a><p><b>6.13.</b></p></td><td align="left" valign="top"><p>How do I compile a Windows executable that doesn't use Cygwin?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The compilers provided by the <code class="literal">mingw64-i686-gcc</code> and
<code class="literal">mingw64-x86_64-gcc</code> packages link against standard Microsoft
DLLs instead of Cygwin. This is desirable for native Windows programs that
don't need a UNIX emulation layer.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.static-linking"></a><p><b>6.14.</b></p></td><td align="left" valign="top"><p>Can I build a Cygwin program that does not require cygwin1.dll at runtime?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>No.  If your program uses the Cygwin API, then your executable cannot
run without cygwin1.dll.  In particular, it is not possible to
statically link with a Cygwin library to obtain an independent,
self-contained executable.
</p><p>If this is an issue because you intend to distribute your Cygwin
application, then you had better read and understand
<a class="ulink" href="https://cygwin.com/licensing.html" target="_top">https://cygwin.com/licensing.html</a>, which explains the
licensing options.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.msvcrt-and-cygwin"></a><p><b>6.15.</b></p></td><td align="left" valign="top"><p>Can I link with both MSVCRT*.DLL and cygwin1.dll?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>No, you must use one or the other, they are mutually exclusive.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.no-console-window"></a><p><b>6.16.</b></p></td><td align="left" valign="top"><p>How do I make the console window go away?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The default during compilation is to produce a console application.
It you are writing a GUI program, you should either compile with
-mwindows as explained above, or add the string
"-Wl,--subsystem,windows" to the GCC command line.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.make-spaces"></a><p><b>6.17.</b></p></td><td align="left" valign="top"><p>Why does make complain about a "missing separator"?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>This problem usually occurs as a result of someone editing a Makefile
with a text editor that replaces tab characters with spaces.  Command
lines must start with tabs.  This is not specific to Cygwin.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.win32-headers"></a><p><b>6.18.</b></p></td><td align="left" valign="top"><p>Why can't we redistribute Microsoft's Windows API headers?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Subsection 2.d.f of the `Microsoft Open Tools License agreement' looks
like it says that one may not "permit further redistribution of the
Redistributables to their end users".  We take this to mean that we can
give them to you, but you can't give them to anyone else, which is
something that we can't agree to.  Fortunately, we
have our own Windows API headers which are pretty complete.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.msvs-mingw"></a><p><b>6.19.</b></p></td><td align="left" valign="top"><p>How do I use <code class="literal">cygwin1.dll</code> with Visual Studio or Mingw-w64?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you want to load the DLL dynamically, read
<code class="literal">winsup/cygwin/how-cygtls-works.txt</code> and the sample code in
<code class="literal">winsup/testsuite/cygload</code> to understand how this works.
The short version is:
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Make sure you have 4K of scratch space at the bottom of your stack.
</p></li><li class="listitem"><p>Invoke <code class="literal">cygwin_dll_init()</code>:
</p><pre class="screen">
HMODULE h = LoadLibrary("cygwin1.dll");
void (*init)() = GetProcAddress(h, "cygwin_dll_init");
init();
</pre><p>
</p></li></ol></div><p>If you want to link statically from Visual Studio, to my knowledge
none of the Cygwin developers have done this, but we have this report
from the mailing list that it can be done this way:
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Use the impdef program to generate a .def file for the cygwin1.dll
(if you build the cygwin dll from source, you will already have a def
file)
</p><pre class="screen">
impdef cygwin1.dll &gt; cygwin1.def
</pre></li><li class="listitem"><p>Use the MS VS linker (lib) to generate an import library
</p><pre class="screen">
lib /def=cygwin1.def /out=cygwin1.lib
</pre></li><li class="listitem"><p>Create a file "my_crt0.c" with the following contents
</p><pre class="screen">
#include &lt;sys/cygwin.h&gt;
#include &lt;stdlib.h&gt;

typedef int (*MainFunc) (int argc, char *argv[], char **env);

void
  my_crt0 (MainFunc f)
  {
    cygwin_crt0(f);
  }
</pre></li><li class="listitem"><p>Use gcc in a Cygwin prompt to build my_crt0.c into a DLL
       (e.g. my_crt0.dll). Follow steps 1 and 2 to generate .def and
       .lib files for the DLL.
</p></li><li class="listitem"><p>Download crt0.c from the cygwin website and include it in
       your sources. Modify it to call my_crt0() instead of
       cygwin_crt0().  
</p></li><li class="listitem"><p>Build your object files using the MS VC compiler cl.
</p></li><li class="listitem"><p>Link your object files, cygwin1.lib, and my_crt0.lib (or
       whatever you called it) into the executable.
</p></li></ol></div><p>Note that if you are using any other Cygwin based libraries
that you will probably need to build them as DLLs using gcc and
then generate import libraries for the MS VC linker.
</p><p>Thanks to Alastair Growcott (alastair dot growcott at bakbone dot co
dot uk) for this tip.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.linking-lib"></a><p><b>6.20.</b></p></td><td align="left" valign="top"><p>How do I link against a <code class="literal">.lib</code> file?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If your <code class="literal">.lib</code> file is a normal static or import library with
C-callable entry points, you can list <code class="literal">foo.lib</code> as an object file for
gcc/g++, just like any <code class="literal">*.o</code> file. Otherwise, here are some steps:
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Build a C file with a function table.  Put all functions you intend
to use in that table.  This forces the linker to include all the object
files from the .lib.  Maybe there is an option to force LINK.EXE to
include an object file.
</p></li><li class="listitem"><p>Build a dummy 'LibMain'.
</p></li><li class="listitem"><p>Build a .def with all the exports you need.
</p></li><li class="listitem"><p>Link with your .lib using link.exe.
</p></li></ol></div><p>or
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Extract all the object files from the .lib using LIB.EXE.
</p></li><li class="listitem"><p>Build a dummy C file referencing all the functions you need, either
      with a direct call or through an initialized function pointer.
</p></li><li class="listitem"><p>Build a dummy LibMain.
</p></li><li class="listitem"><p>Link all the objects with this file+LibMain.
</p></li><li class="listitem"><p>Write a .def.
</p></li><li class="listitem"><p>Link.
</p></li></ol></div><p>You can use these methods to use MSVC (and many other runtime libs)
with Cygwin development tools.
</p><p>Note that this is a lot of work (half a day or so), but much less than
rewriting the runtime library in question from specs...
</p><p>Thanks to Jacob Navia (root at jacob dot remcomp dot fr) for this explanation.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.building-cygwin"></a><p><b>6.21.</b></p></td><td align="left" valign="top"><p>How do I build Cygwin on my own?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>First, you need to make sure you have the necessary build tools
installed; you at least need <code class="literal">autoconf</code>,
<code class="literal">automake</code>, <code class="literal">cocom</code>,
<code class="literal">gcc-g++</code>, <code class="literal">git</code>,
<code class="literal">libtool</code>, <code class="literal">make</code>,
<code class="literal">patch</code>, and <code class="literal">perl</code>.
</p><p>
Additionally, building the <code class="code">dumper</code> utility requires
<code class="literal">gettext-devel</code>, <code class="literal">libiconv</code>,
<code class="literal">libiconv-devel</code>, <code class="literal">libiconv2</code>,
<code class="literal">libzstd-devel</code>, and <code class="literal">zlib-devel</code>.
</p><p>
Building those Cygwin utilities which are not themselves Cygwin programs
(e.g. <code class="code">cygcheck</code> and <code class="code">strace</code>) also requires
<code class="literal">mingw64-x86_64-gcc-g++</code> and <code class="literal">mingw64-x86_64-zlib</code>.
Building these programs can be disabled with the <code class="literal">--without-cross-bootstrap</code>
option to <code class="literal">configure</code>.
</p><p>
Building the documentation also requires the <code class="literal">dblatex</code>,
<code class="literal">docbook-utils</code>, <code class="literal">docbook-xml45</code>,
<code class="literal">docbook-xsl</code>, <code class="literal">docbook2X</code>,
<code class="literal">perl-XML-SAX-Expat</code>, and <code class="literal">xmlto</code>
packages. Building the documentation can be disabled with the
<code class="literal">--disable-doc</code> option to <code class="literal">configure</code>.
</p><p>
Below are ready-made commands to download the required
packages. When you reach the <span class="emphasis"><em>Select Packages</em></span> screen,
these packages should be amongst the search results.
</p><pre class="screen">
$ setup-x86_64.exe -P autoconf,automake,cocom,gcc-g++,git,libtool,make,patch,perl                           # download build tool packages
$ setup-x86_64.exe -P gettext-devel,libiconv,libiconv-devel,libiconv2,libzstd-devel,zlib-devel              # download dumper packages
$ setup-x86_64.exe -P mingw64-x86_64-gcc-g++,mingw64-x86_64-zlib                                            # download utility packages
$ setup-x86_64.exe -P dblatex,docbook-utils,docbook-xml45,docbook-xsl,docbook2X,perl-XML-SAX-Expat,xmlto    # download documentation packages
</pre><p>Next, check out the Cygwin sources from the
<a class="ulink" href="https://cygwin.com/git.html" target="_top">Cygwin GIT source repository</a>.
This is the <span class="emphasis"><em>preferred method</em></span> for acquiring the sources.
Otherwise, if you are trying to duplicate a cygwin release then you should
download the corresponding source package
(<code class="literal">cygwin-x.y.z-n-src.tar.bz2</code>). </p><p>You <span class="emphasis"><em>must</em></span> build cygwin in a separate directory from
the source, so create something like a <code class="literal">build/</code> directory.
Assuming you checked out the source to
<code class="literal">/oss/src/newlib-cygwin/</code>, and you want to install to the
temporary location <code class="literal">/oss/install/</code>, these are the required
steps to build Cygwin:
</p><pre class="screen">
$ mkdir -p /oss/src/newlib-cygwin/build    # create build dir
$ mkdir -p /oss/install                    # create install dir
$ cd /oss/src/newlib-cygwin/winsup         # chdir into Cygwin source dir and...
$ ./autogen.sh                             # create config files
$ cd /oss/src/newlib-cygwin/build          # chdir into build dir
$                                          # create makefiles...
$ /oss/src/newlib-cygwin/configure --prefix=/oss/install
$ make                                     # build Cygwin
$ make install                             # install Cygwin into install dir
</pre><p>
If the build worked, you can install everything you like into the currently
running system, <span class="emphasis"><em>except</em></span> the Cygwin DLL
<span class="command"><strong>cygwin1.dll</strong></span> itself.  For installing the DLL, close down
all Cygwin programs (including bash windows, any servers like
<span class="command"><strong>cygserver</strong></span>, etc.), save your old dll, and copy the new dll
to the correct place.  Then, for first testing, start up a Cygwin program
from the Windows command prompt and see what happens.
</p><p>If you get a lengthy error messages like
<code class="literal">"user shared memory version mismatch detected"</code>, it's
very likely a Cygwin process still running using the old DLL.  Kill it
in Windows' Task Manager or <span class="command"><strong>taskkill</strong></span> and try again.
If it's still not working, and if you're sure there's no older Cygwin
process still running, it's probably a bug you introduced with your changes.
From here on, you're on your own or discuss problems on the
<a class="ulink" href="https://cygwin.com/lists.html" target="_top">Cygwin-developers mailing list</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.debugging-cygwin"></a><p><b>6.22.</b></p></td><td align="left" valign="top"><p>I may have found a bug in Cygwin, how can I debug it (the symbols in gdb look funny)?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Debugging symbols are stripped from distibuted Cygwin binaries, so to
debug with <span class="command"><strong>gdb</strong></span> you will need to install the
<span class="package">cygwin-debuginfo</span> package to obtain the debug symbols for
<code class="filename">cygwin1.dll</code>
</p><p>
If your bug causes an exception inside <code class="filename">cygwin1.dll</code> you will
need to use the <span class="command"><strong>gdb</strong></span> command <strong class="userinput"><code>set cygwin-exceptions
on</code></strong> to tell <span class="command"><strong>gdb</strong></span> to stop on exceptions inside the
Cygwin DLL (by default they are ignored, as they may be generated during normal
operation e.g. when checking a pointer is valid)
</p><p>
It is also a good idea to use the latest code in case the bug has been fixed,
so we recommend trying the latest cygwin test release (see
<a class="xref" href="faq.html#faq.setup.testrels" title="2.21.">Install Test Releases</a>) or building the DLL from git.
</p><p>To build a debugging version of the Cygwin DLL, you will need to follow
the instructions at <a class="xref" href="faq.html#faq.programming.building-cygwin" title="6.21.">Build Cygwin</a>.
</p><p>
You can also contact the mailing list for pointers (a simple test case that 
demonstrates the bug is always welcome).  
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.compiling-unsupported"></a><p><b>6.23.</b></p></td><td align="left" valign="top"><p>How can I compile Cygwin for an unsupported platform (PowerPC, Alpha, ARM, Itanium)?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Unfortunately, this will be difficult.  Exception handling and signals
support semantics and args have been designed for x86_64 so you would need
to write specific support for your platform.  We don't know of any other
incompatibilities. Please send us patches if you do this work!
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.adjusting-heap"></a><p><b>6.24.</b></p></td><td align="left" valign="top"><p>How can I adjust the heap/stack size of an application?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you need to change the maximum amount of memory available to Cygwin, see
<a class="ulink" href="https://cygwin.com/cygwin-ug-net/setup-maxmem.html" target="_top">https://cygwin.com/cygwin-ug-net/setup-maxmem.html</a>. Otherwise,
just pass heap/stack linker arguments to gcc.  To create foo.exe with
a heap size of 200MB and a stack size of 8MB, you would invoke
gcc as:
</p><p><code class="literal">gcc -Wl,--heap,200000000,--stack,8000000 -o foo foo.c</code>
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.dll-cygcheck"></a><p><b>6.25.</b></p></td><td align="left" valign="top"><p>How can I find out which DLLs are needed by an executable?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p><code class="literal">objdump -p</code> provides this information, but is rather verbose.
</p><p><code class="literal">cygcheck</code> will do this much more concisely, and operates
recursively, provided the command is in your path.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.dll-building"></a><p><b>6.26.</b></p></td><td align="left" valign="top"><p>How do I build a DLL?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>There's documentation that explains the process in the Cygwin User's
Guide here: <a class="ulink" href="https://cygwin.com/cygwin-ug-net/dll.html" target="_top">https://cygwin.com/cygwin-ug-net/dll.html</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.breakpoint"></a><p><b>6.27.</b></p></td><td align="left" valign="top"><p>How can I set a breakpoint at mainCRTStartup?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
  Set a breakpoint in <span class="command"><strong>gdb</strong></span> with <span class="command"><strong>b *0x401000</strong></span>
  (for i686), or <span class="command"><strong>b *0x100401000</strong></span> (for x86_64).
</p><p>
  This entrypoint address can be computed as the sum of the ImageBase and
  AddressOfEntryPoint values given by <span class="command"><strong>objdump -p</strong></span>.
</p><p>
  Note that the DllMain entrypoints for linked DLLs will have been executed
  before this breakpoint is hit.
</p><p>
  (It may be necessary to use the <span class="command"><strong>gdb</strong></span> command <span class="command"><strong>set
  disable-randomization on</strong></span> to turn off ASLR for the debuggee to
  prevent the base address getting randomized.)
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.debug"></a><p><b>6.28.</b></p></td><td align="left" valign="top"><p>How can I debug what's going on?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>You can debug your application using <code class="literal">gdb</code>.  Make sure you
compile it with the -g flag!  If your application calls functions in
MS DLLs, gdb will complain about not being able to load debug information
for them when you run your program.  This is normal since these DLLs
don't contain debugging information (and even if they did, that debug
info would not be compatible with gdb).
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.system-trace"></a><p><b>6.29.</b></p></td><td align="left" valign="top"><p>Can I use a system trace mechanism instead?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes.  You can use the <code class="literal">strace.exe</code> utility to run other cygwin
programs with various debug and trace messages enabled.  For information
on using <code class="literal">strace</code>, see the Cygwin User's Guide.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.gdb-signals"></a><p><b>6.30.</b></p></td><td align="left" valign="top"><p>How does gdb handle signals?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
gdb maps known Windows exceptions to signals such as SIGSEGV, SIGFPE, SIGTRAP,
SIGINT and SIGILL.  Other Windows exceptions are passed on to the handler (if
any), and reported as an unknown signal if an unhandled (second chance)
exception occurs.
</p><p>
There is also an experimental feature to notify gdb of purely Cygwin signals
like SIGABRT, SIGHUP or SIGUSR1.  This currently has some known problems, for
example, single-stepping from these signals may not work as expected.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.linker"></a><p><b>6.31.</b></p></td><td align="left" valign="top"><p>The linker complains that it can't find something.</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>A common error is to put the library on the command line before
the thing that needs things from it.
</p><p>This is wrong <code class="literal">gcc -lstdc++ hello.cc</code>.
This is right <code class="literal">gcc hello.cc -lstdc++</code>.
</p><p>
  The first command above (usually) works on Linux, because:
  </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; "><li class="listitem" style="list-style-type: disc">A DT_NEEDED tag for libstdc++ is added when the library name is seen.</li><li class="listitem" style="list-style-type: disc">The executable has unresolved symbols, which can be found in libstdc++.</li><li class="listitem" style="list-style-type: disc">When executed, the ELF loader resolves those symbols.</li></ul></div><p>
</p><p>
  Note that this won't work if the linker flags <code class="literal">--as-needed</code>
  or <code class="literal">--no-undefined</code> are used, or if the library being linked
  with is a static library.
</p><p>
  PE/COFF executables work very differently, and the dynamic library which
  provides a symbol must be fully resolved <span class="emphasis"><em>at link time</em></span>
  (so the library which provides a symbol must follow a reference to it).
</p><p>
  See point 3 in <a class="xref" href="faq.html#faq.programming.unix-gui" title="6.40.">Q: 6.40</a> for more
  discussion of how this affects plugins.
</p><p>
  This also has consequences for how weak symbols are resolved. See <a class="ulink" href="https://cygwin.com/ml/cygwin/2010-04/msg00281.html" target="_top">https://cygwin.com/ml/cygwin/2010-04/msg00281.html</a> for more
  discussion of that.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.stat64"></a><p><b>6.32.</b></p></td><td align="left" valign="top"><p>Why do I get an error using <code class="literal">struct stat64</code>?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p><code class="literal">struct stat64</code> is not used in Cygwin, just
use <code class="literal">struct stat</code>.  It's 64 bit aware.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.libc"></a><p><b>6.33.</b></p></td><td align="left" valign="top"><p>Can you make DLLs that are linked against libc ?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.malloc-h"></a><p><b>6.34.</b></p></td><td align="left" valign="top"><p>Where is malloc.h?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>It exists, but you should rather include stdlib.h instead of malloc.h.
stdlib.h is POSIX standard for defining malloc and friends, malloc.h is
definitely non-standard.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.own-malloc"></a><p><b>6.35.</b></p></td><td align="left" valign="top"><p>Can I use my own malloc?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you define a function called <code class="literal">malloc</code> in your own code, and link
with the DLL, the DLL <span class="emphasis"><em>will</em></span> call your <code class="literal">malloc</code>.  Needless to
say, you will run into serious problems if your malloc is buggy.
</p><p>If you run any programs from the DOS command prompt, rather than from in
bash, the DLL will try and expand the wildcards on the command line.
This process uses <code class="literal">malloc</code> <span class="emphasis"><em>before</em></span> your main line is started.
If you have written your own <code class="literal">malloc</code> to need some initialization
to occur after <code class="literal">main</code> is called, then this will surely break.
</p><p>Moreover, there is an outstanding issue with <code class="literal">_malloc_r</code> in
<code class="literal">newlib</code>.  This re-entrant version of <code class="literal">malloc</code> will be called
directly from within <code class="literal">newlib</code>, by-passing your custom version, and
is probably incompatible with it.  But it may not be possible to replace
<code class="literal">_malloc_r</code> too, because <code class="literal">cygwin1.dll</code> does not export it and
Cygwin does not expect your program to replace it.  This is really a
newlib issue, but we are open to suggestions on how to deal with it.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.msvc-gcc-objects"></a><p><b>6.36.</b></p></td><td align="left" valign="top"><p>Can I mix objects compiled with msvc++ and gcc?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes, but only if you are combining C object files.  MSVC C++ uses a
different mangling scheme than GNU C++, so you will have difficulties
combining C++ objects.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.gdb-msvc"></a><p><b>6.37.</b></p></td><td align="left" valign="top"><p>Can I use the gdb debugger to debug programs built by VC++?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>No, not for full (high level source language) debugging.
The Microsoft compilers generate a different type of debugging
symbol information, which gdb does not understand.
</p><p>However, the low-level (assembly-type) symbols generated by
Microsoft compilers are coff, which gdb DOES understand.
Therefore you should at least be able to see all of your
global symbols; you just won't have any information about
data types, line numbers, local variables etc.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.make-scripts"></a><p><b>6.38.</b></p></td><td align="left" valign="top"><p>Shell scripts aren't running properly from my makefiles?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If your scripts are in the current directory, you must have <code class="literal">.</code>
(dot) in your $PATH.  (It is not normally there by default.)  Better yet,
add /bin/sh in front of each and every shell script invoked in your Makefiles.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.preprocessor"></a><p><b>6.39.</b></p></td><td align="left" valign="top"><p>What preprocessor macros do I need to know about?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>gcc for Cygwin defines __CYGWIN__ when building for a Cygwin
environment.
</p><p>Microsoft defines the preprocessor symbol _WIN32 in their Windows
development environment.
</p><p>In gcc for Cygwin, _WIN32 is only defined when you use the -mwin32
gcc command line options.  This is because Cygwin is supposed to be a
POSIX emulation environment in the first place and defining _WIN32 confuses
some programs which think that they have to make special concessions for
a Windows environment which Cygwin handles automatically.
</p><p>Check out the predefined symbols in detail by running, for example
</p><pre class="screen">
       $ gcc  -dM -E -xc /dev/null &gt;gcc.txt
       $ gcc -mwin32 -dM -E -xc /dev/null &gt;gcc-mwin32.txt
</pre><p>Then use the diff and grep utilities to check what the difference is.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.programming.unix-gui"></a><p><b>6.40.</b></p></td><td align="left" valign="top"><p>How should I port my Unix GUI to Windows?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Like other Unix-like platforms, the Cygwin distribution includes many of
the common GUI toolkits, including X11, X Athena widgets, Motif, Tk, GTK+,
and Qt. Many programs which rely on these toolkits will work with little, if
any, porting work if they are otherwise portable.  However, there are a few
things to look out for:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Some packages written for both Windows and X11 incorrectly
treat Cygwin as a Windows platform rather than a Unix variant.  Mixing Cygwin's
Unix APIs with Windows' GDI is best avoided; rather, remove these assumptions
so that Cygwin is treated like other X11 platforms.</p></li><li class="listitem"><p>GTK+ programs which use <code class="literal">gtk_builder_connect_signals()</code>
or <code class="literal">glade_xml_signal_autoconnect()</code> need to be able to
<code class="literal">dlopen()</code> themselves.  In order for this to work, the program
must be linked with the <code class="literal">-Wl,--export-all-symbols</code> linker flag.
This can be added to LDFLAGS manually, or handled automatically with the
<code class="literal">-export-dynamic</code> libtool flag (requires libtool 2.2.8) or
by adding <code class="literal">gmodule-export-2.0</code> to the pkg-config modules used
to build the package.</p></li><li class="listitem"><p>Programs which include their own loadable modules (plugins)
often must have its modules linked against the symbols in the program.  The
most portable solution is for such programs to provide all its symbols (except
for <code class="literal">main()</code>) in a shared library, against which the plugins
can be linked.  Otherwise, the symbols from the executable itself must be
exported.</p><p>If the package uses the CMake build system, this can be done by adding
<code class="literal">ENABLE_EXPORTS TRUE</code> to the executable's <code class="literal">set_target_properties</code>
command, then adding the executable's target name to the <code class="literal">target_link_libraries</code>
command for the plugins.</p><p>For other build systems, the following steps are required:</p><div class="orderedlist"><ol class="orderedlist" type="a"><li class="listitem"><p>The executable must be built before its plugins.</p></li><li class="listitem"><p>Symbols must be exported from the executable with a
<code class="literal">-Wl,--export-all-symbols,--out-implib,libfoo.exe.a</code>
linker flag, where <code class="literal">foo</code> represents the name of the
executable.</p></li><li class="listitem"><p>The plugins must be linked with a <code class="literal">-Wl,/path/to/libfoo.exe.a</code>
linker flag.</p></li></ol></div></li></ol></div></td></tr><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="faq.copyright"></a>7. Copyright</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>7.1. <a href="faq.html#faq.what.copyright">What are the copyrights?</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="faq.what.copyright"></a><p><b>7.1.</b></p></td><td align="left" valign="top"><p>What are the copyrights?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Please see <a class="ulink" href="https://cygwin.com/licensing.html" target="_top">https://cygwin.com/licensing.html</a>
      for more information about Cygwin copyright and licensing.</p></td></tr></tbody></table></div></div><div class="navfooter"><hr></div>