Missing aarch64 gcc libraries - gcc

I've installed the aarch64-linux-gnu-gcc-8 gcc compiler on an x86 debian distro and am not able to build code due to missing libraries.
The libraries have obviously not been installed when I installed aarch64 version of gcc - but I cannot work out how to install them. Below is the full build output, but it is clear that these two lines tell the story:
ignoring nonexistent directory "/usr/local/include/aarch64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/aarch64-linux-gnu"
How do you install the aarch64 standard libraries for cross compiling on x86 linux?
Here is how I installed gcc aarch64:
sudo apt install gcc-8-aarch64-linux-gnu
sudo apt install qemu
sudo apt install gdb-multiarch
Full build output:
$ aarch64-linux-gnu-gcc-8 -o arm64main hello.c -v -static Using
built-in specs. COLLECT_GCC=aarch64-linux-gnu-gcc-8
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/8/lto-wrapper
Target: aarch64-linux-gnu Configured with: ../src/configure -v
--with-pkgversion='Debian 8.3.0-2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --disable-libphobos --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu --program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include Thread model: posix gcc version 8.3.0 (Debian 8.3.0-2) COLLECT_GCC_OPTIONS='-o' 'arm64main'
'-v' '-static' '-mlittle-endian' '-mabi=lp64'
/usr/lib/gcc-cross/aarch64-linux-gnu/8/cc1 -quiet -v -imultiarch
aarch64-linux-gnu hello.c -quiet -dumpbase hello.c -mlittle-endian
-mabi=lp64 -auxbase hello -version -o /tmp/ccR3mCkw.s GNU C17 (Debian 8.3.0-2) version 8.3.0 (aarch64-linux-gnu) compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param
ggc-min-heapsize=131072 ignoring nonexistent directory
"/usr/local/include/aarch64-linux-gnu" ignoring nonexistent directory
"/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/aarch64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here: /usr/lib/gcc-cross/aarch64-linux-gnu/8/include
/usr/lib/gcc-cross/aarch64-linux-gnu/8/include-fixed /usr/include End
of search list. GNU C17 (Debian 8.3.0-2) version 8.3.0
(aarch64-linux-gnu) compiled by GNU C version 8.3.0, GMP version
6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param
ggc-min-heapsize=131072 Compiler executable checksum:
85d021a8c445ff17fea6865e03920e8f In file included from hello.c:1:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No
such file or directory #include <bits/libc-header-start.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.

short answer: you're not missing anything! doing the file command shows that you've created the binary you intended to:
$ file arm64main
arm64main: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.7.0, BuildID[sha1]=82bc100420a39fb0555d1971aafc488669d3f71c, not stripped
sweetest demo: M. Mossberg's blog shows how to run this binary with qemu and debug with gdb-multiarch here: How to set up an ARM64 playground on Ubuntu 18.04
related: JensD's blog walks you through the whole process here: Cross compiling for Arm or Aarch64 on Debian or Ubuntu
long answer: this LinuxFoundation video explains the GCC cross-compilation toolchain in about 50 minutes Anatomy of Cross-Compilation Toolchains--Thomas Petazzoni, Free Electrons

Related

Msys gcc produces exe that results in "cannot execute binary file: Exec format error"

On an Msys installation I use only occasionally, I could not produce a working executable with gcc. I upgraded the system with pacman -Suy but the error persists.
Here is a session transcript:
$ gcc -v array-indexing.c -o array-indexing.exe
gcc -v array-indexing.c -o array-indexing.exe
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-msys/10.2.0/lto-wrapper.exe
Target: x86_64-pc-msys
Configured with: /c/_/S/gcc/src/gcc-10.2.0/configure --build=x86_64-pc-msys --prefix=/usr --libexecdir=/usr/lib --enable-bootstrap --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --disable-multilib --enable-__cxa_atexit --with-dwarf2 --enable-languages=c,c++,fortran,lto --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=release --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'array-indexing.exe' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/cc1.exe -quiet -v -idirafter /usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../lib/../include/w32api -idirafter /usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/lib/../lib/../../include/w32api array-indexing.c -quiet -dumpbase array-indexing.c -mtune=generic -march=x86-64 -auxbase array-indexing -version -o /tmp/ccHxGOyu.s
GNU C17 (GCC) version 10.2.0 (x86_64-pc-msys)
compiled by GNU C version 10.2.0, GMP version 6.2.0, MPFR version 4.1.0, MPC version 1.1.0, isl version isl-0.22.1-GMP
warning: GMP header version 6.2.0 differs from library version 6.2.1.
warning: MPC header version 1.1.0 differs from library version 1.2.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/include"
ignoring duplicate directory "/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/lib/../lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-msys/10.2.0/include
/usr/lib/gcc/x86_64-pc-msys/10.2.0/include-fixed
/usr/include
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../lib/../include/w32api
End of search list.
GNU C17 (GCC) version 10.2.0 (x86_64-pc-msys)
compiled by GNU C version 10.2.0, GMP version 6.2.0, MPFR version 4.1.0, MPC version 1.1.0, isl version isl-0.22.1-GMP
warning: GMP header version 6.2.0 differs from library version 6.2.1.
warning: MPC header version 1.1.0 differs from library version 1.2.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5dc831ba8ba50cc9f8b7e3207bc4f700
COLLECT_GCC_OPTIONS='-v' '-o' 'array-indexing.exe' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/as.exe -v -o /tmp/ccyivrKf.o /tmp/ccHxGOyu.s
GNU assembler version 2.36.1 (x86_64-pc-msys) using BFD version (GNU Binutils) 2.36.1
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-msys/10.2.0/:/usr/lib/gcc/x86_64-pc-msys/10.2.0/:/usr/lib/gcc/x86_64-pc-msys/:/usr/lib/gcc/x86_64-pc-msys/10.2.0/:/usr/lib/gcc/x86_64-pc-msys/:/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-msys/10.2.0/:/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/lib/../lib/:/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/lib/:/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'array-indexing.exe' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/collect2.exe -plugin /usr/lib/gcc/x86_64-pc-msys/10.2.0/msys-lto_plugin.dll -plugin-opt=/usr/lib/gcc/x86_64-pc-msys/10.2.0/lto-wrapper.exe -plugin-opt=-fresolution=/tmp/cc7hM2x2.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmsys-2.0 -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id -m i386pep --wrap _Znwm --wrap _Znam --wrap _ZdlPv --wrap _ZdaPv --wrap _ZnwmRKSt9nothrow_t --wrap _ZnamRKSt9nothrow_t --wrap _ZdlPvRKSt9nothrow_t --wrap _ZdaPvRKSt9nothrow_t -Bdynamic --dll-search-prefix=msys- --tsaware -o array-indexing.exe /usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../lib/crt0.o /usr/lib/gcc/x86_64-pc-msys/10.2.0/crtbegin.o -L/usr/lib/gcc/x86_64-pc-msys/10.2.0 -L/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/lib/../lib -L/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/lib -L/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../.. /tmp/ccyivrKf.o -lgcc_s -lgcc -lmsys-2.0 -ladvapi32 -lshell32 -luser32 -lkernel32 -lgcc_s -lgcc /usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../lib/default-manifest.o /usr/lib/gcc/x86_64-pc-msys/10.2.0/crtend.o
COLLECT_GCC_OPTIONS='-v' '-o' 'array-indexing.exe' '-mtune=generic' '-march=x86-64'
$ file array-indexing.exe
file array-indexing.exe
array-indexing.exe: PE32+ executable (console) x86-64, for MS Windows
$ ./array-indexing.exe
./array-indexing.exe
bash: ./array-indexing.exe: cannot execute binary file: Exec format error
$
I'm at a loss. To my admittedly non-expert eye, the output looks inconspicuous. In particular, the generated file is recognized as a Windows executable.
The only thing standing out are these two warnings:
warning: GMP header version 6.2.0 differs from library version 6.2.1.
warning: MPC header version 1.1.0 differs from library version 1.2.1.
Googling didn't produce much insight — there was a broken dwarf5 a year ago, but the transcript shows it's using dwarf2, and that was about it.
Any ideas?
It's probably as ssbssa said in a comment: The compiler produced dwarf5 output which the runtime could not handle. The executable ran when stripped of debug information.
The issue was compounded because for some reason even repeated pacman -Suy didn't upgrade gcc or the binutils (I hadn't checked and thought that 10.2.0 was the latest available msys gcc version). Even though that command didn't output any error messages, it didn't upgrade non-core packages. It is possible that some msys processes still lingered and prevented upgrading non-core package upgrades, even though the installation closed the mintty console I was upgrading from.
For some reason the upgrades worked when I followed the advice on this page. I issued the command pacman --needed -S bash pacman pacman-mirrors msys2-runtime, followed by pacman -Suu, and a lot of package upgrades were performed successfully, resulting in a working toolchain.

Compilation program with libftd2xx library on ARM platform

I try to compile program in C, dedicated for FTDI chip. My enviroment is Advanced Tomato based Asus router + 16GB USB mem stick, mounted as /opt. Additionaly I have compiler + dependences + the newest FTDI library for ARMv7 from FTDI web site.
My compilation command is:
gcc -v -Wl,-rpath=/opt/usr/local/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3 -L/opt/usr/local/lib -O2 -pipe -march=armv7-a -mtune=cortex-a9 -fno-caller-saves -mfloat-abi=soft -l ftd2xx arco.c -o arco
Library patch is:
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/opt/lib:/opt/usr/lib:/opt/include:/opt/usr/local/lib:/opt/usr/include
Below verbose output from compilation process. Strange think is that in the first part of compilation, location od dynamic linker is correct, that is:
/opt/lib/ld-linux.so.3
But in the second part is wrong, that is:
/lib/ld-linux.so.3
It is not possible to copy/link ld-linux.so.3 to /lib because it is read only filesystem.
All this cause that when I run program, an library error occurs:
./arco: error while loading shared libraries: /opt/usr/local/lib/libftd2xx.so: internal error
Any idea what I am doing wrong?
Compilation output:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper
Target: arm-openwrt-linux-gnueabi
Configured with: /media/ware3/Entware-ng.2016.08/build_dir/target-arm_cortex-a9_glibc-2.23_eabi/gcc-5.4.0/configure --target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-linux-gnu --program-prefix= --program-suffix= --prefix=/opt --exec-prefix=/opt --bindir=/opt/bin --sbindir=/opt/sbin --libexecdir=/opt/lib --sysconfdir=/opt/etc --datadir=/opt/share --localstatedir=/opt/var --mandir=/opt/man --infodir=/opt/info --disable-nls --build=x86_64-linux-gnu --host=arm-openwrt-linux-gnueabi --target=arm-openwrt-linux-gnueabi --enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 5.4.0' --enable-shared --enable-__cxa_atexit --with-default-libstdcxx-abi=gcc4-compatible --enable-target-optspace --with-gnu-ld --with-stage1-ldflags='-Wl,-rpath=/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3' --with-boot-ldflags='static-libstdc++ -static-libgcc -Wl,-rpath=/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3' --disable-nls --disable-libsanitizer --disable-libvtv --disable-libcilkrts --disable-libmudflap --disable-multilib --disable-libgomp --disable-libquadmath --disable-libssp --disable-decimal-float --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/opt --libexecdir=/opt/lib --with-local-prefix=/opt --with-float=soft --with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 5.4.0 (OpenWrt GCC 5.4.0)
COLLECT_GCC_OPTIONS='-v' '-L/opt/usr/local/lib' '-O2' '-pipe' '-march=armv7-a' '-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'arco' '-mtls-dialect=gnu'
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/cc1 -quiet -v -imultilib . -imultiarch arm-linux-gnueabi arco.c -quiet -dumpbase arco.c -march=armv7-a -mtune=cortex-a9 -mfloat-abi=soft -mtls-dialect=gnu -auxbase arco -O2 -version -fno-caller-saves -o - |
as -v -march=armv7-a -mfloat-abi=soft -meabi=5 -o /opt/tmp/ccMeNAyM.o
GNU assembler version 2.26.1 (arm-openwrt-linux-gnueabi) using BFD version (GNU Binutils) 2.26.1
GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
ignoring nonexistent directory "/opt/include/arm-linux-gnueabi"
ignoring nonexistent directory "/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../../arm-openwrt-linux-gnueabi/include"
ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include
/opt/include
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include-fixed
End of search list.
GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
Compiler executable checksum: a589712d81e28a1300ccb0e03d994135
COMPILER_PATH=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/
LIBRARY_PATH=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-L/opt/usr/local/lib' '-O2' '-pipe' '-march=armv7-a' '-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'arco' '-mtls-dialect=gnu'
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/collect2 -plugin /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/liblto_plugin.so -plugin-opt=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper -plugin-opt=-fresolution=/opt/tmp/ccOsGCvJ.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -o arco /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crt1.o /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crti.o /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtbegin.o -L/opt/usr/local/lib -L/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0 -L/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../.. -rpath=/opt/usr/local/lib --dynamic-linker=/opt/lib/ld-linux.so.3 -lftd2xx /opt/tmp/ccMeNAyM.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtend.o /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtn.o

How to compile with gcc inside OpenWRT

I have a "Linksys WRT1200AC" router running "OpenWrt Chaos Calmer 15.05.1" (mvebu Architecture) with "gcc_4.8.3-1_mvebu.ipk" and all other required packages installed.
I've tried to compile a C source file (something easy, similar to "hello world") with the command:
#gcc mysource.c -o myprogram
#chmod +x myprogram
#./myprogram
myprogram: line 1: syntax error: unexpected word (expecting ")")
The compiler gives me no errors or warnings, but the program can't be started.
It's like installing a .ipk package from a different arch to the router.
So I think that gcc is compiling my source for a different CPU/Arch.
The router cpu is: "Marvell Armada 38X dual-core # 1.33 GHz (88F6820-A0 C133)"
# uname -a
Linux OW 3.18.23 #1 SMP Sun Jan 31 12:53:24 CET 2016 armv7l GNU/Linux
# grep 'model name' /proc/cpuinfo
model name : ARMv7 Processor rev 1 (v7l)
model name : ARMv7 Processor rev 1 (v7l)
What is the correct command line to compile my sources inside openwrt with the right CPU/Arch option?
I've tried with different "-march/-mcpu" but no success.
This is with verbose on:
# gcc -v mysource.c -o myprogram
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/lto-wrapper
Target: arm-openwrt-linux-uclibcgnueabi
Configured with: /home/buildbot/slave-local/mvebu_generic/build/build_dir/target-arm_cortex-a9+vfpv3_uClibc-0.9.33.2_eabi/gcc-4.8.3/configure --target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-linux-gnu --program-prefix= --program-suffix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls --build=x86_64-linux-gnu --host=arm-openwrt-linux-uclibcgnueabi --target=arm-openwrt-linux-uclibcgnueabi --enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 4.8.3' --enable-shared --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-nls --disable-libmudflap --disable-multilib --disable-libgomp --disable-libquadmath --disable-libssp --disable-decimal-float --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/usr --libexecdir=/usr/lib --with-float=soft
Thread model: posix
gcc version 4.8.3 (OpenWrt GCC 4.8.3)
COLLECT_GCC_OPTIONS='-v' '-o' 'myprogram' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/cc1 -quiet -v -imultilib . -imultiarch arm-linux-gnueabi mysource.c -quiet -dumpbase myprogram.c -mfloat-abi=soft -mtls-dialect=gnu -auxbase mysource -version -o /tmp/ccojawQz.s
GNU C (OpenWrt GCC 4.8.3) version 4.8.3 (arm-openwrt-linux-uclibcgnueabi)
compiled by GNU C version 4.8.3, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../../../arm-openwrt-linux-uclibcgnueabi/include"
ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/include
/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/include-fixed
/usr/include
End of search list.
GNU C (OpenWrt GCC 4.8.3) version 4.8.3 (arm-openwrt-linux-uclibcgnueabi)
compiled by GNU C version 4.8.3, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Well, seems that is working this way ;)
gcc -mabi=aapcs-linux mysource.c -o myprogram

gcc: CreateProcess: No such file or directory

I have tried to use other solutions posted on the web for the same error but it doesn't work for me.
I am testing the installation of MinGW compiler on my pc and I get the following error when running the code:
gcc -v hello.c
C:\Python34\swigibpy-master>gcc -v hello.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --
enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-we
rror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-mtune=i386' '-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/cc1.exe -quiet -v -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.5.2/ hello.c -quiet -dumpbas
e hello.c -mtune=i386 -march=i386 -auxbase hello -version -o C:\Users\E039256\AppData\Local\Temp\cc87BHBZ.s
GNU C (GCC) version 4.5.2 (mingw32)
compiled by GNU C version 4.5.2, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../mingw32/include"
ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.5.2/../../../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.2/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.2/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.2/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"#include "..." search starts here:#include <...> search starts here: C:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/include
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/include-fixed
End of search list.
GNU C (GCC) version 4.5.2 (mingw32)
compiled by GNU C version 4.5.2, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 48c0bd49e9a9404f24c600b71b435d06
COLLECT_GCC_OPTIONS='-v' '-mtune=i386' '-march=i386'
as -o C:\Users\E039256\AppData\Local\Temp\ccwHyCqZ.o C:\Users\E039256\AppData\Local\Temp\cc87BHBZ.s
gcc: CreateProcess: No such file or directory
The mingw32-gcc, mingw32-g++, etc. binaries exist as an aid to cross development. They are created in a typical build of gcc. They are therefore distributed as the maintainers of GCC meant them to be. The gcc.exe indicates that the binary produces binaries for a target equal to the build, while the mingw32-gcc binary produces binaries to be executed on the mingw32 target.
You can see that at http://www.mingw.org/wiki/FAQ

Why don't programs compiled with 64-bit MinGW g++ work on my 64-bit PC?

I am using Cygwin on 64-bit Windows 8.1.
I wanted to make native windows executables inside the Cygwin environment (i.e. I didn't want to deal with cygwin dll issues). I saw Cygwin had minGW packages so I downloaded the
i686-pc-mingw32-gcc
x86_64-w64-mingw32-gcc
packages. From this post I've gathered the i686 one is 32-bit and the x86_64 one is 64-bit.
I used both the i686 and x86_64 version of g++ to compile a simple hello world program and both compiled without error.
The executable compiled by the i686 works as expected.
My problem: When I try to run the executable compiled by the x86_64 version, I get an windows error box saying "The application was unable to start correctly (0x000007b). Click OK to close the application."
I am very confused by this. Why does the 32-bit compiler work and the 64-bit compiler not work on my system?
In case it helps, here the stuff the x86_64 compiler is doing when I call it
$ x86_64-w64-mingw32-g++ test.cpp -o dd -v
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: /cygdrive/i/szsz/tmpp/cygwin64/mingw64-x86_64/mingw64- x86_64-gc c-4.9.2-1.x86_64/src/gcc-4.9.2/configure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64 /mingw64-x86_64/mingw64-x86_64-gcc-4.9.2-1.x86_64/src/gcc-4.9.2 --prefix=/usr -- exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/ mingw64-x86_64-gcc --htmldir=/usr/share/doc/mingw64-x86_64-gcc/html -C --build=x 86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-w64-mingw32 --without-li biconv-prefix --without-libintl-prefix --with-sysroot=/usr/x86_64-w64-mingw32/sy s-root --with-build-sysroot=/usr/x86_64-w64-mingw32/sys-root --disable-multilib --disable-win32-registry --enable-languages=c,ada,c++,fortran,lto,objc,obj-c++ - -enable-fully-dynamic-strings --enable-graphite --enable-libgomp --enable-libqua dmath --enable-libquadmath-support --enable-libssp --enable-version-specific-run time-libs --with-dwarf2 --with-gnu-ld --with-gnu-as --with-tune=generic --with-c loog-include=/usr/include/cloog-isl --with-system-zlib --libexecdir=/usr/lib
Thread model: win32
gcc version 4.9.2 (GCC)
COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march =x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/cc1plus.exe -quiet -v -U_REENTRANT test.c pp -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -version -o /tmp/ccKIncrs.s
GNU C++ (GCC) version 4.9.2 (x86_64-w64-mingw32)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p 11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/sys- root/usr/local/inclu de"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64- mingw32/4.9.2/../../../. ./x86_64-w64-mingw32/include"
\#include "..." search starts here:
\#include <...> search starts here:
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/x86_64-w64-mingw32
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/backward
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include-fixed
/usr/x86_64-w64-mingw32/sys-root/mingw/include
End of search list.
GNU C++ (GCC) version 4.9.2 (x86_64-w64-mingw32)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p 11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: aee7f7b7ca14852762daf4c41db46c26
COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march =x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64- mingw32/bin/as.exe -v -o /tmp/ccSHmwxw.o /tmp/ccKIncrs.s
GNU assembler version 2.25.51 (x86_64-w64-mingw32) using BFD version (GNU Binuti ls) 2.25.51.20150320
COMPILER_PATH=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/:/usr/lib/gcc/x86_64-w64-min gw32/4.9.2/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/4.9 .2/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../.. /../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/:/usr/lib/gcc/x86_64-w64- ming w32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/:/usr/x86_64-w64-mingw32/sys -root/mingw/lib/../lib/:/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64 -w64-mingw32/lib/:/usr/x86_64-w64-mingw32/sys-root/mingw/lib/
COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march =x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/collect2.exe -plugin /usr/lib/gcc/x86_64- w64-mingw32/4.9.2/cyglto_plugin.dll -plugin-opt=/usr/lib/gcc/x86_64-w64-mingw32/ 4.9.2/lto-wrapper.exe -plugin-opt=-fresolution=/tmp/ccaaJ5U7.res -plugin-opt=-pa ss-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through =-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin- opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass -through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-throug h=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname - plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot= /usr/x86_64-w64-mingw32/sys-root -m i386pep -Bdynamic -o dd.exe /usr/x86_64-w64- mingw32/sys-root/mingw/lib/../lib/crt2.o /usr/x86_64-w64-mingw32/sys-root/mingw/ lib/../lib/crtbegin.o -L/usr/lib/gcc/x86_64-w64-mingw32/4.9.2 -L/usr/lib/gcc/x86 _64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib -L/usr/x86_64-w6 4-mingw32/sys-root/mingw/lib/../lib -L/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../. ./../../x86_64-w64-mingw32/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib /tmp /ccSHmwxw.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladv api32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/default-manifest.o / usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/crtend.o
EDIT: Did some more testing. When I made a program more complex than hello world (I used a #include ) the i686 version of the executable failed as it was missing some GCC related dll. When I add -static-libgcc -static-libstdc++, both version of the compilers work.
This leads me to conclude stuffs messed up with my linkers and DLLs. I don't know too much about this :(

Resources