iPhone 模拟器:“libpng.dylib,文件不符合所需架构”

发布于 2024-08-12 05:15:17 字数 278 浏览 4 评论 0原文

我试图将 libpng 库链接到我的 iphone 应用程序,并收到此错误:

ld: warning: in /opt/local/lib/libpng.dylib, file is not of required architecture

当我为模拟器或设备构建时会发生这种情况。

然而,当我构建控制台应用程序时,我可以很好地链接到 libpng 。

我做错了什么?我需要使用不同的 libpng.dylib 来进行 iPhone 开发吗?

I'm trying to link the libpng library to my iphone application, and getting this error:

ld: warning: in /opt/local/lib/libpng.dylib, file is not of required architecture

This happens when I build for the simulator or the device.

When I build a console application however, I can link in libpng just fine.

What am I doing wrong? Is there a different libpng.dylib I need to use for iphone development?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

听不够的曲调 2024-08-19 05:15:17

你不能在 iPhone 上使用 dylibs,你需要静态编译它。话虽如此,您看到的错误是单独的问题。

您正在 Snow Leopard 上进行开发吗?如果是这样,那么您构建的默认库可能是 64 位的。模拟器需要 32 位库。您可以通过运行文件来检查它:

file /opt/local/lib/libpng.dylib

如果您没有看到类似的内容:

(for architecture i386):    Mach-O dynamically linked shared library i386

那么您将无法重用它。将库重新构建为静态 i386 库,您应该能够在模拟器中使用它。如果它是基于 autoconf 的构建这篇博客文章解释了如何进行构建并具有 shell 脚本您可以使用。

You can't use dylibs on iPhone, you will need to compile it statically. Having said that, the error you are seeing is separate issue.

Are you developing on Snow Leopard? If so then then the default library you built is likely 64 bit. The simulator requires 32 bit libraries. You can check by running file against it:

file /opt/local/lib/libpng.dylib

If you don't see something like:

(for architecture i386):    Mach-O dynamically linked shared library i386

Then you won't be able to reuse it. Rebuild the library as a static i386 lib and you should be able to use it in the simulator. If it is an autoconf based build this blog post explains how to do a build and has shell script that you can use.

拿命拼未来 2024-08-19 05:15:17

正如 Chris Long 所说,libpng 在 iPhone 上不可用。您可以将其编译到您的项目中(如果它可以为 ARM 编译),否则它将无法工作。
这是一个线索: http:// www.cloudgoessocial.net/2009/06/09/imagemagick-on-iphone-with-jpeg-png/

另外,为了记录,您可以使用以下方法将 UIImage 写为 png: UIImagePNGRepresentation( UIImage *图像)

As Chris Long says, libpng is not available on the iphone. You can compile it into your project (if it will compile for ARM), otherwise it no workums.
Here is a lead: http://www.cloudgoessocial.net/2009/06/09/imagemagick-on-iphone-with-jpeg-png/

Also, for the record, you can write out a UIImage as png natively using: UIImagePNGRepresentation(UIImage *image)

超可爱的懒熊 2024-08-19 05:15:17

这是你从网上下载的libpng.dylib吗? iPhone 开发人员不得使用外部动态库。

我不知道 libpng 是否可用,但以下是检查方法。

  1. 双击目标列表中的应用程序名称。
  2. 单击框架列表下的加号按钮并尝试找到它。不要忘记小写名称出现在“Z”之后。

如果它不存在,则无法使用它。尝试找到一个静态库并从源代码编译它。它必须专门针对 iPhone 模拟器 (Intel) 和 iPhone (ARM) 的架构进行编译。

Is this a libpng.dylib you downloaded from the Internet? iPhone developers aren't allowed to use outside dynamic libraries.

I don't know if libpng is available, but here's how to check.

  1. Double-click on your app name in the Targets list.
  2. Click the Plus button under the Frameworks list and try to find it. Don't forget that lowercase names appear after "Z".

If it's not there, you can't use it. Try finding a static library and compile it from source. It has to be compiled specifically for both the architecture of the iPhone Simulator (Intel) and iPhone (ARM).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文