Cross-compiling and running hello world for ARM Linux - c

I'm trying to run hello world program on ARM computer with Linux (Debian Wheezy). The libc version on it is 2.13, while my own computer has 2.15 (Ubuntu Precise).
I installed arm-linux-gnueabi-gcc on my computer and compiled the application with static linkage.
All my attempts to run compiled binary result in "cannot execute binary file" message. However, QEMU on my own computer (qemu-arm-static) runs the application succesfully.
I thought that it should be enough to link my app statically. The permissions are 755. What am I missing here?
UPD: I tried to install Arch Linux on that ARM. In that distribution my compiled binaries crash with segfault instead of bash error message. Does stock cross compiler in Ubuntu distribution ever work? :-/
Thanks!

Related

Run valgrind on cross compiled executable

I'm using Ubuntu 18.04 VM and trying to find a way to valgrind check an arm-Linux executable. I've tried compiling with local gcc but ran into some problems. The executable is created by Makefile provided from project. I've tried linaro emulator, following guides online, but faced multiple issues which for each one I've searched on online for solutions but all failed. What are the ways I can valgrind?
As long as I can check program for memory leak, any way is fine.
What I get when I valgrind executable now:
valgrind: failed to start tool 'memcheck' for platform 'arm-linux': No such file or directory
The file it self is fyi:
nrf52832_xxaa.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
I've searched through multiple posts for solutions but couldn't find any.
Cross compile valgrind, and execute on the target. There are no other ways. Can't even use qemu to execute valgrind.
It is mandatory to run the executable on the device.
Please consider the option to download the precompiled package for your arch example from https://packages.debian.org/search?keywords=valgrind, follow the mandatory dependencies, and install all on you embedded device. I use to base the version according to the installed version of libc.

GDB stuck at “Configuring GDB Aborting configuring GDB”

I've installed (OSX Mojave 10.14.6.) Eclipse CDT and GNU MCU Eclipse plugin and finaly GNU Tools for ARM. My goal is to build and debug ARM code using GDB (arm-none-eabi-gdb).
I've created a Hello World project for Arm, which builds ok - but, debugging seems not to work with GDB (that comes with the Arm package). GDB gets stuck:
I have set the proper paths in Eclipse to arm-none-eabi-gdb.
I have signed the arm-none-eabi-gdb (with the same certificate that I used to sign GDB installed via brew into /usr/local/bin/gdb the day before - and it worked!).
I have also tried running Eclipse as root from command line.
Nothing helps.
The message is "Configuring GDB Aborting configuring GDB".
What to do?
Probably what is going on here is that you built to a given target (ARM based) and you're trying to run it (with gdb) on your mac (x86).
You'll need an emulator or QEMU to properly run on your mac or maybe a real board.

Run C program on CentOS written in Windows

I want to write a program which should be able to communicate over a network between Windows and CentOS machines.
Now, my problem is that I do not have access to a centOS (6/7 x64) machine to have it done / tested. Is there a way of building it on a Windows machine so that it will be compatible on centOS too? It is going to have a very simple command line interface so there's no need for a GUI compatibility.
If you mean to compile a file on Windows and then have the executable run on Centos then the answer no (see below).
If you mean to write code on Windows that you can move to a Centos box, compile and run, then the answer is yes. To do this you need to insure that you write code that is at least posix compliant. Note that there are a number of cross-platform frameworks if you want graphical interfaces (like QT).
N.B. -- It should be possible to cross-compile if you want to be able to move the executable from a windows box to a Linux box. You will (probably) need to use gcc (mingw) as you compiler on Windows.
My ELLCC cross compilation tool chain can compile C and C++ programs targeting Linux and Windows systems on both Windows and Linux hosts. Pre-built binary packages are available for download.
It's pretty easy to use. Here is an example of building a hello world program for Linux and Windows on a Linux host:
[~/ellcc/examples/hello] dev% ~/ellcc/bin/ecc -target x86_64-linux-eng main.c
[~/ellcc/examples/hello] dev% ./a.out
hello world
[~/ellcc/examples/hello] dev% ~/ellcc/bin/ecc -target x86_64-w64-mingw32 main.c
[~/ellcc/examples/hello] dev% ./a.exe
fixme:winediag:start_process Wine Staging is a testing version containing experimental patches.
fixme:winediag:start_process Please report bugs at http://bugs.wine-staging.com (instead of winehq.org).
hello world
and the same program on a Windows system:
C:\ellcc\examples\hello>c:\ellcc\bin\ecc -target x86_64-w64-mingw32 main.c
C:\ellcc\examples\hello>.\a.exe
hello world
C:\ellcc\examples\hello>C:\ellcc\examples\hello>c:\ellcc\bin\ecc -target x86_64-w64-mingw32 main.c
C:\ellcc\examples\hello>.\a.exe
hello world
C:\ellcc\examples\hello>
ELLCC targets a variety of Linux systems including ARM, Mips, PowerPC and X86 systems as well as 32 and 64 bit Windows systems.
The best solution is probably to install CentOS on a virtual machine such as VirtualBox and use that for test and development.

Can't find gcc compiler

I am running Fedora 19 via VMware and I want to compile and run, a simple C program. However, after running which gcc I get:
/usr/bin/which: no gcc in (/home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin:/home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin_cache:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/demetres/.local/bin:/home/demetres/bin)
It hasn't been a long time, since I installed Sourcery CodeBench Lite, an ARM cross-compiler, for a project I'm working on. Is there a problem with cross-compiler? Othewise, what is required to compile and run the program?
p.s. This specific program is not intended for an ARM platform.
Try yum install gcc for reinstalling.

Cross-compiling step by step to build a simple "hello world" that run into a WM8650 Tablet from Ubuntu 12

i'm a programmer that program in windows world. With experience in Delphi, C for microcontrollers (Motorola, AVR, PIC ) and Assembler. Few months ago i begin to walk into the Linux world, working with routers (DIR 600) like an interface between my hardware (we develop embedded systems) and a web-page.
Some weeks later we start to work with tablets (Chineese cheap based on WM8650) and write some bash programs to communicate with our hardware. All fine.
Later i read that Ubuntu have insede a cross-compiler, so i was install the last version 12.04
but when i try to compile a simple "Hello world" if i use simple gcc al fine inside the ubuntu machine, when compile with the arm-linux-gnueabi-gcc and put the program into the tablet and run it this error is displaying:
Segmentation fault
i was read this link : Cross compiling static C hello world for Android using arm-linux-gnueabi-gcc
But can't understand the right answer.
If some one knows a place or doc file to solve the simple job: cross compile a C program that run into my WM8650 tablet will be appreciated.
Best regards.
Try to specify architecture or cpu like -march=armv5 in front of arm-linux-gnueabi-gcc -static [cpu/architecture] files...

Resources