运行 32 位 Linux(Ubuntu)应用程序在 64 位上。

huangapple go评论61阅读模式
英文:

Running 32bit linux (ubuntu) application on 64bit

问题

我正在尝试在Ubuntu 22.04 64位上运行在Ubuntu 18.04 32位上开发的32位可执行文件。该应用程序是使用GNU GCC编译器和CodeBlocks(带有-m32标志)编译的。在Ubuntu 18.04 32位上可以正常工作。我已经在Ubuntu 22.04上添加了32位架构,并安装了必要的库:

sudo dpkg --add-architecture i386
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

该应用程序依赖于libgtksourceview2.0。我已经安装了它,并它位于/usr/lib/x86_64-linux-gnu/中,路径也已添加到/etc/ld.so.conf.d/中。

但当我尝试运行该应用程序时,出现以下错误:

错误加载共享库: libgtksourceview-2.0.so.0: 无法打开共享对象文件: 没有该文件或目录

我还尝试在Ubuntu 22.04上编译该应用程序,但所有安装在x86_64-linux-gnu文件夹下的库似乎不在搜索路径中。同时,其他依赖于该文件夹中库的应用程序也无法启动。

有人能帮助我吗?

谢谢!

我已经尝试将路径添加到ld.so.conf.d中。我已经多次安装了libgtksourceview库。

以下是ldd应用程序的一部分:

libcairo.so.2 => /lib/i386-linux-gnu/libcairo.so.2 (0xf7328000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7223000)
libgtksourceview-2.0.so.0 => 未找到
libgdk-x11-2.0.so.0 => /lib/i386-linux-gnu/libgdk-x11-2.0.so.0 (0xf715c000)
libX11.so.6 => /lib/i386-linux-gnu/libX11.so.6 (0xf700d000)

我期望该应用程序能在64位环境中运行。

英文:

I'm trying to run a 32bit executable developed on ubuntu 18.04 32bit on ubuntu 22.04 64bit.
The applciation is compiled with GNU GCC Compiler with CodeBlocks (with -m32 flags)
On Ubuntu 18.04 32 bit works fine.
I've added the architecture on ubuntu 22.04 and also needed libraries

sudo dpkg --add-architecture i386
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

The application depends on libgtksourceview2.0.
I've installed it and it's present in /usr/lib/x86_64-linux-gnu/
the path is also added on /etc/ld.so.conf.d/

When I try to run the applicatin I get the following error:

**error while loading shared libraries: libgtksourceview-2.0.so.0: cannot open shared object file: No such file or directory
**

I've also tryed to compile the application on ubuntu 22.04 but all libraries which are installed under x86_64-linux-gnu seem to not be on search path.

Also other application which depends on libraries under that folder do not start.

Anyone can help me?

Thank you

I've tried to add the path on ld.so.conf.d.
I've installed the library libgtksourceview several times

this is a part of ldd application

    libcairo.so.2 => /lib/i386-linux-gnu/libcairo.so.2 (0xf7328000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7223000)
libgtksourceview-2.0.so.0 => not found
libgdk-x11-2.0.so.0 => /lib/i386-linux-gnu/libgdk-x11-2.0.so.0 (0xf715c000)
libX11.so.6 => /lib/i386-linux-gnu/libX11.so.6 (0xf700d000)

I expect the application will run even on 64 bit environment

答案1

得分: 1

You can't mix 32-bit and 64-bit code.

You said you added the -m32 flag. It means your application is 32-bit. But you also said that libgtksourceview2.0 is in /usr/lib/x86_64-linux-gnu/. It's considered 64-bit. (You can check by readelf -h).

Therefore, you need to build libgtksourceview2.0 in 32-bit, and then add it to the library path.

To add the library path, I think it's better to specify the built path to LD_LIBRARY_PATH. Other than that, copy built files to the path that is defined at /etc/ld.so.conf or /etc/ld.so.conf.d/*.conf. In your case, probably /lib/i386-linux-gnu/.

英文:

You can't mix 32-bit and 64-bit code.

You said you added the -m32 flag. It means your application is 32-bit.
But you also said that libgtksourceview2.0 is in /usr/lib/x86_64-linux-gnu/. It's considered 64-bit. (You can check by readelf -h).

Therefore, you need to build libgtksourceview2.0 in 32-bit, and then add it to the library path.

To add the library path, I think it's better to specify the built path to LD_LIBRARY_PATH. Other than that, copy built files to the path that is defined at /etc/ld.so.conf or /etc/ld.so.conf.d/*.conf. In your case, probably /lib/i386-linux-gnu/.

huangapple
  • 本文由 发表于 2023年3月21日 00:43:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/75793035.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定