install 64-bit glib2 on 32-bit system for cross-compiling
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).
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.
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.
I'm going to assume that you're using gcc as your cross-compiler.
- Copy over all the libraries that you'll need form the target system to some folder
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.
精彩评论