gpt4 book ai didi

linux - qvfb 编译错误 - 对 `png_create_write_struct' 的 undefined reference

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:21:48 26 4
gpt4 key购买 nike

我在为 x11 编译 qvfb 时遇到错误。

1> 现在这个 png_create_write_struct 声明在哪里,我得到了与之相关的错误

2> x11 的 qvbf 编译是在主机文件系统中查找 libpng 还是在 QT_source_code 中查找 libpng?

3> 请建议如何解决此错误以成功编译 ?

#/qt-everywhere-opensource-src-4.8.5/tools/qvfb$ make
e-opensource-src-4.8.5/lib -L/usr/X11R6/lib -lQtGui -lQtCore -lGL -lpthread -lXext -lX11 -lm
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriter::QAnimationWriter(QString const&, char const*)':
qanimationwriter.cpp:(.text+0xbf): undefined reference to `png_create_write_struct'
qanimationwriter.cpp:(.text+0xca): undefined reference to `png_create_info_struct'
qanimationwriter.cpp:(.text+0xe0): undefined reference to `png_set_compression_level'
qanimationwriter.cpp:(.text+0xff): undefined reference to `png_set_write_fn'
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriterMNG::write(png_struct_def*, unsigned char*, unsigned int)':
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG5writeEP14png_struct_defPhj[QAnimationWriterMNG::write(png_struct_def*, unsigned char*, unsigned int)]+0xb): undefined reference to `png_get_io_ptr'
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)':
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x65): undefined reference to `png_write_chunk'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x78): undefined reference to `png_set_sig_bytes'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0xda): undefined reference to `png_set_IHDR'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0xec): undefined reference to `png_write_info'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x107): undefined reference to `png_set_bgr'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x154): undefined reference to `png_write_image'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x172): undefined reference to `png_write_end'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x184): undefined reference to `png_destroy_write_struct'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x1a8): undefined reference to `png_create_write_struct'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x1b3): undefined reference to `png_create_info_struct'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x1c9): undefined reference to `png_set_compression_level'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x1e8): undefined reference to `png_set_write_fn'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG12composeImageERK6QImageRK6QPoint[QAnimationWriterMNG::composeImage(QImage const&, QPoint const&)]+0x21f): undefined reference to `png_set_filler'
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriterMNG::~QAnimationWriterMNG()':
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD0Ev[_ZN19QAnimationWriterMNGD5Ev]+0x9e): undefined reference to `png_write_chunk'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD0Ev[_ZN19QAnimationWriterMNGD5Ev]+0xb0): undefined reference to `png_destroy_write_struct'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD0Ev[_ZN19QAnimationWriterMNGD5Ev]+0x176): undefined reference to `png_write_chunk'
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriterMNG::setImage(QImage const&)':
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNG8setImageERK6QImage[QAnimationWriterMNG::setImage(QImage const&)]+0xc3): undefined reference to `png_write_chunk'
.obj/release-shared/qanimationwriter.o: In function `QAnimationWriterMNG::~QAnimationWriterMNG()':
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD2Ev[_ZN19QAnimationWriterMNGD5Ev]+0x9e): undefined reference to `png_write_chunk'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD2Ev[_ZN19QAnimationWriterMNGD5Ev]+0xb0): undefined reference to `png_destroy_write_struct'
qanimationwriter.cpp:(.text._ZN19QAnimationWriterMNGD2Ev[_ZN19QAnimationWriterMNGD5Ev]+0x16e): undefined reference to `png_write_chunk'
collect2: ld returned 1 exit status
make: *** [../../bin/qvfb] Error 1

libpng 的定位命令返回:--

#locate libpng
/lib/i386-linux-gnu/libpng12.so.0
/lib/i386-linux-gnu/libpng12.so.0.46.0
/usr/share/doc/libpng12-0
/usr/share/doc/libpng12-0/ANNOUNCE
/usr/share/doc/libpng12-0/KNOWNBUG
/usr/share/doc/libpng12-0/README.Debian
/usr/share/doc/libpng12-0/README.gz
/usr/share/doc/libpng12-0/TODO
/usr/share/doc/libpng12-0/changelog.Debian.gz
/usr/share/doc/libpng12-0/copyright
/usr/share/doc/libpng12-0/libpng-1.2.46.txt.gz
/usr/share/doc-base/libpng12
/var/lib/doc-base/documents/libpng12
/var/lib/dpkg/info/libpng12-0:i386.list
/var/lib/dpkg/info/libpng12-0:i386.md5sums
/var/lib/dpkg/info/libpng12-0:i386.postinst
/var/lib/dpkg/info/libpng12-0:i386.postrm
/var/lib/dpkg/info/libpng12-0:i386.shlibs

现在,如果运行 nm 命令后我的库位于/lib/i386-linux-gnu/libpng12.so.0 :---

$ nm -D /lib/i386-linux-gnu/libpng12.so.0
00000000 A PNG12_0
w _Jv_RegisterClasses
w __cxa_finalize
U __fprintf_chk
w __gmon_start__
U __longjmp_chk
U __memcpy_chk
U __snprintf_chk
U __stack_chk_fail
U _setjmp
U abort
U crc32
U deflate
U deflateEnd
U deflateInit2_
U deflateReset
U fflush
U fputc
U fread
U free
U fwrite
U gmtime
U inflate
U inflateEnd
U inflateInit_
U inflateReset
U malloc
U memcmp
U memcpy
U memset
00004700 T png_access_version_number
00018540 T png_build_grayscale_palette
000039b0 T png_check_sig
0001de60 T png_chunk_error
0001def0 T png_chunk_warning
00014160 T png_convert_from_struct_tm
000141a0 T png_convert_from_time_t
00004470 T png_convert_to_rfc1123
00003c80 T png_create_info_struct
00011120 T png_create_read_struct
00010ca0 T png_create_read_struct_2
00015840 T png_create_write_struct
000154c0 T png_create_write_struct_2
00003cf0 T png_data_freer
000043b0 T png_destroy_info_struct
000130f0 T png_destroy_read_struct
00014930 T png_destroy_write_struct
0001db30 T png_error
0001d8f0 T png_free
00003d80 T png_free_data
0001d8b0 T png_free_default
00006e80 T png_get_IHDR
000071a0 T png_get_PLTE
00007410 T png_get_asm_flagmask
00007400 T png_get_asm_flags
00006a90 T png_get_bKGD
000067f0 T png_get_bit_depth
00006ad0 T png_get_cHRM
00006bf0 T png_get_cHRM_fixed
00006a50 T png_get_channels
00006810 T png_get_color_type
000073e0 T png_get_compression_buffer_size
00006870 T png_get_compression_type
000045c0 T png_get_copyright
0001dfb0 T png_get_error_ptr
00006830 T png_get_filter_type
00006cd0 T png_get_gAMA
00006d10 T png_get_gAMA_fixed
00006e40 T png_get_hIST
00004600 T png_get_header_ver
00004620 T png_get_header_version
00006d90 T png_get_iCCP
000067d0 T png_get_image_height
000067b0 T png_get_image_width
000076e0 T png_get_int_32
00006850 T png_get_interlace_type
00004430 T png_get_io_ptr
000045e0 T png_get_libpng_ver
0001da30 T png_get_mem_ptr
00007430 T png_get_mmx_bitdepth_threshold
00007420 T png_get_mmx_flagmask
00007440 T png_get_mmx_rowbytes_threshold
00006fa0 T png_get_oFFs
00007010 T png_get_pCAL
00007130 T png_get_pHYs
00006930 T png_get_pixel_aspect_ratio
000068f0 T png_get_pixels_per_meter
000204b0 T png_get_progressive_ptr
000073a0 T png_get_rgb_to_gray_status
00006770 T png_get_rowbytes
00006790 T png_get_rows
000071f0 T png_get_sBIT
000070e0 T png_get_sCAL
00006e10 T png_get_sPLT
00006d50 T png_get_sRGB
00006a70 T png_get_signature
000072a0 T png_get_tIME
000072e0 T png_get_tRNS
00007230 T png_get_text
00007710 T png_get_uint_16
00007630 T png_get_uint_31
000076b0 T png_get_uint_32
00007370 T png_get_unknown_chunks
000073c0 T png_get_user_chunk_ptr
00007470 T png_get_user_height_max
0000c720 T png_get_user_transform_ptr
00007450 T png_get_user_width_max
00006750 T png_get_valid
00006990 T png_get_x_offset_microns
000069f0 T png_get_x_offset_pixels
00006890 T png_get_x_pixels_per_meter
000069c0 T png_get_y_offset_microns
00006a20 T png_get_y_offset_pixels
000068c0 T png_get_y_pixels_per_meter
00004640 T png_handle_as_unknown
00003c50 T png_info_init
00003b70 T png_info_init_3
00004450 T png_init_io
00020a90 R png_libpng_ver
0001d7b0 T png_malloc
0001d770 T png_malloc_default
0001d940 T png_malloc_warn
0001d9a0 T png_memcpy_check
0001d9d0 T png_memset_check
00004710 T png_mmx_support
000209e0 R png_pass_dsp_mask
00020a50 R png_pass_inc
000209fc R png_pass_mask
00020a6c R png_pass_start
00020a18 R png_pass_yinc
00020a34 R png_pass_ystart
00006400 T png_permit_empty_plte
00006430 T png_permit_mng_features
00020370 T png_process_data
00020400 T png_progressive_combine_row
00012cd0 T png_read_destroy
000126a0 T png_read_end
00012600 T png_read_image
00011690 T png_read_info
00013250 T png_read_png
00011ea0 T png_read_row
00012510 T png_read_rows
00011e00 T png_read_update_info
000046c0 T png_reset_zstream
0000cb70 T png_save_int_32
0000cba0 T png_save_uint_16
0000cb40 T png_save_uint_32
00005320 T png_set_IHDR
00005750 T png_set_PLTE
0000c110 T png_set_add_alpha
00006700 T png_set_asm_flags
00004d60 T png_set_bKGD
00015d70 T png_set_background
0000bfb0 T png_set_bgr
00004da0 T png_set_cHRM
00004f20 T png_set_cHRM_fixed
00006660 T png_set_compression_buffer_size
00015890 T png_set_compression_level
000158b0 T png_set_compression_mem_level
00015990 T png_set_compression_method
000158d0 T png_set_compression_strategy
000158f0 T png_set_compression_window_bits
00015c20 T png_set_crc_action
00015e70 T png_set_dither
0001df80 T png_set_error_fn
00016a40 T png_set_expand
00016a80 T png_set_expand_gray_1_2_4_to_8
0000c0a0 T png_set_filler
00014a60 T png_set_filter
00014d00 T png_set_filter_heuristics
00014580 T png_set_flush
000050a0 T png_set_gAMA
00005180 T png_set_gAMA_fixed
000169c0 T png_set_gamma
00016aa0 T png_set_gray_1_2_4_to_8
00016ae0 T png_set_gray_to_rgb
00005240 T png_set_hIST
000059c0 T png_set_iCCP
0000c070 T png_set_interlace_handling
000066e0 T png_set_invalid
0000c180 T png_set_invert_alpha
0000c1a0 T png_set_invert_mono
00006450 T png_set_keep_unknown_chunks
0001da00 T png_set_mem_fn
00006720 T png_set_mmx_thresholds
00005470 T png_set_oFFs
000054a0 T png_set_pCAL
00005720 T png_set_pHYs
0000bff0 T png_set_packing
0000c020 T png_set_packswap
00016a60 T png_set_palette_to_rgb
00020450 T png_set_progressive_read_fn
00013620 T png_set_read_fn
00013230 T png_set_read_status_fn
000065c0 T png_set_read_user_chunk_fn
00016d80 T png_set_read_user_transform_fn
00016c70 T png_set_rgb_to_gray
00016b00 T png_set_rgb_to_gray_fixed
000065e0 T png_set_rows
00005830 T png_set_sBIT
000056c0 T png_set_sCAL
00005fb0 T png_set_sPLT
00005860 T png_set_sRGB
00005880 T png_set_sRGB_gAMA_and_cHRM
0000c040 T png_set_shift
00003880 T png_set_sig_bytes
00015e30 T png_set_strip_16
00015e50 T png_set_strip_alpha
0001dfd0 T png_set_strip_error_numbers
0000bfd0 T png_set_swap
0000c160 T png_set_swap_alpha
00005df0 T png_set_tIME
00005e30 T png_set_tRNS
00016ac0 T png_set_tRNS_to_alpha
00005d90 T png_set_text
000063c0 T png_set_unknown_chunk_location
000061e0 T png_set_unknown_chunks
00006730 T png_set_user_limits
0000c6f0 T png_set_user_transform_info
000137c0 T png_set_write_fn
000159f0 T png_set_write_status_fn
00015a10 T png_set_write_user_transform_fn
000038f0 T png_sig_cmp
00011e70 T png_start_read_image
0001dcf0 T png_warning
0000cee0 T png_write_chunk
0000cd10 T png_write_chunk_data
0000ce60 T png_write_chunk_end
0000cc60 T png_write_chunk_start
000146d0 T png_write_destroy
00013f60 T png_write_end
000145a0 T png_write_flush
000144b0 T png_write_image
00013b20 T png_write_info
00013860 T png_write_info_before_PLTE
00015a30 T png_write_png
000141d0 T png_write_row
00014530 T png_write_rows
U pow
U stderr
U strlen
U strtod

我搜索了 png.h 文件:---

# locate png.h
/home/dinesh/qt_source/qt_source_x11/qt-everywhere-opensource-src-4.8.5/src/3rdparty/libpng/png.h
/usr/lib/syslinux/com32/include/png.h

现在 lib png 源也在 QT_source 中:---

/qt-everywhere-opensource-src-4.8.5/src/3rdparty/libpng$ ls
ANNOUNCE pngconf.h pnglibconf.h pngrtran.c pngwrite.c
CHANGES pngdebug.h pngmem.c pngrutil.c pngwtran.c
INSTALL pngerror.c pngpread.c pngset.c pngwutil.c
libpng-manual.txt pngget.c pngpriv.h pngstruct.h README
LICENSE png.h pngread.c pngtrans.c
png.c pnginfo.h pngrio.c pngwio.c

==================================== 编辑 ========== ================

我执行了这些步骤,都失败了:---

1> 我点击了以下链接 http://www.brunolinux.com/02-The_Terminal/ldconfig.html和 将以下行添加到 ld.so.conf 文件/lib/i386-linux-gnu/。然后我运行 ldconfig 命令。

我直接复制make的命令行结果,加上-lpng运行

qt-everywhere-opensource-src-4.8.5/tools/qvfb$ g++ -Wl,-rpath-link,/home/dinesh/qt_source/qt_source_x11/qt-everywhere-opensource-src-4.8.5/lib -Wl,-O1 -Wl,-rpath,/opt/Qt5.1.1/4.8.5_X11/gcc/lib -Wl,-rpath,/opt/Qt5.1.1/4.8.5_X11/gcc/lib -o ../../bin/qvfb .obj/release-shared/qvfb.o .obj/release-shared/qvfbview.o .obj/release-shared/qvfbratedlg.o .obj/release-shared/main.o .obj/release-shared/qanimationwriter.o .obj/release-shared/qvfbprotocol.o .obj/release-shared/qvfbshmem.o .obj/release-shared/qvfbmmap.o .obj/release-shared/qlock.o .obj/release-shared/qwslock.o .obj/release-shared/qwssignalhandler.o .obj/release-shared/deviceskin.o .obj/release-shared/qvfbx11view.o .obj/release-shared/x11keyfaker.o .obj/release-shared/moc_qvfb.o .obj/release-shared/moc_qvfbview.o .obj/release-shared/moc_qvfbratedlg.o .obj/release-shared/moc_gammaview.o .obj/release-shared/moc_qvfbprotocol.o .obj/release-shared/moc_qvfbshmem.o .obj/release-shared/moc_qvfbmmap.o .obj/release-shared/moc_deviceskin.o .obj/release-shared/moc_qvfbx11view.o .obj/release-shared/moc_x11keyfaker.o .obj/release-shared/qrc_ClamshellPhone.o .obj/release-shared/qrc_SmartPhone2.o .obj/release-shared/qrc_SmartPhone.o .obj/release-shared/qrc_SmartPhoneWithButtons.o .obj/release-shared/qrc_TouchscreenPhone.o .obj/release-shared/qrc_PortableMedia.o .obj/release-shared/qrc_S60-QVGA-Candybar.o .obj/release-shared/qrc_S60-nHD-Touchscreen.o .obj/release-shared/qrc_qvfb.o   -lpng  -L/home/dinesh/qt_source/qt_source_x11/qt-everywhere-opensource-src-4.8.5/lib -L/usr/X11R6/lib -lXtst -lQtOpenGL -L/home/dinesh/qt_source/qt_source_x11/qt-everywhere-opensource-src-4.8.5/lib -L/usr/X11R6/lib -lQtGui -lQtCore -lGL -lpthread -lXext -lX11 -lm
/usr/bin/ld: cannot find -lpng
collect2: ld returned 1 exit status
make: *** [../../bin/qvfb] Error 1

2> 上面的步骤没有用,所以我执行了下面的步骤。我修改了QT的qvfb.pro文件,最后添加了选项LIBS += -lpng

qt-everywhere-opensource-src-4.8.5/tools/qvfb$ sudo make
/home/dinesh/qt_source/qt_source_x11/qt-everywhere-opensource-src-4.8.5/bin/qmake -spec ../../mkspecs/linux-g++ -o Makefile qvfb.pro
g++ -Wl,-rpath-link,/home/dinesh/qt_source/qt_source_x11/qt-everywhere-opensource-src-4.8.5/lib -Wl,-O1 -Wl,-rpath,/opt/Qt5.1.1/4.8.5_X11/gcc/lib -Wl,-rpath,/opt/Qt5.1.1/4.8.5_X11/gcc/lib -o ../../bin/qvfb .obj/release-shared/qvfb.o .obj/release-shared/qvfbview.o .obj/release-shared/qvfbratedlg.o .obj/release-shared/main.o .obj/release-shared/qanimationwriter.o .obj/release-shared/qvfbprotocol.o .obj/release-shared/qvfbshmem.o .obj/release-shared/qvfbmmap.o .obj/release-shared/qlock.o .obj/release-shared/qwslock.o .obj/release-shared/qwssignalhandler.o .obj/release-shared/deviceskin.o .obj/release-shared/qvfbx11view.o .obj/release-shared/x11keyfaker.o .obj/release-shared/moc_qvfb.o .obj/release-shared/moc_qvfbview.o .obj/release-shared/moc_qvfbratedlg.o .obj/release-shared/moc_gammaview.o .obj/release-shared/moc_qvfbprotocol.o .obj/release-shared/moc_qvfbshmem.o .obj/release-shared/moc_qvfbmmap.o .obj/release-shared/moc_deviceskin.o .obj/release-shared/moc_qvfbx11view.o .obj/release-shared/moc_x11keyfaker.o .obj/release-shared/qrc_ClamshellPhone.o .obj/release-shared/qrc_SmartPhone2.o .obj/release-shared/qrc_SmartPhone.o .obj/release-shared/qrc_SmartPhoneWithButtons.o .obj/release-shared/qrc_TouchscreenPhone.o .obj/release-shared/qrc_PortableMedia.o .obj/release-shared/qrc_S60-QVGA-Candybar.o .obj/release-shared/qrc_S60-nHD-Touchscreen.o .obj/release-shared/qrc_qvfb.o -L/home/dinesh/qt_source/qt_source_x11/qt-everywhere-opensource-src-4.8.5/lib -L/usr/X11R6/lib -lXtst -lpng -lQtOpenGL -L/home/dinesh/qt_source/qt_source_x11/qt-everywhere-opensource-src-4.8.5/lib -L/usr/X11R6/lib -lQtGui -lQtCore -lGL -lpthread -lXext -lX11 -lm
/usr/bin/ld: cannot find -lpng
collect2: ld returned 1 exit status
make: *** [../../bin/qvfb] Error 1

============================= 编辑 =================

感谢大家的工作。

创建软链接(soft link)有效:--
ln -s/lib/i386-linux-gnu/libpng12.so.0/lib/i386-linux-gnu/libpng.so

这有效:---
-L/lib/i386-linux-gnu -lpng

您也可以直接修改您的 qvfb.pro 文件,而不是直接在命令行中输入:---LIBS = -L/lib/i386-linux-gnu -lpng

最佳答案

我遇到了同样的问题。如果您查看导致错误的链接 qvfb 的编译行,您会发现它只是缺少 -lpng 来指示与 libpng 的链接。这只是一种解决方法,但是一旦你运行了一次“make”,你就可以简单地复制并通过错误的编译行并在末尾添加 -lpng。它对我有用。

关于linux - qvfb 编译错误 - 对 `png_create_write_struct' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20365850/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com