在 32 位系统上安装 64 位 glib2 进行交叉编译 [英] install 64-bit glib2 on 32-bit system for cross-compiling

查看:25
本文介绍了在 32 位系统上安装 64 位 glib2 进行交叉编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 32 位 ubuntu 系统上交叉编译 64 位可执行文件.这一直有效,直到链接失败,因为缺少 64 位 glib2 (libglib-2.0.a).

I'm trying to cross-compile a 64-bit executable on a 32-bit ubuntu system. This works up until linking, where it fails due to the lack of a 64-bit glib2 (libglib-2.0.a).

如果我在 64 位系统上执行此操作,我会使用 getlibs 将 32 位 glib2 安装到/usr/lib32.然而,在 32 位机器上 getlibs 似乎并没有做相反的事情——将 64 位 glib2 安装到/usr/lib64 中.

If I were doing this on a 64-bit system, I would use getlibs to install a 32-bit glib2 into /usr/lib32. However, on a 32-bit machine getlibs doesn't seem to do the opposite-- install a 64-bit glib2 into /usr/lib64.

我的问题是:我如何手动做getlibs应该做的事情,即将一个64位的glib2安装到/usr/lib64?

My quesiton is: how do I manually do what getlibs should do, that is, install a 64-bit glib2 into /usr/lib64?

推荐答案

有几种方法可以解决这个问题.最直接的方法是下载带有您需要的目标库的工具链.鉴于这很可能不会发生,这是解决此问题的一种方法.

There a couple of ways of going about this. The most straight-forward is to download a toolchain that comes with target libraries you need. Given that this is most likely not going to happen, here's one way to solve this problem.

我将假设您使用 gcc 作为交叉编译器.

I'm going to assume that you're using gcc as your cross-compiler.

  1. 将目标系统所需的所有库复制到某个文件夹中
  2. 在您的 Makefile(或命令行)中,将 CFLAGS(如果是 C++,则为 CXXFLAGS)设置为以下内容:

  1. Copy over all the libraries that you'll need form the target system to some folder
  2. In your Makefile (or command line) set CFLAGS (and CXXFLAGS if C++) to the following:

-L/path/to/target/libs -Wl,-rpath-link/same/path/as/first

-L /path/to/target/libs -Wl,-rpath-link /same/path/as/first

注意 -Wl 和 -rpath-link 之间没有空格,必须是这样.

Note that -Wl, and -rpath-link do not have a space between them, it has to be this way.

-L 添加库路径供编译器查看.第二个参数 -Wl,-rpath-link 添加链接器的路径.您必须同时拥有两者,否则编译器将解析符号,但链接器会抱怨它没有可链接的库.

-L adds library path for the compiler to look at. The second argument, -Wl,-rpath-link adds the path for the linker. You have to have both, otherwise the compiler will resolve the symbols but the linker will whine that it doesn't have the library to link nagainst.

这篇关于在 32 位系统上安装 64 位 glib2 进行交叉编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆