install and use GCC in windows 7 x64 - gcc

I am new to GCC, don't know much about it. I want to install it on my Windows 7 64bit PC and use it for C, C++ and Java. The latest version is GCC-4.8.0. In their mirror links, I am getting option to download gcc 4.8.0.tar.bz2 and gcc 4.8.0.tar.gz and md5.sum. Please guide me, how should i proceed, to use GCC

On Windows, easiest way to get gcc is to install MinGW.
Most recent MinGW release has support for gcc 4.8 as well - but it may be not very stable at the moment.

These files are source archive files of the latest released GCC compiler.
As a newbie, you probably want a binary distribution, e.g. mingw or cygwin on Windows. (Then you might get an earlier version of GCC. 4.8 has just been released)
Alternatively, consider switching to Linux and install it on your machine. It will teach you a big lot (and almost all of Linux is free software so you can get its source code and study it).
Using Linux and GCC also gives you a significant advantage: you could use GCC plugins, e.g. develop your own MELT extension (MELT is a domain specific language to extend GCC, implemented as a [meta-]plugin). Neither Mingw nor Cygwin support GCC plugins.
PS. compiling GCC from source code is not easy for a newbie.

this is an older question but this was harder to search for than it should have been so I will post it here, http://gcc.gnu.org/wiki/WindowsBuilding is a quick guide to getting gcc4.8 running on windows. I am about to dive in to building it on my old windows-xp box. wish me luck.

I use codeblocks . You can follow this Youtube video for instructions:). Hope it helps!
http://www.youtube.com/watch?v=nNeySMSW8qU

You should really check out Code::Blocks (http://codeblocks.org/).
It's a good IDE which is easily set up to get you started.
To support Windows 64-bit though you should not use the MinGW compiler that comes with it. Instead get a separate binary of MinGW-w64 with 64-bit support.
You can get it from http://winlibs.com where you can also find tips on how to configure both Windows 32-bit and 64-bit compilers.

Related

Clang or GCC compiler for c++ 11 compatibility programming on Windows?

I was wondering which compiler is better to use on Windows OS (8.1) in temrs of compatibility to c++11's (and later 14) functions, liberies and features (like lambdas) and is also comfortable to use (less bugs).
I am a university student hence I'm not looking at the subject product-wise (even though I do like to code a bit more than just projects for my studies).
I am currently using eclipse luna IDE if it matters.
Notice that compiler != IDE.
VC++ is one of the most populars on Windows and depending on its version it has a good support for C++11 features. Check the list on the msdn blog to find out if there's everything you need.
Gcc is also ported to Windows and you can install MinGW to use it (4.8.1.4 at the moment of writing this). It is pretty complete on C++11.
Clang is also available for the Windows platform and it is also complete on C++11 support (plus it has good diagnostic messages), but notice that you will have to use another linker since clang doesn't ship with one (although there is an ongoing effort to write it: http://lld.llvm.org/)
All the compilers I cited above are pretty stable but, based on my experience, if you're looking for latest and greatest C++11/14/17 features, you might just want to go for gcc or clang (VC++ is slower in adding support for newest features and the compiler is undergoing a huge update to modernize). Just keep in mind that these are compilers and not just IDEs, an IDE is a front-end supporting program that uses a compiler undercover to compile files.
To set up a C++11 compiler, I suggest installing MSYS2, it has a package manager (pacman) that can install fresh versions of GCC, GDB, Clang and many libraries like SDL, Lua etc. Very easy to use too.
As far as GCC vs CLang goes - I really tried hard to make CLang work (which is presumably faster and more friendly than GCC - produces better warnings, etc.), but failed. Issues were that CLang (which comes with MSYS2) is hard-coded to use GCC linker which produces some strange linker errors when using libstdc++ (std implementation from GCC). libc++ (a new implementation designed to work with CLang) didn't worked for me on Windows either.
So you either try build CLang from sources and hope that some configuration will work with C++11 library, OR just stick with GCC which works just fine out of the box.
As IDE, I suggest to take a look at CLion. It is very comfortable (infinitely more user-friendly and intuitive than Visual Studio, IMO). Just install it and point it to the mingw64 (or mingw32) folder of MSYS2, it will auto-detect everything for you.
It only works with CMake projects though.

How to get Cuda to use gcc 4.6

I am trying to install Cuda on my machine and as usual it causes problem with gcc 4.7 when trying to run the installer.
I have now installed gcc 4-6 which should work and I am now thinking about the best way to install CUDA.
I have thought about creating a symlink to gcc-4.6 so that the installer uses version 4.6 instead of 4.7.
Do you have any suggestions to do that or is there a better solution? It feels a bit stupid erase 4.7 from the machine in order to use cuda.
Thanks in advance!
/ Erik
Another solution to your problem is to download CUDA 5.5, which works with gcc 4.7. It is currently only available to CUDA registered developers: link to forum announcement
Create alternatives so that you can switch between versions at any time check out this helpful page:
How to change the default GCC compiler in Ubuntu?

How do I compile a crosscompiler targeting Linux x64 on a Windows host?

I am planning on harvesting my gaming HTPCs spare cycles for compiling my software using distcc, but I will need to set up a cross compiler. The problem is that Google is sadly lacking in relevant information.
I think Cygwin is the purest form of evil, but is the easiest way of doing what you want.
You will just have to install the correct version of gcc from the cygwin installer.
This website has the answer here

installing gcc on vista

I downloaded gcc 4.4.0 and unzipped it to C:\Program Files\gcc
forgive me for being a novice, but...now what? I read the install readme file but it's over my head. how do i get it to work?
If it were me, I would just start with cygwin in the first place. If you do, most of the Unix/Linux/BSD faq's and tutorials will "just work".
If you're new to gcc and want to start using it on Windows, I highly recommend the MinGW GUI installer.
If you want to do C/C++ programming for fun, Mingw is the simpler way to go about it. You'll also need some libraries to get you started.
Try: http://nuwen.net/mingw.html
It's a Mingw distribution based on GCC 4.3.3
It also contains: binutils, boost (with compiled headers), SDL, libbzip, libjpeg, libvorbis, freetype, and many other libraries.
EDIT: I'm not sure if any of the precompiled stuff will work on Vista. I've only tried it on WinXP.
If you want to Install, you can install Dev C++, which is actually MinGW with GUI. Dev C++ can probably be clubbed wth cygwin too though I havn't tried it out ever.
Even if the name says C++ in Dev C++, don't worry. I have tried and it does compile C programs as well. I am recommending Dev C++ because most people on Windows have a habit of using GUI for everything in contrast to be people from *nix background.
You can download it from here
It also includes GDB which is the debugger you can use. If you are don't know how to use gdb this tutorial can come handy.
Another aspect of Dev C++ is that it's development has probably ceased as no new versions have been released since Feb,2005 which is more than 4 years. People still use Dev C++ as it does it's job right. The latest version has GCC 3.4.2 bundled with it.
If you are interested in running the most latest or using newer versions of gcc, then you should try out wxDev C++ is an extension of Dev C++. The latest RC was made available somewhere in 1 yr back. It even has in built CVS support
Now since you require GCC 4.4.0 , it is available on MinGW site. Try to replace the older gcc dll in Dev C++/wxDev C++ with the newer one from this site.
You will edit the environment variable "PATH" to include C:\Program Files\gcc\bin.
(source: justrealized.com)
Then you can use gcc just like in Linux.

Is it possible to use GCC without Cygwin or MinGW?

GCC is a very well respected multi-language compiler (from what I've gathered). One thing I've not been able to definitively find out is: Is it possible to use GCC on windows without anything extra like Cygwin or MinGW?
I've learned that if you use GCC on Cygwin, there is a dependency on a DLL. If you use GCC with MinGW, you eliminate that dependency but you still must have MinGW to use GCC.
Is it possible to build GCC and utilize it by itself, completely native to Windows? Like Microsoft's Compiler? After reading around, my guess is no. But I'd still like more info, if possible.
If not, why does GCC require environments like Cygwin or MinGW? I understand this now. It is because GCC requires a Unix/POSIX environment. Why it does, it still beyond me.
I did find this and it helps but doesn't really answer my question: Why does GCC-Windows depend on cygwin?
To refine my question, I guess what I'm trying to understand why GCC can't stand on it's own -- Where I have just "GCC.exe".
For MinGW, you need MinGW in the sense that MinGW provides the implementation of the gcc language system. I don't see how your question makes sense - it's like "Can I use VC++ without installing VC++?"
To clarify: MinGW is the GCC compiler executable(s), headers and support objects. There isn't anything else. There is a related but independant package called MSYS which provides some posix utilities, but you do not need this in any way in order to use the MinGW version of GCC.
What is exactly the problem with mingw? And what is native?
mingw used to generate pretty much standalone binaries, and maybe that is even more native than MSVC's, which require msvcrt, a component that needs to be installed sometimes.
So maybe you could explain what you tried with mingw, and what the exact problem is.
To disable mingw's extra dependency simply don't use exceptions (-fno-exceptions), I haven't used cygwin so not sure.
I don't think so. I've had to compile some command line apps for people in the past and always had to use cygwin.
I think the biggest reason being posix compatibility, which is what cygwin strives to bring to Win32.
Linaro used to provide that long time ago, a GCC that runs naively on Windows without MinGW or Cygwin. I am currently using that GCC 4.9 on a Windows 10 PC to compile UEFI and it is working like charm.
https://releases.linaro.org/archive/14.09/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.9-2014.09_win32.zip
simply install wsl on your computer.

Resources