Mac OS X 共享库跨平台开发
我应该承认我什至没有 Mac,我做过 Windows 和 Linux 编程。在这里,如果可能的话,我希望通过将 Mac OS X 与 Linux 联系起来来了解一些有关 Mac OS X 的知识。并希望能够在不购买 Mac 的情况下编译 Mac 共享库。
注意:绝对没有 GUI,所以 Cocoa 不应该是必需的,对吗?还想象我现在使用 C 或 c++0x 和 POSIX。
Mac OS X 共享库和 Linux 之间有什么区别? 能够在 Mac 上运行 Linux .so 文件需要什么?我是否需要 Mac 本机替换 ld-linux.so 和 linux-gate.so 或其他一些与 crt 相关的目标文件?
Windows 或 Linux 上有适用于 Mac 的跨平台 gcc 吗? (同样没有 GUI)
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.
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.
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?
Is there any cross platform gcc for Mac on Windows or Linux? (again no GUI)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即使您不需要 Cocoa/Objective-C,您仍然需要链接 Mac OS X 库(例如
libSystem
,类似于 Linux 上的libc
)。文件格式完全不同(ELF 与 Mach-O),因此如果不重新编译,就无法使 Linux 库或工具在 Mac 上运行。如果您坚持使用 POSIX/SUS API,您可以轻松地编写一些东西,这样它们就可以在 Linux 和 Mac 上编译而无需进行任何更改,只要您不尝试任何特定于平台的操作(例如读取 Linux
/proc
文件)。似乎不存在任何用于 Linux 到 Mac 开发的交叉编译器,我无法想象有人会尝试这样做:你会追逐一个移动的目标,而没有任何真正的好处。
此类问题的解决方案一如既往:在 eBay 或类似的拍卖平台上购买二手 MacMini。它们很便宜并且足够了。
Even though you don't need Cocoa/Objective-C, you still need to link against Mac OS X libraries (like
libSystem
, which is likelibc
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.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.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.
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.