开发者

Loading a dylib from a different architecture

I currently have a program I have compiled in x86_64, it relies on quite a few libraries also compiled in x86_64 (so recompiling them all would be a big project). I am looking to run a i386 dylib, however whenever I load it using dlopen I get an error saying开发者_如何学Python it was not built for my architecture. Is there any way to either convert the i386 lib directly to a x86_64 (I do not have the source code for this) or run it on an x86_64 architecture?


You cannot load an i386 library in an x86_64 executable.

There only way to get an x86_64 library out of an i386 one is to recompile it for the right target. If you don't have the source code, this cannot be done.

You can recompile all your code for i386 and use the library though.


You can't load a 32-bit (i386) library (dylib) into a 64-bit (x86_64) process, nor vice versa.

The machine can run either 32-bit or 64-bit processes; what you can't do is mix 32-bit and 64-bit code in a single process.


If that library is irreplaceable, you can't recompile it and you really need the rest of the program to be x86_64, you can run it in a separate process and use some form of IPC to call the code and pass results.
In a lot of cases though, it may be easier to rewrite the library or replace it with something else that does a similar job.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜