How to determine architecture to build GCC cross compiler? - c++

I'm trying to set up a build server on Linux which I will use to build C/C++ apps for Windows and Mac.
I know that GCC supports a body of different architectures but I can't figure out how to determine targets against which I need to build GCC cross compiler.
Could someone please explain this to me?
Thanks in advance.
P.S.
I know that precompiled solutions already exist, but I just want to understand this in detail by making a deep dive.

On the target machine, run:
gcc -dumpmachine
Then use the result in the --target option when building your cross toolchain.

Related

Cross Compile a automake project?

I am developing an application for enocean. I am able to compile it for my Host system. I want to cross compile it for beaglebone black running openwrt. I have cross compiler and all other libraries. I am not sure how to change the existing configure, Makefiles to cross-compile it.
Please help!
you don't have to change anything. autotools comes with full cross-compilation support.
Just pass the proper --host= flag for your target architecture, e.g.:
./configure --host arm-linux-gnueabihf
This will look for toolchain programs with the given prefix (in the above case, it would look e.g. for a compiler arm-linux-gnueabihf-gcc) in your current $PATH. Most cross-compiling toolchains should automatically adhere to this convention.
See also the official documentation

Install gcc 4.9 on windows and configure it in Netbeans

Preamble
If anything I wrote is not correct, please be so kind and correct me. I am a php developer mainly - I am not into this compiling stuff. I know there are a lot of topics around the www but they seems to be either old/outdated, very complex or links to a bunch of files on sourceforge (I have no clue what files I should download and what to do with them after downloading them).
Searching a couple of days by now
I am researching for a couple of days by now and tried different compilers and settings but I don't get a standalone executable for a c++14 programme.
First compiler
The first compiler I used was cygwin. I was able to compile it with c++14 but on other computers cygwin had to be installed as well as a cygwin dll was missing. I googled and figured out that programmes compiled using Cygwin requires this dll but cannot be included to the programme itself - or did I missed something?
Current compiler
I then switched to MinGW which seems to be a better choice as it allows to compile standalone executables which is correct as I am able to do so. Well, the MinGW setup I downloaded from http://www.mingw.org/ installed among other the gcc version 4.8.1. I need 4.9.1 for c++14.
As the title says I want to configure it in Netbeans but if there is a proper tutorial for a command line compiling it's no problem either but I try to avoid using another IDE as we use it at work, too.
drangon.org
I also heard about http://www.drangon.org/mingw/ but there are tons of links linking to similiar stuff.
My goals
Get a better understanding about gcc and this compiling stuff in general.
Install gcc 4.9.1 (preferred into MinGW as it's currently installed)
Configure it in Netbeans 8.
I suggest you to try MinGW-w64. (Download.)
It's similar to MinGW, but have better multitreading support, can easily compile x64 applications, and what's more important, at this moment it uses GCC 4.9.2.
By the way, MinGW applications require some .dlls to work too. Usually you just provide these libraries with your application, but another option is to add -static flag at linking phase. Applications that are compiled with it do not require any external library files (unless you're using 3rd party libraries that don't support static linking).

Install libcurl for C++ in Windows

this is my first time trying to install a library, and I have next-to-no idea as to how I'd do that. I'm using GCC in codeblocks. Do I download the MinGW64 binary or development build? From there where do/should I extract it to. After that, I believe I have to link it to GCC, how do I accomplish that? Is there anything else after that? I found results on Google, but all they did for me was confuse me.
Downloading MinGW binaries for windows should be sufficient. Dev build from source is only necessary if you want to contribute to the GCC toolchain itself, or change build parameters for it (which is unlikely for the context you're asking for).
When you have installed your MinGW GCC toolchain properly, you should be able to download libcurl as source distribution and compile it with this toolchain.

Binutils ld linker how to configure emulation mode (no supported emulations after build with mingw)

After successfully building binutils/ld with mingw and trying to run it I am getting this message-
$ ld-new
h:/binutils-2.23.1/ld/.libs/ld-new.exe: unrecognised emulation mode:
Supported emulations:
I've looked through the internals documentation and from what I understand you need to set up the configure or makefile so that the emulation mode you want is installed during the build process but I can't work out how you actually do that.
Would appreciate it if someone could explain the process.
Thanks very much.
It seems that default emulation mode is determined based on target tuple that is provided to binutils configure script (--target option).
See also: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=ld/configure.tgt;hb=HEAD

Compiling my C++ code for ARM Architecture

I am a java developer. I have some C++ code to make some system realted calls. This code is compiled on Intel 32-bit platform using GCC (I have make files) and it works fine on regular Intel based 32-bit linux machine. Now I need to run this on a linux OS running on Marvell ARM processor. When I load the shared objects in java I get the following error.
cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)
Please tell me how to resolve this issue. I looked at the GCC options and I found one option to specify the architecture (-march=armv5) and I can't compile with that option.
Thanks in advance.
You need more than just a switch, you need a cross-compiler. You can make your own, but probably the easiest way is :
Find the development tools for your board. It probably comes with a development kit that includes a cross-compilation toolchain
If you don't have these, you can try to install a precompiled cross-compilation like the ones provided freely by CodeSourcery
Then you have to make the location of your toolchain (look for something like arm-none-linux-gnueabi-gcc) available in your path.
Cross compiling simple project is then easy, just override the CC variable in your Makefile :
CROSS = arm-none-linux-gnueabi-
CC = $(CROSS)gcc
LD = $(CROSS)ld
Try using the -mcpu=armv5 switch for gcc.
Here is what's written on http://elinux.org/RPi_Software#ARM:
-Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s