install 64-bit glib2 on 32-bit system for cross-compiling

后端 未结 1 1323
独厮守ぢ
独厮守ぢ 2021-01-14 10:43

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).

相关标签:
1条回答
  • 2021-01-14 11:08

    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.

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

    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

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

    -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.

    0 讨论(0)
提交回复
热议问题