2

I have a device with armel architecture, the file system is running on a VM (amd64 architecture) because the device has not enough space to install compile requirements. The OS is Debian 9 (stretch).

I download the Python, create the file config.site with following content (found it in another answer):

ac_cv_file__dev_ptmx=no
ac_cv_file__dev_ptc=no

After that i run ./configure. At last with many options (that i found in different forums) like:

CONFIG_SITE=config.site ./configure --target=arm-linux --host=arm-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" --build=armel --enable-ipv6

At this point, for what i need --[dis|en]able-ipv6?

With different settings it work, if it worked I run make. If this was complete i run

checkinstall -D --install=no --fstrans=yes

If this running successful i install the .deb package on the another device with armel architecure, but if I run python there comes an error: bash: /usr/local/bin/python: cannot execute binary file. Can you explain me why?

UPDATE After the installation of the Debian package the output of file /usr/local/bin/pythonis a symbolic link up to /usr/local/bin/python2.7. The output of the last is:

python2.7: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped

I found that the gcc use x86-64 to compile is that correct? Or i need to change that? When yes, how i change that?

I want to know more about compiling. Please write detailed answers and/or add source links to your answer.

Many thanks in advance!

3
  • 1
    Is the Debian 9 python2.7 package for armel not appropriate? – Stephen Kitt Nov 1 '19 at 11:39
  • Please show the output of file /usr/local/bin/python. – JigglyNaga Nov 1 '19 at 12:04
  • StephenKitt: Where I can see this? The python version 2.7.6 works fine as well. @JigglyNaga: Oh I forgot to write it into the question. I'm currently not on the computer. But i know the command says me it was compiled for x86-64. – Luca Nov 3 '19 at 12:57
0

Compiling is the process of translating a language such as C into instructions for a CPU. Different CPUs have different instruction sets. Think of this as x86_64 being a different CPU language to armel.

While it's technically possible to make a compiler that can write in any instruction set (language), I don't believe there are any that can just switch.

So to use GCC to compile for armel you need a copy of GCC which itself was compiled to write armel. Here's the catch... To achieve what you are trying you need a copy of GCC which will compile for armel, but that copy of GCC needs to run on (be compiled for) x86_64. This is known as a cross compiler: a compiler who's code is compiled for one instruction set that will, when used compile code to a different instruction set.

The compiler you will need is gcc-arm-linux-gnueabi (https://packages.debian.org/buster/gcc-arm-linux-gnueabi). You may find that this get's tripped up with header files (compiling will fail on # include <...>), or libraries (undefined reference to ...). I'm afraid it's so long since I've done this I can't actually remember how to tell the compiler to use the headers and libraries from your target system. This may be something you need to research.

4
  • First, thanks for the description. There is a large list if i run the command. And I found libgcc1-armel-cross. Now I run make CC=libgcc1-armel-cross but that throw an error: Makefile:676: recipe for target 'Modules/python.o' failed – Luca Nov 4 '19 at 9:04
  • The one you want is gcc-arm-linux-gnueabi. – Philip Couling Nov 4 '19 at 11:13
  • This i tried as well. But i get the same error. Is there perhaps something wrong with the command ./configure? – Luca Nov 4 '19 at 11:37
  • I'm afraid this is rapidly going beyond my knowledge, I'm not going to be able to help you much further. I will say the error you've mentioned should have more information before it. As my edit suggests, I'm half expecting you to have a problem with headers or libraries, but I can't for the life of me remember how to re-configure this. Double check if configure has a --target option. You might need to set this instead of CC. Sorry I can't do more. – Philip Couling Nov 4 '19 at 11:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.