创建静态MAC OS XÇ构建 [英] Creating static Mac OS X C build

查看:210
本文介绍了创建静态MAC OS XÇ构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何创建.c文件的Mac OS X上的静态编译?当我尝试:

 的gcc -o测试MAIN.C -static

我得到:

没有发现-lcrt0.o库:

  LD
collect2:劳工处返回1退出状态


解决方案

这不是在Mac OS X系统的gcc支持:

<一个href=\"http://discussions.apple.com/message.jspa?messageID=11053384\">http://discussions.apple.com/message.jspa?messageID=11053384


  

也许这-static旗平出不MacOS X上并非所有的gcc功能MacOS X上的苹果实施工作,甚至不能在OS的未来版本使用gcc。


  
  

我不知道如何使用-static扯上关系。我想不出任何理由MacOSX上这样做。如果我知道你为什么想用-static我可能更感兴趣的问题。现在,我只是不明白这一点。通过寻求帮助,你基本上是要求该项目的合作者 - 哪怕只有10分钟。你需要让我感兴趣的。


和<一个href=\"http://developer.apple.com/library/mac/#qa/qa2001/qa1118.html\">http://developer.apple.com/library/mac/#qa/qa2001/qa1118.html


  

用户二进制文件的静态链接不支持在Mac OS X搭售用户二进制文件的内部实现的Mac OS X库和接口会限制我们的,而不是更新和提高Mac OS X的能力,动态链接支持(链接针对crt1.o代替自动寻找的crt0.o,例如)。


  
  

我们强烈建议您考虑的静态非常仔细地连接的限制,并考虑您的客户和他们的需求,再加上长期支持,您将需要提供。


更新:禁止是一个静态的二进制文件。但你仍然可以编译一些静态库与您另一个程序使用。计划将静态与库链接,但像其他的libc库将是动态的,因此计划将是一个动态的可执行文件。

How can i create a static build of a .c file on Mac OS X ? When i try:

gcc -o test Main.c -static

I get:

ld: library not found for -lcrt0.o
collect2: ld returned 1 exit status

解决方案

It is not supported in Mac OS X's gcc:

http://discussions.apple.com/message.jspa?messageID=11053384

Perhaps that "-static" flag flat out won't work on MacOS X. Not all features of gcc are implemented on MacOS X. Apple won't even be using gcc in future versions of the OS.

I don't know how to link using "-static". I can't think of any reason to do so on MacOSX. If I knew why you wanted to use "-static" I might be more interested in the problem. Right now, I just don't get it. By asking for help, you are essentially asking for collaborators on the project - even if it is only for 10 minutes. You need to get me interested.

And http://developer.apple.com/library/mac/#qa/qa2001/qa1118.html

Static linking of user binaries is not supported on Mac OS X. Tying user binaries to the internal implementation of Mac OS X libraries and interfaces would limit our ability to update and enhance Mac OS X. Instead, dynamic linking is supported (linking against crt1.o automatically instead of looking for crt0.o, for example).

We strongly recommend that you consider the limitations of statically linking very carefully, and consider your customer and their needs, plus the long-term support you will need to provide.

Update: The prohibited is a static binary. But you still can compile some static library and use it with you another program. Program will be linked statically with your library, but other libraries like libc will be dynamic, so program will be a dynamic executable.

这篇关于创建静态MAC OS XÇ构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆