PDF download Download Article PDF download Download Article

This wikiHow teaches you how to compile your C program in Windows and macOS. If you're using Linux, check out How to Compile a C Program Using the GNU Compiler .

Method 1
Method 1 of 3:

Using Cygwin for Windows

PDF download Download Article
  1. Go to https://cygwin.com/install.html . Cygwin is a free Windows tool that allows you to use the GCC C compiler from a Unix command line.
  2. If you're using the 64-bit version of Windows, download setup-x86_64.exe . If you have the 32-bit version, download setup-x86.exe .
    Advertisement
  3. Double-click the downloaded file to open the setup wizard. Downloaded files usually save to the Downloads folder.
    • If prompted to give permission for the installer to run, click Yes .
  4. This is where packages you download will be saved.
  5. The installer will connect to the internet and then display a list of download sites.
  6. These sites all host the same files. This downloads the installation files to your computer.
    • If there's a problem with one site, try another on the list.
  7. Follow these steps to ensure the C compiler is installed:
    • Click the + next to "Devel" to expand the options.
    • Scroll down and click the down-arrow next to gcc core .
    • Click the most recent (highest) version number.
  8. It's at the bottom-right corner. A confirmation message will appear.
  9. Cygwin will now download all selected tools and install them on your computer. Follow the on-screen instructions to complete the installation.
  10. It'll be in the Start menu (called either Cygwin64 or Cygwin32 , depending on your version).
  11. You're looking for the file you coded with ".c" at the end. For example, if your code is located in your Documents folder, you would type cd c:\Users\(yourusername)\Documents and press Enter . [1]
    • A quick way to find the full path to your file: Press Win + E to open the File Explorer, go to the folder that contains your file, click the file once to select it, then click Copy Path at the top of the screen. Now you can right-click the Cygwin command line and select Paste .
  12. Replace "yourcode.c" with the name of the file, and "yourcode.exe" with the name of your program. [2] Your code is now compiled.
  13. Advertisement
Method 2
Method 2 of 3:

Using Visual Studio for Windows

PDF download Download Article
  1. This app is separate than the main Visual Studio app. To find it, click the Start menu, expand the Visual Studio 2017 folder, then click Developer Command Prompt for VS 2017 (or your version number). [3]
  2. You're looking for the file you coded with ".c" at the end. For example, if your code is located in your Documents folder, you would type cd c:\Users\(yourusername)\Documents and press Enter
    • Your code must be in a file that ends with the ".c" extension to use this method.
  3. Replace "yourcode.c" with the name of your file. This creates a file called yourcode.exe from your code file.
  4. Advertisement
Method 3
Method 3 of 3:

Using Xcode for macOS

PDF download Download Article
  1. [4]
  2. Now that it's installed, you'll find it in the Applications folder.
  3. The contents of your code will appear.
  4. It's at the top of the screen.
  5. This compiles and links your C code. When it's ready to be exported, a window containing options will appear.
  6. Xcode will create a new folder (inside the folder where your code is saved) and place the executable file inside.
  7. Advertisement

Expert Q&A

Ask a Question
      Advertisement

      Tips

      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!

      About This Article

      Thanks to all authors for creating a page that has been read 31,929 times.

      Is this article up to date?

      Advertisement