Cross compiling gcc 6.2 for QNX - linux

I'm trying to cross compile GCC or clang for qnx and I am not able to find any good set of instructions that explain cross compiling to other operating systems. I already have access to qnx and a GCC compiler version 4.7 for the target.
I've tried reading http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/ and wasn't successful. I keep running into this error:
checking dynamic linker characteristics... ldqnx.so
checking how to hardcode library paths into programs... immediate
checking for shl_load... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
Makefile:11454: recipe for target 'configure-target-libstdc++-v3' failed
make[1]: *** [configure-target-libstdc++-v3] Error 1
I want to compile the latest stable GCC. The host machine is an x86_64 linux. The target is i486-pc-nto-qnx6.6.0. Any ideas?

Related

CMake Target Link Library G++ Flags conflict with OSX Clang

I am trying to write a single CMakeLists.txt file for C++ compilation on Linux with G++ and on OSX with Clang.
I want to use the Target Library flags -Wl,--start-group and -Wl,--end-group with G++, but these give an error when linking with Clang: ld: unknown option: --start-group
The only results I can find choose to just delete these flags on Mac copies, but that doesn't allow easy project migration from linux to OSX. I tried to make these statements CMAKE conditions, but those are treated as literal libraries which are not found:
eg: $<IF($<NOT:APPLE>)> -Wl,--start-group $<ENDIF($<NOT:APPLE>)>
produces: c++: error: $<IF: No such file or directory
Is there a way to conditionally edit in the CMAKE TARGET_LINK_LIBRARIES field?
I'd try this:
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(START_GROUP "-Wl,--start-group")
set(END_GROUP "-Wl,--end-group")
else()
set(START_GROUP "")
set(END_GROUP "")
endif()
Then just replace those options with ${START_GROUP} and ${END_GROUP}, and they will only be used with the GNU compiler.
Don't switch based on platform if it's really the compiler that matters. Otherwise, Clang users on Linux won't be able to build your project.

GCC keeps saying -mfpu=neon is an unrecognoized command

I am compiling code to run on an arm neon and the make files have the following command line included.
-mcpu=cortex-a9 -march=armv7 -mfpu=neon -DARM_NEON
The details of GCC version are as follows:
gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
However when I try to compile, gcc keeps throwing the following error:
gcc: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
gcc: error: unrecognized command line option '-mfpu=neon'
I am pretty sure that the code could be compiled previously. Though a long time ago. Could it be changes in version of GCC? or is it do with 32 bit and 64 bit compilers?
I was trying to cross compile for an arm processor on my intel x86_64 Ubuntu machine. I needed to add the configuration for the host in the makefiles and use arm-linux-gnueabihf-gcc instead of gcc.

Gcc compile hello.c for c6x

I compiled hello.c program for c6x architecture:
gcc-4.8 -o hello -march='c64x' hello.c
But It got an error: error: bad value (c64x) for -march= switch
Seem gcc can't recognize c64x architecture!
I am using Ubuntu 12.04 LTS & gcc-4.8 version.
Thank you!
-march=name
This specifies the name of the target architecture.
But in your case target is TI (c64x) board i.e its arm architecture. to compile your program for arm architecture you need cross-compiler. But you trying to compile on x86gcc native-compiler with option -march which is different from target target. i.e "gcc" is a native compiler. In your case it appears you are not working on an ARM host, thus "gcc" will not compile for ARM on x86.
so download the cross-compiler tool chain and then compile your program with your options.
cross compiler for ubuntu is here
http://www.filewatcher.com/m/gcc-c6x-linux-gnu-4.7.1-0.1.20120606.fc18.1.i686.rpm.10801432-0.html

Compiling Bochs 2.4.6 under Cygwin

Could anyone tell me a version of Cygwin that can compile successfully Bochs 2.4.6? I've tried with the latest version of Cygwin (1.7.9(0.237/5/3)) but I ran into a bunch of errors.
In specific, I initially got a C compiler cannot create executables error when trying to ./configure Bochs:
...
...
checking if you are configuring for another platform... no
checking for standard CFLAGS on this platform... -mno-cygwin -DWIN32
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/usr/bochs-2.4.6':
configure: error: C compiler cannot create executables
See `config.log' for more details
I solved this by switching my default gcc to version 3.x by using /usr/bin/set-gcc-default-3.sh. However, although the progress of the build was going great, I finally got a DEPRECATED error:
configure: error: DEPRECATED - moved to .bochsrc options
Now, I don't know how to overcome the last error so I am stucked.
Any help will be appreciated.
Thanks a lot.

Getting GMP to work with GCC 4.5.2

I'm trying to make a cross compiler with the files from http://crossgcc.rts-software.org/doku.php?id=i386linuxgccformac
I'm on an Intel Mac (10.6.6, x86_64) I compiled: gmp, mpfr, mpc for the cross compiler as 32bit (as I'm on a 64bit Mac) but I'm getting
ld: warning: option -s is obsolete and being ignored
ld: warning: ignoring file /gmp1/lib/libmpc.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file /gmp1/lib/libmpfr.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file /gmp1/lib/libgmp.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
When compiling GCC with:
--prefix=/usr/local/i386-linux-4.5.2 --target=i386-linux --enable-languages=c --without-headers --disable-shared --disable-threads --disable-nls --with-gmp=/gmp1 --with-gmp-lib=/gmp1 --with-gmp-include=/gmp1 --with-mpfr=/gmp1 --with-mpfr-include=/gmp1 --with-mpfr-lib=/gmp1 --with-mpc=/gmp1 --with-mpc-lib=/gmp1 --with-mpc-include=/gmp1
Also, if I compile GMP with:
./configure --prefix=/gmp1 --host=i386-linux
I get:
configure: WARNING: +----------------------------------------------------------
configure: WARNING: | Cannot determine global symbol prefix.
configure: WARNING: | link -dump -symbols output doesn't contain a global data symbol.
configure: WARNING: | Will proceed with no underscore.
configure: WARNING: | If this is wrong then you'll get link errors referring
configure: WARNING: | to ___gmpn_add_n (note three underscores).
configure: WARNING: | In this case do a fresh build with an override,
configure: WARNING: | ./configure gmp_cv_asm_underscore=yes
configure: WARNING: +----------------------------------------------------------
checking how to switch to read-only data section... .data
checking for assembler .type directive...
checking for assembler .size directive...
checking for assembler local label prefix... configure: WARNING: "link -dump -symbols" failure
configure: WARNING: cannot determine local label, using default L
L
checking for assembler byte directive... .byte
checking how to define a 32-bit word... link: illegal option -- d
I think that you are confused about which package should be compiled for which platform:
GCC needs to be compiled for an x86_64 MacOS X host and an i386-linux target.
GMP, MPC and MPFR are runtime dependencies for GCC. Therefore they also need to be compiled for the GCC host - x86_64 in your case. Therefore, the --host=i386-linux option in the GMP configure command is incorrect.
In general, only libraries that will be linked in the programs compiled by GCC need to be built for the cross-compiler target (e.g. i386-linux). GMP and MPFR are not such libraries, unless your programs are actually using them - in that case you will need to have two copies of such libraries, one for GCC and a cross-build for the target.
EDIT:
Have you considered using MacPorts? It has all the dependencies for your cross-compiler:
gmp-5.0.1
mpfr-3.0.0
libmpc-0.8.2
There is also an older newlib-based cross-compiler for i386:
i386-elf-gcc-4.3.2
Even if you do not want to use these, you can still have a look at the build instructions in their Portfiles.
The bottom line is:
Apply whatever patches these libraries need - MacPorts already do that.
Compile the libraries for your build host i.e. MacOSX/x86_64. That means that in any --host options for their configure calls you should be something along the lines of --host=x86_64-darwin (or whatever your host needs). If configure can figure out the host on its own, you can skip the --host options altogether.
Compile GCC with --host being your build host (the 64-bit Mac OS X) and a target of i386-linux, e.g. --target=i386-linux. If I were you, I'd start simple with a compiler for the C and C++ languages only.
See also this tutorial. It has some information on how to produce a working toolchain with a proper glibc.
That said, I think that you'd be better off installing a proper Linux distribution in a virtual machine, for a whole bunch of reasons. Is there a reason for you to need a cross-compiler specifically? What do you want to do with that compiler?
Did you use the "ABI=32" option when compiling GMP? If not, I think it will use 64-bit code even if the host/target are specified as i386.

Resources