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

不羁的心 提交于 2019-12-10 16:13:40

问题


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

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

./configure runs fine

make check passes everything but png-error that gets skipped

sudo make install apparently works fine since my library libpng. appears.

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

clang -w -lz -lpng16 libpng_test.c

i get the error

fatal error: 'png.h' file not found

#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


回答1:


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

sudo find / -name png.h

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

Then look for libpng.a

sudo find / -name libpng.a

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

Now add those directories to the clang command line:

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


来源:https://stackoverflow.com/questions/20954719/png-h-not-found-in-mac-os-x-mavericks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!