How to build GCC 4.7 on Windows? - windows

How to build GCC 4.7 on Windows?

You are not finding instructions on how to do this because you cannot natively use gcc in Windows. Your options are either to use gcc through Cygwin [installation instructions] or install the MinGW port [installation instructions].
You can also find links to these projects on the Installing GCC: Binaries page.

Well, gcc 4.7 has not yet been released (it will be released in a few months, i.e. spring 2012).
If your system is Windows then I am sorry for you, Linux is so much better :-) More seriously, you should search for cygwin gcc. I cannot help you in that case.
What did you try? Building GCC (even on Linux) is not an easy task. Some hints (which I guess are also relevant to cygwin & windows).
Always configure and build the compiler in a build tree outside of the source tree. (this is a common mistake).
take care of the many dependencies (and their versions), like the Parma Polyhedra Library, Cloog, etc ...
some features of GCC are not available on Windows. In particular plugins.
I would suppose that installing the binary of an older variant of cygwin gcc (and all the related packages) will help.
But really, I know nothing about Windows. And if you really want a very recent GCC and you cannot install Linux (or build GCC cygwin), you might perhaps consider running Linux in an emulator or virtual machine.

Related

Run or use GCC without install

Can I use GCC for e.g GCC4.0.3 without installation
In my macOS I have installed Clang xcode , and GCC from Homebrew
In my Linux they are installed as well
But I want to use GCC (Specially older version) besides most updated version
Like NVM that manage Node version and it lets you install many nodejs with different version on your system
I want to use GCC4 specially for science and compiling Old FORTRAN to make my Source codes run and see the results
In new OS both macOS and Linux when you install gcc it will install most updated and that is not useful for old fortran or old codes.
So In my solution i think its better to use gcc without install or even install gcc to custom directory folder and copy the codes in that directory and compile them but not to install as wide system and make incompatibility with default GCC and CLANG on system
Thanks in advance

how does compilation work exactly on os x

I just started getting into LLVM and clang compilers and the whole thing. I am following the book "Getting started with llvm core libraries". I was under the impression that OS X comes bundled with llvm. However it seems that is not the case. I need to install llvm separately to get command line tools like llc or lli.
So my question is, when I do a "clang" to compile my c/c++ code, what backend does the work of creating the machine code ? My installation shows commands like llvm-gcc and llvm-g++ . Does it mean that it uses gcc internally for creating machine code? And do i need to brew install llvm to switch completely to llvm ?
If you just want clang, and plan to do mostly high-level language development (C, C++, ObjC), then I recommend installing the Xcode command line tools. You can get those from https://developer.apple.com/downloads/index.action?name=for%20Xcode (or you can install all of Xcode if you prefer).
If you want lower-level tools like llc, then my recommendation is brew, as you suggest.
If you're goal is just Mac development, then Xcode is the better solution. If your goal is working on LLVM, then brew is the better answer (or pull the sources and build it yourself).
If you want both on the same machine, I'd recommend not installing the command line tools. Just install Xcode and LLVM. Then you can run the Xcode versions using xcrun without colliding with your LLVM installation.
clang doesn't use llvm-gcc as a backend. It includes LLVM. llvm-gcc is a modified version of GCC that integrates with the LLVM backend, which allows programs that expect GCC-specific features to work with LLVM.

Installing gcc 4.8 on Debian

I want to start playing around with some of the newer C++11 features and it appears that the best support for this is with gcc 4.8, and Squeeze ships with 4.4.5.
However, I don't want to cause any "damage" to my current setup. What's the best way to get both versions of gcc running side-by-side? I'm concerned mostly at the large number of dependencies and that taking them all in to my current system may render it unstable.
Has anyone managed to do this, and what are the steps involved?
Failing that, I'll probably just create a VM and run an "unstable" Debian under that but it's a less-than-ideal solution.
If you install GCC from source just make sure you don't install it to /usr and it won't mess anything up. If you install it as your own user, not root, then there is zero chance of messing up the system.
See http://gcc.gnu.org/wiki/InstallingGCC for the almost-idiot-proof minimal configuration.
I have various versions built as my user and installed in ~/gcc/4.X for various X.
The only thing to be aware of using that set up is that the shared libraries for the new version aren't in the dynamic linker's default search path, so you need to use LD_LIBRARY_PATH or some other solution to ensure executables find the libs from 4.8, see the libstdc++ FAQ and the page it links to in the manual
I use a wrapper script call g++11 which simply calls the new version of GCC with -std=gnu++11 and passes a flag to the linker telling it to set the path to the 4.8 libs in the executable:
$HOME/gcc/4.8/bin/g++ -Wl,-rpath,$HOME/gcc/4.8/lib64 -std=gnu++11 -Wall -Wextra -g "$#"
I had the same problem, and didn't want to fully upgrade to testing.
Jessie (testing) now contains g++-4.8 which is compliant with C++11.
I used apt-pinning in the following way:
A source to jessie was added to /etc/apt/sources.list:
deb http://ftp.uk.debian.org/debian/ jessie main non-free contrib
/etc/apt/preferences was edited as such:
Package: *
Pin: release n=wheezy
Pin-Priority: 900
Package: gcc*
Pin: release n=jessie
Pin-Priority: 910
Then,
$ sudo aptitude update
$ sudo aptitude install gcc/jessie
At which point I selected the second presented option to resolve dependencies fully.
Debian has the package under the name gcc-4.8 (or for the c++ compiler, g++-4.8). Installing those packages will not mess up your OS, as long as you do not rename it to g++. The package is listed as experimental though.
Information on the package is here.
Update: g++-4.8 is now in testing, but an updated package is in unstable
Quick ones:
Just upgrade to testing, it is rock-solid and offers you several concurrent gcc versions. Similar for Ubuntu, on 12.10 I have gcc/g++ 4.4, 4.5, 4.6 and 4.7 in parallel.
Try the Debian backports archive, it may have a port of gcc 4.8.
Use virtualization: I prefer libvirt / kvm which is incredibly lightweight on Linux as it is kernel based. My amd64 server has two other 32 bit installations for that very reason.
Not really a SO question...
Have you tried chroot to install a newer Debian flavor?
you can play around without fear to break you working system.
install a Debian flavor that support you gcc version desired.
install a gcc version manually without affecting you working system.
http://wiki.blender.org/index.php/Dev:Doc/Building_Blender/Linux/Chroot

Getting the latest version of GCC and boost on newest version of Ubuntu

First of all I know that the title is general, but i presume that is the correct way of asking questions.
Specifics are: I'm trying to get boost 1.46 and gcc 4.6 using ppa(ubuntu toolchain for gcc and boost latest for libboost). I can do it on 10.10, but it seems impossible on 11.04. So is there an official way of using the latest version of gcc and libbbost. I know that default versions for ubuntu arent the newest ones, but i need some 1.44+ boost stuff and gcc 4.6 for some nice :) c++11 features. So what is the best way to do it? PPA?
This works on every distribution on almost any operating system:
Go to gcc.gnu.org, download the sources, unpack, have a look at the README, do a
./configure
make -j4
make install (as root)
which will install gcc in the /usr/local prefix (your current compiler will be untouched).
If you want to use the compiler, you need to make your toolchain aware of it, you can use some environment variables (CC, PATH) or configure your project manually.
Repeat for boost.

How to compile a Windows binary in Ubuntu?

I have a Qt application that I can compile in Ubuntu 10.04 64-bit and on Windows. However, I would like to avoid switching to Windows every time I want to compile the Windows version.
Is there a way I can compile a Windows Qt executable in Ubuntu with mingw32 or something?
Further, is there a way to integrate that compiler into Qt Creator?
There is a PPA (Personal Package Archive) for some people who are cross-compiling Qt and related software on Ubuntu for Windows. The PPA contains both the cross-compilers and the dependencies you will need to cross-compile Qt programs. If you look at the source packages there, I think you will be able to figure out how to configure your projects and build them.
If you most of your time spend coding with Qt on Linux (for example, Ubuntu), you may produce some experiment: install Wine, install Qt SDK for Windows with Wine and tried to build some simple project!
And if you don't like crazy things, which I wrote above, just use VirtualBox.

Resources