I'm using the Bochs emulator and for my class we're using gcc 4.2.1. I believe I've gotten Bochs running, but now I need to compile our programs which are compatible with gcc 4.2/.1.
I understand OSX uses an alias for gcc 4.2.1, but how can I use gcc specifically and not clang?
Edit: GCC 4.6.3 not 4.2.1 sorry
You can install previous version of gcc pretty easily using homebrew.
If you have homebrew installed you can get gcc 4.9 by running
brew install gcc#4.9
After it is installed gcc will still map to the clang that came with your mac. The newly installed gcc will be installed at /usr/local/bin and be called something like gcc-4.
You can find the exact executable name using
ls /usr/local/bin | grep gcc
Hopefully 4.9 is close enough to 4.6 for your purposes.
I have written some effects in C++ (g++) using freeglut on Linux, and I compile them with
g++ -Wall -lglut part8.cpp -o part8
So I was wondering if it is possible to have g++ make static compiled Windows executables that contains everything needed?
I don't have Windows, so it would be really cool, if I could do that on Linux :)
mingw32 exists as a package for Linux. You can cross-compile and -link Windows applications with it. There's a tutorial here at the Code::Blocks forum. Mind that the command changes to x86_64-w64-mingw32-gcc-win32, for example.
Ubuntu, for example, has MinGW in its repositories:
$ apt-cache search mingw
[...]
g++-mingw-w64 - GNU C++ compiler for MinGW-w64
gcc-mingw-w64 - GNU C compiler for MinGW-w64
mingw-w64 - Development environment targeting 32- and 64-bit Windows
[...]
Suggested method gave me error on Ubuntu 16.04: E: Unable to locate package mingw32
===========================================================================
To install this package on Ubuntu please use following:
sudo apt-get install mingw-w64
After install you can use it:
x86_64-w64-mingw32-g++
Please note!
For 64-bit use: x86_64-w64-mingw32-g++
For 32-bit use: i686-w64-mingw32-g++
One option of compiling for Windows in Linux is via mingw. I found a very helpful tutorial here.
To install mingw32 on Debian based systems, run the following command:
sudo apt-get install mingw32
To compile your code, you can use something like:
i586-mingw32msvc-g++ -o myApp.exe myApp.cpp
You'll sometimes want to test the new Windows application directly in Linux. You can use wine for that, although you should always keep in mind that wine could have bugs. This means that you might not be sure that a bug is in wine, your program, or both, so only use wine for general testing.
To install wine, run:
sudo apt-get install wine
Install a cross compiler, like mingw64 from your package manager.
Then compile in the following way: instead of simply calling gcc call i686-w64-mingw32-gcc for 32-bit Windows or x86_64-w64-mingw32-gcc" for 64-bit Windows. I would also use the --static option, as the target system may not have all the libraries.
If you want to compile other language, like Fortran, replace -gcc with -gfortran in the previous commands.
I've used mingw on Linux to make Windows executables in C, I suspect C++ would work as well.
I have a project, ELLCC, that packages clang and other things as a cross compiler tool chain. I use it to compile clang (C++), binutils, and GDB for Windows. Follow the download link at ellcc.org for pre-compiled binaries for several Linux hosts.
From: https://fedoraproject.org/wiki/MinGW/Tutorial
As of Fedora 17 it is possible to easily build (cross-compile) binaries for the win32 and win64 targets. This is realized using the mingw-w64 toolchain: http://mingw-w64.sf.net/. Using this toolchain allows you to build binaries for the following programming languages: C, C++, Objective-C, Objective-C++ and Fortran.
"Tips and tricks for using the Windows cross-compiler": https://fedoraproject.org/wiki/MinGW/Tips
For Fedora:
# Fedora 18 or greater
sudo dnf group install "MinGW cross-compiler"
# Or (not recommended, because of its deprecation)
sudo yum groupinstall -y "MinGW cross-compiler"
I currently have gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010. For some reason I have to install gcc (GCC) 4.4.7 20120313. How Can I do this?
Thanks.
gcc versions can coexists, you don't need to uninstall the system one.
try apt-get install gcc-4.7
After installing you'll need to change your makefile or your env to point to the proper tool chain instead of default gcc
You should visit https://www.gnu.org/software/gcc/gcc-4.4/ to search for the version you want.
https://www.gnu.org/software/gcc/mirrors.html
has a list of mirrors where you can download the source files for whichever version you want. You can then easily build it yourself.
Note that the version you need is GCC 4.4.7 and NOT GCC 4.7.
I have downloaded gcc binaries (gcc-4.8.2-16.el7.x86_64.rpm). i extracted (it created a directory usr) and checked the version of
gcc using
usr/bin/x86_64-redhat-linux-gcc -dumpversion
It says it as 4.4.6. But it should have been 4.8.2. right. I tried downloading 4.8.2 rpm from different mirrors but "dumpversion" is not showing right version.
Can you please let me know the reason and also tell me how to download the 4.8.2 gcc.?
The "dumped" version number is correct, that you can be sure of.
The path that you query is very odd. Normally it should be gcc, x86_64-linux-gnu-gcc or something similar.ยน
And GCC always has a variant with the explicit version number, so try gcc-4.8 or x86_64-linux-gnu-gcc-4.8.
1) But Redhat is known to invent their own rules ...
There are instructions on llvm.org on how to add the Gold plugin to LLVM-gcc; however since version 3.2 they are not using LLVM-gcc anymore, using Clang instead, and it's unclear on how to use it.
Does anyone know how to add the Gold plugin to LLVM 3.2?
Do we need to install this plug-in at all, or is it embedded in Clang?
I've read that if you don't have Gold plugin as linker, if you try -O4 for LTO it will treats it as -O3, but I suppose it is when you use gcc system linker and not when using Clang, right?
1-If you don't want to change any thing in home/bin directory, then you can compile and install binutils and LLVM in same place it will automatically generate ld,ar and (not ld_new) in llvm/bin directory and since llvm first looks to its own directory to find tools (clang -print-search-dirs) so you can be sure that clang will invoke ld gold in link time first. Its not mentioned in LLVMgold.html but its needed to create bfd-plugins directory in lib and install both LLVMgold.so and linLTO.so there.
2- to support LTO in LLVM we need gold plugin and need to be rebuilt to support it. -O4 is similar to -O3 -flto