上海古都建筑设计集团,上海办公室装修设计公司,上海装修公司高质量的内容分享社区,上海装修公司我们不是内容生产者,我们只是上海办公室装修设计公司内容的搬运工平台

找不到libpng16的符号

guduadmin14小时前

找不到libpng16的符号

gcc编译

gcc -o encode encode.c -lavcodec -lavutil

报错

/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_set_IHDR@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_get_io_ptr@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_set_longjmp_fn@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_set_PLTE@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_write_info@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_create_info_struct@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_write_image@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_write_end@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_create_write_struct@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_set_write_fn@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_set_tRNS@PNG16_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libzvbi.so.0: undefined reference to `png_set_gAMA@PNG16_0'

pkg-config libpng16找到libpng16所在目录

$ pkg-config libpng16 --cflags --libs
-I/usr/local/include/libpng16 -L/usr/local/lib/x86_64-linux-gnu -lpng16 -lz

设置LD_LIBRARY_PATH,然后编译:

export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
gcc -o encode encode.c -lavcodec -lavutil

或者直接-L参数,指定lpng16就可以:

gcc -o encode encode.c -lavcodec -lavutil -L/usr/lib/x86_64-linux-gnu/ -lpng16

指定-L/usr/lib/x86_64-linux-gnu/ -lpng16可以解决上面的问题。

网友评论