7

My Linux .so file can be opened with the fopen() command in Ubuntu, but when I tried to open the file with the fopen() command in Mac OS X 10.6, it failed.

The error was the file type was not recognized. How can I make a Linux library or tool work on Mac OS X 10.6 without recompilation?

Aryan Beezadhur
  • 4,503
  • 4
  • 21
  • 42
user1377049
  • 123
  • 1
  • 1
  • 5
  • MacOS knows nothing about how to open Ubuntu shared object files... you would probably need to install Ubuntu in place of MacOS X, [or maybe dual boot?](https://help.ubuntu.com/community/SwitchingToUbuntu/FromMacOSX) – Michael Dautermann Aug 19 '12 at 10:48
  • yes,is dlopen().Linux binaries are completely different than Mac OS X ones,so i need recompilation,not other ways. – user1377049 Aug 19 '12 at 13:11

1 Answers1

18

Linux binaries are completely different to Mac OS X ones, even on the same architecture. For starters, Linux binaries use the ELF format, whilst Mac OS X ones are based on the Mach-O format. But even if the formats were the same, the operating system interface is not the same.

As a result, Mac OS X cannot run Linux binaries directly. The safest approach would be to install Linux in a virtual machine, e.g. VirtualBox. You would then have a full-blown Linux system to do anything that you want, including accessing files on the Mac OS X host via shared folders.

Aryan Beezadhur
  • 4,503
  • 4
  • 21
  • 42
thkala
  • 84,049
  • 23
  • 157
  • 201