Compile GCC with Code Sourcery - gcc

Is it possible to compile native GCC for ARM (host == target == ARM) using Code Sourcery G++?
If it is not possible, could I use crosstool-NG to build the cross-compile and then using this one for compiling the native ARM GCC?
Thank you,
Edit: as to why: I'm creating my own distro for beagleboard...

CodeSourcery provides prebuilt toolchains only for Linux/x86 and Windows (see "Host System Requirements" here). If you want a native ARM-hosted toolchain, you should be able to build one using a cross-compiler. If you want a prebuilt one, you can try some of the existing ARM distros such as Debian-arm, or Aboriginal Linux (it's made to be run in QEMU but you can probably extract the compiler from it and run natively).

Tiny C Compiler runs decently natively on the kindle 3.
Find it on the mobileread forums compiled for native use.
Code sourcery toolchain works for simple comilation via "arm-none-linux-gnueabi-gcc foo.c" IIRC with no effort. creating native arms. Crosstools-ng as well but neither natively AIUI.
I looked into http://buildroot.uclibc.org/downloads/manual/manual.html#_about_buildroot
for a more comprehensive solution.
There are some options in there for what you require IIRC using x-compile to make the compiler but Crosstools is the more robust chain I had trouble with codesourcery doing true static build. HTH

better off to use openembedded

Related

Prebuilt MIPS cross compiler with toolchain for MS-Windows

I'm using a MIPS cross compiler on my Linux machine which works great.
Now I need to compile the same application on Windows.
I'm searching the web for some prebuilt MIPS cross compiler (with toolchain) for MS-Windows, but without success.
Since I'm not sure how to do so, I'm asking if someone knows such prebuilt toolchain? or some guide how to convert my Linux toolchain for windows if it's possible?
Thanks.
You should use Codescape MIPS SDK.
It looks like Mentor has taken away the free MIPS toolchain from the CodeSourcery distribution. Maybe one of these might still work: https://www.linux-mips.org/wiki/Toolchains.

What is a prebuilt gcc?

I would like to know what they mean with "prebuilt gcc"?
gcc is the compiler, but what do they mean by prebuilt? And why does google offer a prebuilt gcc for their android. Can I just not use the regular gcc?
GCC has a source code repository available via SVN.
In some scenarios, you need to download the source code and build the GCC yourself (specially when you have custom hardware). But for most cases, 'pre-built' GCC for your hardware and OS is enough.

Portable method to package C++11 program sources

so, C++11 has been around for a while and, given there already are compilers supporting it on most platforms, it would be nice to use it in some real software -- e.g. one that can be packaged in as-portable-as-possible package, preferably providing ./configure and so.
Because both Clang and GCC currently need -std=c++11 flag to compile c++11 source, and both sometimes require specific flags to work correctly (see for example How to compile C++11 with clang 3.2 on OSX lion? or C++11 Thread not working ), I'm quite afraid that the package won't work on some platforms that already support c++11 because of wrong invocation of compiler.
Q: Is there some standard how to correctly and portably compile c++11? E.g. autotools/autoconf check or some list of compiler/platform directives that describe all possible needed options? Or does the situation come from the fact that c++11 standard implementations are currently marked as "experimental" and the standard will eventually stabilize and become the default choice, not needing any usage of extra compiler flags?
Thanks
-exa
Well, if you`re trying to write portable code, i would recommend using cmake
a very powerful cross-platform, open-source build system.
Using cmake you should be able to identify the compilers available in your current machine and then generate your makefiles using the flags that you want in each case.
I have been using cmake for almost a year by now and it has significantly reduced the time consumed when trying to get a project compiling in different platforms.
I`m using CMake to generate Makefiles of C++11 projects. The only change in CMakeLists.txt I need to do is add the following:
ADD_DEFINITIONS("-std=gnu++11")
ADD_DEFINITIONS("-D_GLIBCXX_USE_C99_STDINT_TR1")
ADD_DEFINITIONS("-D_GLIBCXX_HAS_GTHREADS")
However, as I use Qt, I re-compile QtSDK with a new gcc version 4.8 and get a complete mingw system that use gcc in version 4.8.
Makings these changes, the project compile and run in Windows XP, Windows 7 and linux both 32 and 64 bits. I didn`t test it in OSX yet.

install and use GCC in windows 7 x64

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.

How does the same source code generate binaries for different platforms?

Many multi-platform applications seem to have common source code. How do builds generate platform specific binaries?
Is it possible to build say, a windows binary on linux or mac?
It's possible if you have an appropriate cross-compiler and libraries. For example, many programs which are available on both Linux and Windows use the MinGW toolchain on Windows, which includes a library that emulates POSIX functions using Win32 functions.
The platform a binary is compiled to run on depends on the compiler and generally, one can have the compiler compile for a target system. To that end, yes it is generally possible to compile for a system other than the one you are running on. Though you are usually better off compiling for a target system on that system.

Resources