Looking for compiler for 32-bit LSB MIPS architecture - linux

I want to copile a simple c program ("Hello world") for my Xtreamer prodigy. which runs a basic linux kernel:
/host # uname -a
Linux Prodigy 2.6.34-VENUS #30 PREEMPT Tue Feb 28 13:48:27 CST 2012 mips GNU/Linux
(it using chipset Realtek 1186)
I saw one executable file on the streamer and i "filed" it on linux and i got:
sh-4.1# file DvdPlayer
DvdPlayer: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked (uses shared libs), with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x1040000, stripped
On my computer I run linux centos. what compiler do I need to use and when can I get it?
Thanks!

What you need is a cross toolchain - gcc has a architecture that enables it to have different code generation backends, mainly to be able to compile for other architectures than the one you're developing on.
Lots of precompiled cross toolchains exist, an overview of ready to use toolchains for MIPS can be found here.
On the other hand, creating your own cross tool chain, finetuned to your needs, isn't that hard either, it's just quite a bit of work. The canonical reference on how to generate a cross toolchain is Dan Kegel's page.

Related

Raspberry Pi 3: Running arm32 programs on an arm64 system

I run my program perfectly on my Raspberry Pi 3 when I run 32bit Raspibian. It is a Linux 5.10.33-v7+ #1 armv7l system. The programs were compiled on this system, in C++. If I copy the executables to another card with that system, it works.
However, these same executables do not run when I use Debian 4.19.181-1 aarch64 Linux 4.19.0.16-arm64 (I copy the compiled file and paste it on the other system ).
When trying to run, it returns:
-bash: ./Myprogram: No such file or directory.
If I try to run with bash Myprogram, it returns:
Myprogram: cannot execute binary file
From what I've researched, this is an incompatible architectural error.
I've already tried changing permissions with chmod.
I think 32bit files should work on a 64bit system.
The "file" command returns:
ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux),
dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for
GNU/Linux 3.2.0,
BuildID[sha1]=ad484c860b63e0d8735c2b7aa5c69f2e49caaf29, with
debug_info, not stripped
Thank you so much
I understand the problem is the architecture. But why can the same processor (same raspbery) run an armv7l OS and also an arm64 OS? How does compatibility work?
Why does raspberry run both arm64 OS and armv7l OS but not programs?
it's not just a 32 or 64 bit problem .
you are two differents architectures, for your program to work you have no choice, you must recompile it for this architecture.
If you want to make portability you can use systems like "Make".

"No such file or directory" when running app on linux arm target

I have a development kit ( Altera Cyclon V, Cortex A9) and I'm trying to run a simple app on it.
I'm using cygwin for cross compiling my code for ARM Linux (using soureforge toolchain for Linux ).
Steps :
build within cygwin : arm-linux-gcc dd.c -s -mcpu=cortex-a9 -s -o ddb
copy ddb to target and chmod a+x
running it gives me "./ddb: No such file or directory" .
probably a mismatch between lib\tools but I'm new to Linux ( coming from QNX ).
Target is running :
root#socfpga:~/altera# cat /proc/version
Linux version 3.9.0 (jdasilva#sj-interactive3) (gcc version 4.7.3 20121106 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2012.1
1-20121123 - Linaro GCC 2012.11) ) #1 SMP Fri Sep 27 22:55:43 PDT 2013
File data of my app :
ddb: ELF 32-bit LSB executable, ARM, version 1, dynamically linked (uses shared
libs), for GNU/Linux 2.6.33, stripped
File data of a sample hello_world that runs on target :
hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (use
s shared libs), for GNU/Linux 2.6.31, BuildID[sha1]=0x2e8fbebd0bdab5897c0c65fb6b
563f3c34a16eb1, stripped
I can see that different DLL are being used ( 2.6.31 vs 2.6.33 ).
How can I solve this?
I've had that problem before when I tried to copy ARM binaries to an ARM android device.
You solved it, but either way, this is what I found out. The problem was the shared libraries. It is trying to load a library that doesn't exist on the target. The "file not found" error is very misleading.
Related question and answers:
"No such file or directory" but it exists
could be 64<>32bit problem.
See this

executing snmpd::FATAL: kernel too old

can anyone help me to resolve kernel dependency ? I have done net-snmp packaging on linux-3.0.2-generic and trying to make it work on below version.
uname –a
Linux manage 2.6.18.8-1 #3 Wed May 28 14:06:14 UTC 2008 i686 unknown
Snmp version : 5.7.2.rc1
/usr/sbin/chroot /var/snmp3/ /usr/local/sbin/snmpd -f –Le
FATAL: kernel too old
file /usr/local/sbin/snmpd
/usr/local/sbin/snmpd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xacef27c048394ffb2cdef4999566e9aa32e5d2dd, not stripped
so... the file wants 2.6.24 and above version
Hw can I resolve this issue and make it to work on 2.6.18 ? Should I make changes in snmpd.c and recompile it ? if yes than how to do this ? If not than what is the solution of it ?
Just recompiling should be sufficient.
The toolchain used to recompile needs to have a version of the kernel headers and C library that will work with this kernel.
Alternatively, you can switch to a newer kernel, which also has the advantage that it is easier to get security fixes.

Cannot execute binary file error when running bibtex2html

I'm working on a project for a friend on a machine I'm not familiar with and I've run into some errors.
I'm running a program called bibtex2html, which is used to generate an HTML reference page. When I run the program, it gives me a "Cannot execute binary file" error.
From my preliminary research, it seems there are a number of causes to this problem, and I'm not really sure to begin.
What I've done so far:
uname -a ->
Linux baseline 2.6.38-15-generic-pae #60-Ubuntu SMP Tue May 22 11:48:17 UTC 2012 i686 i686 i386 GNU/Linux
file ~/bibtex2html/bibtex2html -> ~/bibtex2html/bibtex2html: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
You did all the research correctly, now you just need to interpret it. It's a 64-bit executable (x86-64), and you're on a 32-bit kernel (i686). You'll need to find or compile a 32-bit version of bibtex2html.

Linux program in FreeBSD

Trying to run my program in FreeBSD OS, I have the following results:
$ ./myprogram
ELF binary type "0" not known
./myprogram: 1: Syntax error: "&" unexpected (expecting ")")
$ file myprogram
myprogram: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.15,
not stripped
The program is built In GCC on Ubuntu computer. What can I do? Can I build the program for FreeBSD on my Ubuntu computer by changing some build options, or I need to build it in FreeBSD OS? Maybe there is some way to convert executable to format recognized by FreeBSD?
You can run a lot of Linux programs on FreeBSD, see http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/linuxemu.html.
If this doesn't work, the easiest solution would be to recompile your program on FreeBSD.
2021-06-21: This answer is outdated. As of 2021, FreeBSD includes Linux® binary compatibility, which will run most Linux binaries, save for those which "overly use i386™ specific calls, as enabling virtual 8086 mode".
A large number of Linux programs can be compiled on BSD systems however they are not the same operating system. Linux and BSD are technically not binary compatible.
These days BSD ships with an ABI (Application Binary Interface) for Linux which will translate Linux sys-calls on the fly (Much how WINE operates). This will allow you to run Linux ELF binaries on BSD systems with a small performance penalty.
That being said, they are not the same operating system and your best bet would be to compile for the target system either by gaining access to it or using a method of cross compiling.
Try branding the executable as a linux executable using brandelf (you still need all the dependent libraries setup though, or try linking it statically
http://www.freebsd.org/cgi/man.cgi?query=brandelf&apropos=0&sektion=0&manpath=FreeBSD+8.0-RELEASE&format=html
brandelf -t "Linux" and it should work.

Resources