arm-linux-gnueabi-gcc compiled binary not executing on ARM - linux

I am trying to compile a Hello World for ARM-1136J-S processor. When I compile the C source using CodeSourcery arm-none-linux-gnueabi-gcc (2008q3 edition), it executes successfully on the ARM, but when I compile same code using arm-linux-gnueabi-gcc (installed through apt-get in Ubuntu 12.01) it gives the following error:
./helloworld: line 1: syntax error: unexpected word (expecting ")")
readelf of both the executables show that the binary compiled using Ubuntu toolchain has following extra attributes:
Tag_CPU_unaligned_access: v6
Tag_DIV_use: Not allowed
How can I make it run using Ubuntu toolchain? Can anyone give some hint on that? Thanks

./helloworld: line 1: syntax error: unexpected word (expecting ")")
This doesn't look like a native code error at all - it looks like a script error. Are you sure "helloworld" is actually your compiled binary. Running compiled C code binaries does not give syntax errors ...

Check that your kernel has support for THUMB binaries:
zcat /proc/config.gz |grep THUMB
Try running 'readelf' on your executable. If the entry point address is an odd number (indicating THUMB or mixed ARM/Thumb) and your kernel lacks THUMB executable support, your binary will be rejected by the kernel, and will be attempted to be run as a shell script.

I had the same problem. The problem went away by adding "-static" to link:
arm-linux-gnueabi-gcc -c test.c -o test.o
arm-linux-gnueabi-g++ -o test test.o -static
If your code use "gethostbyname" you will get
warning: Using 'gethostbyname' in statically linked..
but that is another subject and not easily solved.

Related

f95_precision.mod on Debian

I'm trying to use the Intel MKL library from a fresh install of Debian 11.
I'm looking to use the Debian installation of MKL instead of installing manually.
A simple program like
program main
use f95_precision
write(*,*) "hello world"
end program main
compiled with
mpifort -m64 -I/usr/include/mkl/intel64/lp64 -L/usr/lib/x86_64-linux-gnu/mkl -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl -o test test.F90
fails with error
f951: Fatal Error: Reading module ‘/usr/include/mkl/intel64/lp64/f95_precision.mod’ at line 1 column 2: Unexpected EOF
Typical error when the f95_precision.mod file has been generated with another compiler.
What is the right way to use the file f95_precision when using the Debian package installation of MKL?
Edit: I know I can download MKL from the Intel site, install it, compile the blas95 and lapack95 interfaces and then use the f95_precision.mod generated then. That works. The point of this post is to know how do I use the already existing f95_precision.mod, blas95.mod and lapack95.mod that a fresh Debian installation provides.

Linker error : undefined reference to _fbss

I'm sucessfully building pulp-riscv-gnu-toolchain from this this
But when I try to compile my simple source code with builded compiler,
error occured.
My command is riscv32-unknown-elf-g++ -o hello hello.cpp
Error message is /home/jskim/test_toolchains_lib/gcc/riscv32-unknown-elf/7.1.1/../../../../riscv32-unknown-elf/bin/ld : cannot open linker script file riscv.ld : No such file or directory
So I try with this command riscv32-unknown-elf-g++ -o main main.cpp -T /home/jskim/test_toolchains/riscv32-unknown-elf-ld/lib/ldscripts/elf32lriscv.x
But following error occured : /home/jskim/test_toolchains/lib/gcc/riscv32-unknown-elf/7.1.1/../../../../riscv32-unknown-elf/lib/crt0.o: In function '.L0': (.text+0x10):undefined reference to '_fbss' collect2: error: ld returned 1 exit status
I'm using CentOS 7.6 and I try build this pulp-gcc with gcc 4.8.5 and 7.3.1 but both shows me same error. Please help me.
I resolve the problem in this way.
Actually Here is the solution.
I'm not accurate but I think the problem is that the name is not matched.
crt0, which seems to be the helper of start riscv processor has this line la a0 _fbss just basically linker can recognize this if _fbss is replaced with _edata. So i edit the assembly file which is located at pulp-riscv-gnu-toolchain/riscv-newlib/libgloss/riscv/ And rebuild the gnu toolchain. And execute your compiler with -T option like riscv32-unknown-elf-g++ -o main main.cpp -T /home/jskim/test_toolchains/riscv32-unknown-elf-ld/lib/ldscripts/elf32lriscv.x
This is the easiest solution as I think.

I think is an linking error in Geany with nanopi M1

how are you?. I have a big problem (or at least I don't know how to solve it) with Geany, using Debian jessie in a nanopi M1.
The history is like follows:
I'm trying to run some modified demo code that came with the nanopi M1 to control the GPIO ports, so, when I was tring to "Build" the program after compiled, it shows the following errors:
In the function main it says:
/tmp/ccwWOISx.o in function 'main'
...... undefined reference to 'boardinit'
...... undefined reference to 'pintoGPIO'
...... undefined reference to 'openHW'
...... undefined reference to 'selectHW'
...... undefined reference to 'readHW'
...... undefined reference to 'closeHW'
......
......
and about two or tree more errors of the same type "undefined reference" all
related a functions of the hardware
I'm using gcc, the commands came precharged in geany and are:
Compile:
gcc -Wall -c "%f"
Build:
gcc -Wall -o "%f" "%e"
so I think (if I've understood what I readed in other posts in stackoverflow) that is a linking error but don't know how to solve it.
after that, I've modified the Build command to this:
gcc -Wall -c -o "%f" "%e"
this made to not to have errors but the file generated is now of the type "object code" (this is wrong) because I need "executable" files (without extension) and terminal give the following message:
bash: ./Matrix-ir_receiver: cannot execute binary file: Exec format error
I don't have any idea of how to solve this, please help!
As I said, it was a linker problem, I needed to use the -lfahw and -lm options to build the executable. The first options one is specific for the ARM device, I think; after that the program runs flawlessly.

Getting OpenMPI to work on Mac:

I have installed OpenMPI via MacPorts on my OSX system (running Version 10.8.3). I found the C wrapper compiler in /opt/local/lib/openmpi/bin/mpicc, and
/opt/local/lib/openmpi/bin/mpicc test.c
compiles normally. Following the ideas in this post, I issued the following command
PATH=$PATH:~/opt/local/lib/openmpi/bin
which I thought would allow me to compile with
mpicc test.c
However, this gives the following error:
-bash: mpicc: command not found
What have I done wrong?
Just kidding: I should've used
PATH=$PATH:/opt/local/lib/openmpi/bin
rather than
PATH=$PATH:~/opt/local/lib/openmpi/bin

Setting up G++ or ICC for mpi.h on Ubuntu

I have never done any major programing outside of VS08.
I am trying to compile a program called LAMMPS with either of the two relevant make files. One calls g++ and the other calls icc (Intel's compiler).
icc produces this error:
icc -O -DLAMMPS_GZIP -DMPICH_SKIP_MPICXX -DFFT_FFTW -M write_restart.cpp > write_restart.d
write_restart.cpp(15): catastrophic error: cannot open source file "mpi.h"
#include "mpi.h"
and g++ throws this error
g++ -g -O -DLAMMPS_GZIP -DMPICH_SKIP_MPICXX -DFFT_FFTW -M verlet.cpp > verlet.d
pointers.h:25: fatal error: mpi.h: No such file or directory
compilation terminated.
The mpi.h file is located in /usr/lib/openmpi/include
It is my understanding that I need to set that $PATH variable which reads
bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/opt/intel/bin:/usr/lib/openmpi/include:
and $LD_LIBRARY_PATH which currently reads
/usr/lib/openmpi/lib:
SO, how does one include the mpi.h file? So that either icc or g++ find it?
mpi.h is a header for MPI library. That would be included if you use mpic++ MPI compiler wrapper instead of g++ in your makefile. mpic++ will call the appropriate compiler. From what you describe you have openmpi package installed on your ubuntu machine.
For more info, you need to consult the manual, e.g.
http://lammps.sandia.gov/doc/Section_start.html#2_2 (for LAMMPS)
and perhaps you need to see openmpi manual as to how to set up additional compiler. Not sure if this can be done after openmpi itself has been built. By default I think in Ubuntu openmpi compiler wrappers would only call g++. CMIIW.
Okay, so I got it to work with g++ when setting up cc as "mpic++.mpich2" instead of "mpic++"
you can try compile using openmpi make file in /src/MAKE
make openmpi
in my case, this option was successful

Resources