我想编译法布费尔德程序套件。我运行make
。错误:
cc -s -lpng -o png2ff png2ff.o util.o
png2ff.o: In function `main':
png2ff.c:(.text.startup+0x58): undefined reference to `png_create_read_struct'
png2ff.c:(.text.startup+0x65): undefined reference to `png_create_info_struct'
png2ff.c:(.text.startup+0xb0): undefined reference to `png_init_io'
png2ff.c:(.text.startup+0xc4): undefined reference to `png_get_valid'
png2ff.c:(.text.startup+0xd2): undefined reference to `png_set_tRNS_to_alpha'
png2ff.c:(.text.startup+0xe6): undefined reference to `png_set_add_alpha'
png2ff.c:(.text.startup+0xf0): undefined reference to `png_set_expand_gray_1_2_4_to_8'
png2ff.c:(.text.startup+0xfa): undefined reference to `png_set_gray_to_rgb'
png2ff.c:(.text.startup+0x104): undefined reference to `png_set_packing'
png2ff.c:(.text.startup+0x11a): undefined reference to `png_read_png'
png2ff.c:(.text.startup+0x129): undefined reference to `png_get_image_width'
png2ff.c:(.text.startup+0x143): undefined reference to `png_get_image_height'
png2ff.c:(.text.startup+0x167): undefined reference to `png_get_rows'
png2ff.c:(.text.startup+0x184): undefined reference to `png_get_bit_depth'
png2ff.c:(.text.startup+0x27c): undefined reference to `png_destroy_read_struct'
collect2: error: ld returned 1 exit status
Makefile:26: recipe for target 'png2ff' failed
make: *** [png2ff] Error 1
Libpng 已安装:
$ sudo apt-get install libpng-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libpng-dev is already the newest version (1.6.28-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
如何修复?
我sudo find -name libpng.so
在根目录中运行。文件位于/usr/lib/x86_64-linux-gnu/libpng.so
。我将其添加到-L/usr/lib/x86_64-linux-gnu
。但这没有帮助。LD_FLAGS
config.mk
使输出-v
附加CFLAGS
到config.mk
:
cc -v -std=c99 -pedantic -Wall -Wextra -Os -D_DEFAULT_SOURCE -c -o png2ff.o png2ff.c
Using built-in specs.
COLLECT_GCC=cc
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.3.0-12ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2)
COLLECT_GCC_OPTIONS='-v' '-std=c99' '-Wpedantic' '-Wall' '-Wextra' '-Os' '-D' '_DEFAULT_SOURCE' '-c' '-o' 'png2ff.o' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/6/cc1 -quiet -v -imultiarch x86_64-linux-gnu -D _DEFAULT_SOURCE png2ff.c -quiet -dumpbase png2ff.c -mtune=generic -march=x86-64 -auxbase-strip png2ff.o -Os -Wpedantic -Wall -Wextra -std=c99 -version -fstack-protector-strong -Wformat-security -o /tmp/ccsHz9de.s
GNU C99 (Ubuntu 6.3.0-12ubuntu2) version 6.3.0 20170406 (x86_64-linux-gnu)
compiled by GNU C version 6.3.0 20170406, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/6/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/6/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C99 (Ubuntu 6.3.0-12ubuntu2) version 6.3.0 20170406 (x86_64-linux-gnu)
compiled by GNU C version 6.3.0 20170406, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5a80a4e17a9c5c8f646e6b274db1ec27
COLLECT_GCC_OPTIONS='-v' '-std=c99' '-Wpedantic' '-Wall' '-Wextra' '-Os' '-D' '_DEFAULT_SOURCE' '-c' '-o' 'png2ff.o' '-mtune=generic' '-march=x86-64'
as -v --64 -o png2ff.o /tmp/ccsHz9de.s
GNU assembler version 2.28 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.28
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/6/:/usr/lib/gcc/x86_64-linux-gnu/6/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/6/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/6/:/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/6/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/6/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-std=c99' '-Wpedantic' '-Wall' '-Wextra' '-Os' '-D' '_DEFAULT_SOURCE' '-c' '-o' 'png2ff.o' '-mtune=generic' '-march=x86-64'
cc -L/usr/lib/x86_64-linux-gnu -s -lpng -o png2ff png2ff.o util.o
png2ff.o: In function `main':
png2ff.c:(.text.startup+0x58): undefined reference to `png_create_read_struct'
png2ff.c:(.text.startup+0x65): undefined reference to `png_create_info_struct'
png2ff.c:(.text.startup+0xb0): undefined reference to `png_init_io'
png2ff.c:(.text.startup+0xc4): undefined reference to `png_get_valid'
png2ff.c:(.text.startup+0xd2): undefined reference to `png_set_tRNS_to_alpha'
png2ff.c:(.text.startup+0xe6): undefined reference to `png_set_add_alpha'
png2ff.c:(.text.startup+0xf0): undefined reference to `png_set_expand_gray_1_2_4_to_8'
png2ff.c:(.text.startup+0xfa): undefined reference to `png_set_gray_to_rgb'
png2ff.c:(.text.startup+0x104): undefined reference to `png_set_packing'
png2ff.c:(.text.startup+0x11a): undefined reference to `png_read_png'
png2ff.c:(.text.startup+0x129): undefined reference to `png_get_image_width'
png2ff.c:(.text.startup+0x143): undefined reference to `png_get_image_height'
png2ff.c:(.text.startup+0x167): undefined reference to `png_get_rows'
png2ff.c:(.text.startup+0x184): undefined reference to `png_get_bit_depth'
png2ff.c:(.text.startup+0x27c): undefined reference to `png_destroy_read_struct'
collect2: error: ld returned 1 exit status
Makefile:26: recipe for target 'png2ff' failed
make: *** [png2ff] Error 1
解决方法:必须最后链接png库;
原因:makefile 已损坏。
答案1
您的 libpng 缺少一些符号,因为它对于此版本的 Farbeld 来说是错误的版本。
您可以下载并安装Debian 软件包在 Ubuntu Xenial 或更高版本上。