Mac OS X共享库跨平台开发。

时间:2023-01-03 12:26:48

I should confess I do not even own a Mac, I have done Windows and Linux programming. Here I hope to learn something about Mac OS X by relating it to Linux if possible. And hopefully to be able to compile a Mac shared library without purchasing a Mac.

我应该承认,我甚至没有Mac电脑,我做过Windows和Linux编程。在这里,如果可能的话,我希望通过将Mac OS X与Linux关联来了解一些东西。希望能够编译一个Mac共享库而不用购买Mac。

Note: There is absolutely no GUI, so Cocoa should not be required right? Also imagine I use C or c++0x, and POSIX for now.

注意:绝对没有GUI,所以不需要Cocoa,对吗?假设我现在使用了C或c++0x和POSIX。

What are the differences between Mac OS X shared library and Linux? What is required to be able to run Linux .so files on Mac? Do I need a Mac-native replacement for ld-linux.so, and linux-gate.so or some other crt related object files?

Mac OS X共享库和Linux之间有什么区别?需要什么才能在Mac上运行Linux .so文件?我需要用Mac-native来替代ld-linux吗?所以,linux-gate。还是其他一些crt相关的对象文件?

Is there any cross platform gcc for Mac on Windows or Linux? (again no GUI)

在Windows或Linux上有任何用于Mac的跨平台gcc吗?(再没有GUI)

1 个解决方案

#1


2  

Even though you don't need Cocoa/Objective-C, you still need to link against Mac OS X libraries (like libSystem, which is like libc on Linux). The file format is totally different (ELF vs. Mach-O) so there is no way to make a Linux library or tool work on a Mac without recompilation.

即使您不需要Cocoa/Objective-C,您仍然需要链接到Mac OS X库(比如libSystem,就像Linux上的libc)。文件格式完全不同(ELF和Mach-O),所以如果不重新编译,Linux库或工具就无法在Mac上运行。

If you stick to POSIX/SUS APIs you can easily write things so they compile on both Linux and Mac without changes as long as you don't try any platform-specific things like reading Linux /proc files.

如果您坚持使用POSIX/SUS api,那么您可以轻松地编写东西,以便在Linux和Mac上编译,而不需要更改,只要您不尝试任何特定于平台的东西,比如读取Linux /proc文件。

There doesn't seem to exist any cross-compiler for Linux-to-Mac development and I can't imagine anyone trying to do this: you'd be chasing a moving target without any real benefit.

对于linux到mac的开发,似乎不存在任何交叉编译器,我无法想象有人会这么做:你会追逐一个移动的目标,却没有任何真正的好处。

The solution as always with these type of questions: buy a used MacMini on eBay or similar auction platform. They're cheap and will suffice.

这类问题的解决方法一如既往:在eBay或类似拍卖平台上购买一台用过的MacMini。它们很便宜,足够了。

#1


2  

Even though you don't need Cocoa/Objective-C, you still need to link against Mac OS X libraries (like libSystem, which is like libc on Linux). The file format is totally different (ELF vs. Mach-O) so there is no way to make a Linux library or tool work on a Mac without recompilation.

即使您不需要Cocoa/Objective-C,您仍然需要链接到Mac OS X库(比如libSystem,就像Linux上的libc)。文件格式完全不同(ELF和Mach-O),所以如果不重新编译,Linux库或工具就无法在Mac上运行。

If you stick to POSIX/SUS APIs you can easily write things so they compile on both Linux and Mac without changes as long as you don't try any platform-specific things like reading Linux /proc files.

如果您坚持使用POSIX/SUS api,那么您可以轻松地编写东西,以便在Linux和Mac上编译,而不需要更改,只要您不尝试任何特定于平台的东西,比如读取Linux /proc文件。

There doesn't seem to exist any cross-compiler for Linux-to-Mac development and I can't imagine anyone trying to do this: you'd be chasing a moving target without any real benefit.

对于linux到mac的开发,似乎不存在任何交叉编译器,我无法想象有人会这么做:你会追逐一个移动的目标,却没有任何真正的好处。

The solution as always with these type of questions: buy a used MacMini on eBay or similar auction platform. They're cheap and will suffice.

这类问题的解决方法一如既往:在eBay或类似拍卖平台上购买一台用过的MacMini。它们很便宜,足够了。