how to install gcc on windows 7 machine?

后端 未结 5 1400
星月不相逢
星月不相逢 2020-11-28 18:18

I have MinGW on my windows 7 machine. I wish to install and use complete gcc for C compiler. I found there is no single pre-compiled ready-made installation file for this pu

相关标签:
5条回答
  • 2020-11-28 18:50

    Download mingw-get and simply issue:

    mingw-get install gcc.
    

    See the Getting Started page.

    0 讨论(0)
  • 2020-11-28 18:50
    1. Extract the package to C:\ from here and install it

    2. Copy the path C:\MinGW\bin which contains gcc.exe.

    3. go to Control Panel->System->Advanced>Environment variables, and add or modify PATH. (just concatenate with ';')

    4. Then, open a cmd.exe command prompt (Windows + R and type cmd, if already opened, please close and open a new one, to get the path change)

    5. change the folder to your file path by cd D:\c code Path

    6. type gcc main.c -o helloworld.o. It will compile the code. for C++ use g++

    7 type ./helloworld to run the program.

    If zlib1.dll is missing, download from here

    0 讨论(0)
  • 2020-11-28 18:54

    Following up on Mat's answer (use Cygwin), here are some detailed instructions for : installing gcc on Windows The packages you want are gcc, gdb and make. Cygwin installer lets you install additional packages if you need them.

    0 讨论(0)
  • 2020-11-28 18:59

    I use msysgit to install gcc on Windows, it has a nice installer which installs most everything that you might need. Most devs will need more than just the compiler, e.g. the shell, shell tools, make, git, svn, etc. msysgit comes with all of that. https://msysgit.github.io/

    edit: I am now using msys2. Msys2 uses pacman from Arch Linux to install packages, and includes three environments, for building msys2 apps, 32-bit native apps, and 64-bit native apps. (You probably want to build 32-bit native apps.)

    https://msys2.github.io/

    You could also go full-monty and install code::blocks or some other gui editor that comes with a compiler. I prefer to use vim and make.

    0 讨论(0)
  • 2020-11-28 19:12

    EDIT Since not so recently by now, MinGW-w64 has "absorbed" one of the toolchain building projects. The downloads can be found here. The installer should work, and allow you to pick a version that you need.

    Note the Qt SDK comes with the same toolchain. So if you are developing in Qt and using the SDK, just use the toolchain it comes with.

    Another alternative that has up to date toolchains comes from... harhar... a Microsoft developer, none other than STL (Stephan T. Lavavej, isn't that a spot-on name for the maintainer of MSVC++ Standard Library!). You can find it here. It includes Boost.

    Another option which is highly useful if you care for prebuilt dependencies is MSYS2, which provides a Unix shell (a Cygwin fork modified to work better with Windows pathnames and such), also provides a GCC. It usually lags a bit behind, but that is compensated for by its good package management system and stability. They also provide a functional Clang with libc++ if you care for such thing.

    I leave the below for reference, but I strongly suggest against using MinGW.org, due to limitations detailed below. TDM-GCC (the MinGW-w64 version) provides some hacks that you may find useful in your specific situation, although I recommend using vanilla GCC at all times for maximum compatibility.


    GCC for Windows is provided by two projects currently. They both provide a very own implementation of the Windows SDK (headers and libraries) which is necessary because GCC does not work with Visual Studio files.

    1. The older mingw.org, which @Mat already pointed you to. They provide only a 32-bit compiler. See here for the downloads you need:

      • Binutils is the linker and resource compiler etc.
      • GCC is the compiler, and is split in core and language packages
      • GDB is the debugger.
      • runtime library is required only for mingw.org
      • You might need to download mingw32-make seperately.
      • For support, you can try (don't expect friendly replies) mingw-users@lists.sourceforge.net

      Alternatively, download mingw-get and use that.

    2. The newer mingw-w64, which as the name predicts, also provides a 64-bit variant, and in the future hopefully some ARM support. I use it and built toolchains with their CRT. Personal and auto builds are found under "Toolchains targetting Win32/64" here. They also provide Linux to Windows cross-compilers. I suggest you try a personal build first, they are more complete. Try mine (rubenvb) for GCC 4.6 to 4.8, or use sezero's for GCC 4.4 and 4.5. Both of us provide 32-bit and 64-bit native toolchains. These packages include everything listed above. I currently recommend the "MinGW-Builds" builds, as these are currently sanctioned as "official builds", and come with an installer (see above).

      For support, send an email to mingw-w64-public@lists.sourceforge.net or post on the forum via sourceforge.net.

    Both projects have their files listed on sourceforge, and all you have to do is either run the installer (in case of mingw.org) or download a suitable zipped package and extract it (in the case of mingw-w64).

    There are a lot of "non-official" toolchain builders, one of the most popular is TDM-GCC. They may use patches that break binary compatibility with official/unpatched toolchains, so be careful using them. It's best to use the official releases.

    0 讨论(0)
提交回复
热议问题