user293895
user293895

Reputation: 1527

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

Upvotes: 0

Views: 949

Answers (3)

Torp
Torp

Reputation: 7924

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.

Upvotes: 2

Jonathan Leffler
Jonathan Leffler

Reputation: 754570

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.

Upvotes: 2

Mat
Mat

Reputation: 206851

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.

Upvotes: 3

Related Questions