MacOSX 下 libpng 的链接器错误
我正在使用 MacOSX 10.7.2 和 Xcode 4.2.1。我使用端口安装了 libpng
,并尝试在我的应用程序中加载 PNG 图像,但出现链接器错误:
Undefined symbols for architecture x86_64:
"_png_create_read_struct", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_create_info_struct", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_destroy_read_struct", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_set_longjmp_fn", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_init_io", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_set_sig_bytes", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_read_png", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_get_IHDR", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_get_rowbytes", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_get_rows", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
ld: symbol(s) not found for architecture x86_64
在我的项目中包含了 png.h
#include "/usr/X11/include/png.h"
我使用I Know < code>libpng 基于 zlib
,因此我已将 -lz
包含在“其他链接器标志”中,但没有任何更改。
关于如何使其发挥作用有什么建议吗?
I'm working on MacOSX 10.7.2 and Xcode 4.2.1. I installed libpng
using port and I was trying to load a PNG image in my application, but I get linker errors:
Undefined symbols for architecture x86_64:
"_png_create_read_struct", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_create_info_struct", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_destroy_read_struct", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_set_longjmp_fn", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_init_io", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_set_sig_bytes", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_read_png", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_get_IHDR", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_get_rowbytes", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_get_rows", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
ld: symbol(s) not found for architecture x86_64
I included png.h
in my project using
#include "/usr/X11/include/png.h"
I know libpng
is based on zlib
, thus I have included -lz
in "Other linker flags" but nothing changed.
Any suggestions on how to make it work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过手动安装
libpng
解决了问题:在终端中,进入下载的文件夹并启动
如果它不起作用(如我的情况),请使用 TextEdit (或等效工具)打开
makefile
并更改线ARCH="-arch i386 -arch x86_64"
在
ARCH=-arch x86_64
(当然,假设您的系统是 64 位)。
这可能还不够。 Xcode 仍然无法找到该库。我用
它解决了这个问题。现在效果很好。
I solved with a manual installation of
libpng
:in Terminal, go in the downloaded folder and launch
if it doesn't work (as in my case) open
makefile
with TextEdit (or equivalent) and change lineARCH="-arch i386 -arch x86_64"
in
ARCH=-arch x86_64
(assuming, of course, your system is 64 bit).
It may not be enough. Xcode was still unable to find the library. I solved using
That did the trick. Now it works fine.