Run 64-bit app on 32-bit Ubuntu system

41,680

Solution 1

You can't do that directly on Linux on x86_64 with a 32bit kernel. You need a 64bit kernel to be able to run 64bit code. (Note: kernel. You can have 32bit userland running on a 64bit kernel, and install support for 64bit binaries. How easy this is depends on the distribution. Example here for Debian.)

Some virtualization software is able to do that (with restrictions on the type of CPU you're using), and emulators can do that too. But to run it natively you'll need a 64bit kernel.

Since most 64bit distributions out there have 32bit support (either by default or installable), that's what you should be using if you need to run both 64bit and 32bit binaries on the same OS.

Solution 2

Extending @Mat's answer:

Yes, some virtualization software can do it. The main obstacle to handle is that in a 32-bit environment, the 64-bit features of the CPU are not available, and also the features of a 64-bit kernel isn't available. It is even so if your CPU has 64-bit support (since around 2003, all of them have).

Your question implicitly states that you want to run the 64-bit app in your own system environment. If it is really your intention, this excludes all virtual machine-based solutions. The only remaining which is known for me is the kernel-emulation of the qemu. So:

qemu-x86_64 ./your_64bit_app

It runs your app on your current system, with your current kernel, with your current environment variables. Of course it is not very fast, it has to emulate your cpu.

It can emulate only linux x86-64 apps.

Solution 3

Most 64-bit architectures are extensions to the 32-bit ones. They're newer and completely different so obviously a 32-bit architecture has no idea what the 64-bit counterpart is. They don't know what the new features are, what new registers there are... Even if they know, they have no access to the new registers and features. As a result a 32-bit kernel can't save 64-bit contexts. All of that makes running 64-bit apps on a 32-bit system impossible.

A carefully crafted 64-bit-aware 32-bit kernel can run 64-bit apps but it still needs some 64-bit code to do the context savings, which makes it not a pure 32-bit kernel anymore.

You can run a 64-bit OS inside an emulator, or a 64-bit guest virtual machine inside 32-bit host with VT-x. But technically you're running in a different 64-bit system. It's still not possible to run 64-bit code directly on 32-bit Linux kernel

Share:
41,680

Related videos on Youtube

Gabriel
Author by

Gabriel

Updated on September 18, 2022

Comments

  • Gabriel
    Gabriel over 1 year

    All the questions I've seen refer to running a 32-bit app in a 64-bit system.

    I'm running 32-bit Ubuntu 12.04 (actually elementary OS Luna, which is based on it) and I'm trying to run a 64-bit app which refuses open. Running:

    ./64bit_app.run
    

    (where 64bit_app.run is the 64-bit app I'm trying to run) results in:

    bash: ./64bit_app.run: no se puede ejecutar el fichero binario
    

    which translates to "can't execute/run/open binary file".

    Should I be able to run it? Is it possible to run a 64-bit app in a 32-bit system? If so, how?

    • terdon
      terdon about 10 years
      I have not tried this but have you attempted the solutions shown here, esoecially the answer explaining dpkg --add-architecture? As far as I know, the same approach should work for 32 on 64 and for 64 on 32. Just change dpkg --add-architecture i386 to dpkg --add-architecture amd64.
    • user2914606
      user2914606 about 10 years
      you do have 64-bit hardware, right? (just to make sure)
    • Ludwig Schulze
      Ludwig Schulze about 10 years
      "which refuses open"? how exactly?
    • Gabriel
      Gabriel about 10 years
      @terdon tried adding dpkg --add-architecture amd64 to the ./64bit_app.run line but it did not work.
    • terdon
      terdon about 10 years
      What ./64bit_app line? Please edit your post explaining any steps you've tried.
    • Gabriel
      Gabriel about 10 years
      @terdon just did.
    • terdon
      terdon about 10 years
      Please read the answers to the question I linked to, you need to run sudo dpkg --add-architecture amd64 first. That's a separate command.
    • Gabriel
      Gabriel about 10 years
      @terdon sorry, I did not understand that. Running that line results in: dpkg: error: opción --add-architecture desconocida where desconocida translates to unknown.
    • terdon
      terdon about 10 years
      Gabriel, ah yes, sorry Ubuntu's dpkg does not seem to have that.
  • peterh
    peterh about 5 years
    Somewhere I've also read, as if also vmware could do that, but this is not enough sure info for an answer. Afaik recent vmware are 64bit-only on the host side.