xcode <png.h> 在 mac os X Mavericks 中找不到

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20954719/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:30:49  来源:igfitidea点击:

<png.h> not found in mac os X mavericks

cxcodemacospnglibpng

提问by lucarc

I tried (apparently successfully) to install libpngon mac os x mavericks.

我尝试(显然成功)libpng在 mac os x Mavericks 上安装。

I downloaded the latest 1-6-8 version .tar.xzand followed the instructions.

我下载了最新的 1-6-8 版本.tar.xz并按照说明操作。

./configureruns fine

./configure运行良好

make checkpasses everything but png-error that gets skipped

make check通过除了被跳过的 png-error 之外的所有内容

sudo make installapparently works fine since my library libpng. appears.

sudo make install显然工作正常,因为我的库 libpng。出现。

Now, when i try to compile the C file that i need to compile, using the string

现在,当我尝试编译我需要编译的 C 文件时,使用字符串

clang -w -lz -lpng16 libpng_test.c

clang -w -lz -lpng16 libpng_test.c

i get the error

我得到了错误

fatal error: 'png.h' file not found

fatal error: 'png.h' file not found

#include <png.h>

#include <png.h>

and obviously it does not compile.

显然它不能编译。

I tried installing both with homebrew and macports and it always seems to run fine, but i always get the same error

我尝试使用自制软件和 macports 安装,它似乎总是运行良好,但我总是遇到相同的错误

回答by Pedro Scarapicchia Junior

First you have to find where the png.h file is located

首先你要找到png.h文件所在的位置

sudo find / -name png.h

Here in my environment it is located at /usr/local/include

在我的环境中,它位于/usr/local/include

Then look for libpng.a

然后寻找libpng.a

sudo find / -name libpng.a

Here in my environment it is located at /usr/local/lib

在我的环境中,它位于/usr/local/lib

Now add those directories to the clang command line:

现在将这些目录添加到 clang 命令行:

clang -I/usr/local/include -L/usr/local/lib -w -lz -lpng16 libpng_test.c