Are there c++ compilers that I can run on a brand x system that will create machine code that will run on a brand y system? Would this be considered a cross compiler?
Yes, that's exactly what a cross compiler is.
The GNU Compiler Collection (which includes gcc and g++) are a prime example of a portable cross compiler with hundreds of supported CPU types.
There are many ways to configure GCC to be a cross compiler. Most of it depends on the target machine and what's available from it - mostly because of the C runtime environment. For example, compiling GCC for an ARM Linux target requires an ARM Linux glibc pre-compiled to build the cross compiler libstdc++.
This is quite common using gcc.
There are a number of tutorials around that describe building your own cross-compiler environment.
This is one, but a quick google will probably provide a link to someone doing exactly the mix of environments that you're after.
edit:
This is a more thorough tutorial, using crosstool
Yes there are such compilers; yes, they are called cross compilers. For example, GCC can be configured in this manner, so that I can run the compiler on a 32-bit x86 system, but produce 64-bit code for an x64 system, and that's just the tip of the iceberg.
Crosstool is a really handy tool suite for creating a cross-compiling GCC.
HTH,
Eric Melski
Electric Cloud, Inc.
Yes this is what cross-compilation is about (although I would say "brand X" isn't appropriate classification term).
Related
Suppose you have a cross-compilation tool-chain that produces binaries for the ARM architecture.
Your tool-chain is like this (running on a X86_64 machine with Linux):
arm-linux-gnueabi-gcc.exe : for cross-compilation for Linux, running on ARM.
arm-gcc.exe : for bare-metal cross-compilation targeting ARM.
... and the plethora of other tools for cross-compilation on ARM.
Points that I'm interested in are:
(E)ABI differences between binaries (if any)
limitations in case of bare-metal (like dynamic memory allocations, usage of static constructors in case of C++, threading models, etc)
binary-level differences between the 2 cases in terms of information specific to each of them (like debug info support, etc);
ABI differences is up to how you invoke the compiler, for example GCC has -mabi and that can be one of ‘apcs-gnu’, ‘atpcs’, ‘aapcs’, ‘aapcs-linux’ and ‘iwmmxt’.
On bare-metal limitations for various runtime features exists because someone hasn't provided them. Be them initializing zero allocated areas or providing C++ features. If you can supply them, they will work.
Binary level differences is also up to how you invoke compiler.
You can check GCC ARM options online.
I recently started a little project to use a Linux standard C library in a bare-metal environment. I've been describing it on my blog: http://ellcc.org/blog/?page_id=289
Basically what I've done is set up a way to handle Linux system calls so that by implementing simplified versions of certain system calls I can use functions from the standard library. For example, the current state for the ARM implements simplified versions of read(), readv(), write(), writev() and brk(). This allows me to use printf(), fgets(), and malloc() unchanged.
I'm my case, I use the same compiler for targeting Linux and bare-metal. Since it is clang/LLVM based, I can also use the same compiler to target other processors. I'm working on a bare-metal example for the Mips right now.
So I guess the answer is that there doesn't have to be any difference.
I need to compile c/c++ code, by running a build.sh file.
The instruction on the program (that i want to run) says it needs to be compiled by a Intel's compiler1.
After searching on the net I came across information on what to do.
Some people said that we must install first a 32-bit libraries:
https://help.ubuntu.com/community/InstallingCompilers
Others said that we must, first of any installation, change some things:
http://software.intel.com/en-us/articles/using-intel-compilers-for-linux-with-ubuntu
In the other hand, Intel's page show many suites:
http://software.intel.com/en-us/c-compilers
while the only thing that I want is simply Intel's C/C++ compiler.
Can somebody be so gentle to give me the directions on how to install a Intel's compiler on a 64-bit Ubuntu system?
Footnote 1 / Editor's note: other x86 compilers including GCC and clang (and MSVC on Windows), support Intel's SSE/AVX intrinsic functions, but Intel's compiler comes with some libraries such as SVML (e.g. SIMD sin and exp) and MKL which some code might need. Other compilers can be used with SVML if you have it installed separately.
In short, it's worth trying with other compilers, especially if you understand why something says it needs to be compiled by ICC, if getting ICC would be inconvenient. But you might (or might not) be missing out on performance for packages that detect what's available instead of just erroring.
for non commercial use you can download it from Intel
EDIT:
the Intel® System Studio 2016 includes a c++ compiler.
I've tried the 32-bit version of it, the non-commecial one. I don't think it differ from the 32-bit on basic stuff related to installation. Open this and go to compilers and libraries section and you will see the C/C++ compiler. After download it read the files in doc folder; it includes how to install/use/get a key to compiler etc.
You need to install gcc compiler through apt-get install gcc
Look on example here: Install GCC
Question in one sentence: How can I compile code for AIX using G++ on Ubuntu? (Assuming it is possible)
I hope that it is as simple as adding an option to the make file to specify target processor. I am a novice when it comes to most things compiler related.
Thank you in advance.
What you are looking for is a cross-compiling toolchain.
A toolchain includes a cross-compiler (a compiler that runs on the current platform but builds the binary code to run on another, on your case, AIX), the C or C++ library, and some other interesting tools.
I have successfully used buildroot in the past, which is a tool that automates the process of creating a cross-compiling toolchain. I know they support several target platforms, maybe AIX is among them.
If you want to compile your toolchain by hand, take a look at the Roll-your-own section on this page.
Another approach, probably easier on your case, would be to install a AIX system inside a virtual machine on Ubuntu. This way you would have access to a complete AIX system running inside your machine, giving the opportunity to develop and test your application under real conditions (or whatever reasons you may find interesting for doing such a thing).
You'll want to download the right version of g++ (i.e., one that generates code for POWER, or whatever you're running AIX on), and compile that to run under Ubuntu.
Try to compile with -maix32 or -maux64 (like g++ -m32 file.cxx), it it doesn't work it means that it's not supported by your compiller.
I'm currently managing some C++ code that runs on multiple platforms from a single source tree (Win32, Linux, Verifone CC terminals, MBED and even the Nintendo GBA/DS). However I need to build an app targetted at an embedded platform for which there is no C++ compiler (C only). I remmber that many of the early C++ compilers were only front-ends stitting on existing C compilers (Glockenspiel for example used MSC). Are there any such 'frontend' C++ compilers in use today that will generate C code.
Tools Platform
----------- ------------
______Visual C++ _____ WIN32
/
/_______MBED (ARM)_______MBED (ARM dev board).
/
/_________GCC (x86)________Linux
/
Source____/___________GCC (ARM)________GBA/DS
\
\__________SDA______________Verifone Verix CC Terminals
\
\________ARM SDT__________Verifine VerixV CC terminals
\
\______????_____________Renases M8/16/32.
\
\____????_____________Z8 family.
The last two platforms I have good C compilers for but no C++.
As you can see I'm supporting a large variety of platforms and I share a large body of library code (and some app code).
If you use LLVM, llvm-g++ will compile your C++ code to LLVM bitcode, and llc has a backend which converts bitcode to C.
You could write commands like this:
llvm-g++ -emit-llvm -c foo.cpp -o foo.o
llc -march=c <foo.o >foo.c
Comeau C++ does this.
Can't help with the Z8, but the Renesas M16C/M32C family has GCC these days - see http://www.kpitgnutools.com/ for prebuilt cross toolchain hosted on Windows. Haven't used it myself yet but may be a better option than a 3rd party C++ frontend, especially as your code already targets GCC on other platforms.
Comeau C++ generates C as its output, and they seem to be quite happy to port it to work with different back-end compilers, though I'm not sure about the exact pricing for that.
If you want a bit more of a "roll your own" approach, you could buy a license to the EDG C++ compiler. It's normally used as a front-end (e.g. by Comeau and Intel) but I believe as it's shipped, it includes a code generator that produces C as its output. Its licensing is oriented more toward compiler vendors, though, so a license gives you a lot of rights, but is pretty expensive.
Out of date, but maybe you want to try cfront?
I'll leave this for information - cfront doesn't have exception support.
Of what I have understood, the c++ support in gcc for r8c/m16c/r32c isn't quite mature and good enough for production code. But for r8c/m16c/m32c/r32c there is at least one compiler supporting embedded C++ and that is IAR, I think Tasking also supports embedded C++ on m16c.
Notice that the valid solution is for llvm 1.3
llvm last release was 6.0.0 so it would'nt work at all.
(I post this because i've try the solution of this post but it doesn't work anymore) (Maybe i've done something bad)
In my tests llc do not accept anymore the -march=c option.
And going back to the 1.3 isn't possible for me yet.
So try to take care about the version.
How can a cross compilation setup be achieved to allow compiling Cell Linux programs on a Windows PC using the cygwin toolchain? The cygwin tools provide a GNU compiler to use in building the cross compiler, and associated tools for the build process e.g. rpm, cpio, make, flex, bison and so on.
I am moderately confident this is possible, but unaware of anyone who has actually done this. It has already been done for x86 Linux, but I wish to use Windows, without requiring the use and overhead of a virtual machine running an entire 2nd operating system.
The Cell Linux toolchain is a patched GNU toolchain, with C and C++ compilers for the PPU and SPU processors, and associated binutils. The sources for the Cell Linux SDK for Cell Linux can be found here. The source RPMS here have build scripts for use with the rpmbuild tool on Linux.
The specific question is: how can a set of Cell Linux GNU compilers for the PPU and SPU processors be built, on Windows, using Cygwin.
I've never done it, so I can't give you step by step instructions, but I can give you a general idea.
The instructions you linked will serve as a pretty good outline, but there will be definite changes.
For the host PC, you can install gcc and other build tools from MinGW or cygwin. That will give you the windows native parts of your toolchain.
Then you'll need to download the sources for the cell portions of the toolchain and compile them (with the appropriate options, --target, etc.) using the build environment you just installed.
Then you download and compile the sources for libspe2, and you're done.
But I'll warn you - it sounds easier than it is. Be prepared to spend a lot of time on it.
Since you can already do this on Linux x86, why don't you just install Linux a virtual machine? Also, what might be even easier, is to install Portable Ubuntu for Windows. It runs Linux alongside Windows using coLinux. Although this may not be optimal, it is probably much easier than trying to compile everything on Windows.
the ps2dev toolchain can easily be set up under cygwin
http://ps2dev.org/ps3/Tools/Toolchain
You should be able to build a canadian cross compiler on Linux that runs on windows and creates code for PS3. Have a look at the excellent crosstools from Dan Kegel.
Did you check if the Cell/PS3 devtools for windows/cygwin work for you?
A set of tools compiled to run on Windows via Cygwin can now be found on Sourceforge.
Mike Acton has a long, detailed article on cross-compiling for PS3 Linux on his Cell Performance blog.
It may be a bit out of date, but the bits on setting up the toolchain and various SDKs might prove handy.