编译 PCL 源文件时对 `png_set_longjmp_fn' 的未定义引用

undefined reference to `png_set_longjmp_fn' when compiling PCL source file

我正在尝试从源文件安装 PCL,但出现此错误“对 `png_set_longjmp_fn' 的未定义引用”。我搜索了很多但找不到解决方案。

其他信息:现在,在我的电脑中,我同时安装了libpng1.6 和libpng1.2。我无法删除 libpng1.2,因为其他应用程序依赖于它。

Scanning dependencies of target pcl_io_ply
Scanning dependencies of target pcl_pcd_convert_NaN_nan
Scanning dependencies of target pcl_people
Scanning dependencies of target pcl_octree
Scanning dependencies of target pcl_common
[  1%] Building CXX object io/CMakeFiles/pcl_io_ply.dir/src/ply/ply_parser.cpp.o
[  1%] [  1%] Building CXX object io/tools/CMakeFiles/pcl_pcd_convert_NaN_nan.dir/pcd_convert_NaN_nan.cpp.o
Building CXX object people/CMakeFiles/pcl_people.dir/src/hog.cpp.o
[  1%] Building CXX object octree/CMakeFiles/pcl_octree.dir/src/octree_inst.cpp.o
[  2%] [  2%] [  2%] [  2%] Building CXX object common/CMakeFiles/pcl_common.dir/src/io.cpp.o
Building CXX object common/CMakeFiles/pcl_common.dir/src/common.cpp.o
Building CXX object common/CMakeFiles/pcl_common.dir/src/pcl_base.cpp.o
Building CXX object common/CMakeFiles/pcl_common.dir/src/point_types.cpp.o
Linking CXX executable ../../bin/pcl_pcd_convert_NaN_nan
[  2%] Built target pcl_pcd_convert_NaN_nan
[  3%] Building CXX object common/CMakeFiles/pcl_common.dir/src/correspondence.cpp.o
Linking CXX shared library ../lib/libpcl_people.so
[  3%] Built target pcl_people
[  3%] Building CXX object common/CMakeFiles/pcl_common.dir/src/distances.cpp.o
[  3%] Building CXX object common/CMakeFiles/pcl_common.dir/src/parse.cpp.o
[  3%] Building CXX object common/CMakeFiles/pcl_common.dir/src/poses_from_matches.cpp.o
[  4%] Building CXX object common/CMakeFiles/pcl_common.dir/src/print.cpp.o
[  4%] Building CXX object common/CMakeFiles/pcl_common.dir/src/projection_matrix.cpp.o
[  4%] Building CXX object common/CMakeFiles/pcl_common.dir/src/time_trigger.cpp.o
[  5%] Building CXX object common/CMakeFiles/pcl_common.dir/src/gaussian.cpp.o
[  5%] Building CXX object common/CMakeFiles/pcl_common.dir/src/bearing_angle_image.cpp.o
[  5%] Building CXX object common/CMakeFiles/pcl_common.dir/src/range_image.cpp.o
[  5%] Building CXX object common/CMakeFiles/pcl_common.dir/src/range_image_planar.cpp.o
[  6%] Building C object common/CMakeFiles/pcl_common.dir/src/fft/kiss_fft.c.o
[  6%] Building C object common/CMakeFiles/pcl_common.dir/src/fft/kiss_fftr.c.o
Linking CXX shared library ../lib/libpcl_io_ply.so
[  6%] Built target pcl_io_ply
Scanning dependencies of target pcl_ply2obj
Scanning dependencies of target pcl_ply2raw
Scanning dependencies of target pcl_ply2ply
Scanning dependencies of target pcl_plyheader
[  7%] [  7%] [  7%] [  7%] Building CXX object io/tools/ply/CMakeFiles/pcl_ply2obj.dir/ply2obj.cpp.o
Building CXX object io/tools/ply/CMakeFiles/pcl_ply2raw.dir/ply2raw.cpp.o
Building CXX object io/tools/ply/CMakeFiles/pcl_ply2ply.dir/ply2ply.cpp.o
Building CXX object io/tools/ply/CMakeFiles/pcl_plyheader.dir/plyheader.cpp.o
Linking CXX executable ../../../bin/pcl_plyheader
[  7%] Built target pcl_plyheader
Linking CXX shared library ../lib/libpcl_common.so
[  7%] Built target pcl_common
Scanning dependencies of target pcl_kdtree
Scanning dependencies of target pcl_sample_consensus
Scanning dependencies of target pcl_io
Scanning dependencies of target pcl_example_check_if_point_is_valid
[  7%] [  7%] Building CXX object kdtree/CMakeFiles/pcl_kdtree.dir/src/kdtree_flann.cpp.o
Building CXX object examples/common/CMakeFiles/pcl_example_check_if_point_is_valid.dir/example_check_if_point_is_valid.cpp.o
[  7%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac.cpp.o
[  7%] Building CXX object io/CMakeFiles/pcl_io.dir/src/debayer.cpp.o
[  7%] Building CXX object io/CMakeFiles/pcl_io.dir/src/pcd_grabber.cpp.o
Linking CXX executable ../../../bin/pcl_ply2obj
[  7%] Built target pcl_ply2obj
Scanning dependencies of target pcl_example_copy_point_cloud
[  7%] Building CXX object examples/common/CMakeFiles/pcl_example_copy_point_cloud.dir/example_copy_point_cloud.cpp.o
Linking CXX executable ../../bin/pcl_example_check_if_point_is_valid
Linking CXX executable ../../../bin/pcl_ply2raw
[  7%] Built target pcl_example_check_if_point_is_valid
Scanning dependencies of target pcl_example_organized_point_cloud
[  7%] Built target pcl_ply2raw
[  7%] [  8%] Building CXX object examples/common/CMakeFiles/pcl_example_organized_point_cloud.dir/example_organized_point_cloud.cpp.o
Building CXX object io/CMakeFiles/pcl_io.dir/src/pcd_io.cpp.o
Linking CXX executable ../../bin/pcl_example_copy_point_cloud
[  8%] Built target pcl_example_copy_point_cloud
Scanning dependencies of target pcl_example_scope_time
[  9%] Building CXX object examples/common/CMakeFiles/pcl_example_scope_time.dir/example_scope_time.cpp.o
Linking CXX executable ../../../bin/pcl_ply2ply
[  9%] Built target pcl_ply2ply
[ 10%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_circle.cpp.o
Linking CXX executable ../../bin/pcl_example_organized_point_cloud
[ 10%] Built target pcl_example_organized_point_cloud
Scanning dependencies of target pcl_example_half_edge_mesh
[ 10%] Building CXX object examples/geometry/CMakeFiles/pcl_example_half_edge_mesh.dir/example_half_edge_mesh.cpp.o
Linking CXX executable ../../bin/pcl_example_scope_time
[ 10%] Built target pcl_example_scope_time
[ 10%] Building CXX object io/CMakeFiles/pcl_io.dir/src/vtk_io.cpp.o
Linking CXX executable ../../bin/pcl_example_half_edge_mesh
[ 10%] Built target pcl_example_half_edge_mesh
[ 10%] Building CXX object io/CMakeFiles/pcl_io.dir/src/ply_io.cpp.o
[ 11%] Building CXX object io/CMakeFiles/pcl_io.dir/src/ascii_io.cpp.o
[ 11%] Building CXX object io/CMakeFiles/pcl_io.dir/src/compression.cpp.o
[ 11%] Building CXX object io/CMakeFiles/pcl_io.dir/src/lzf.cpp.o
[ 11%] Building CXX object io/CMakeFiles/pcl_io.dir/src/lzf_image_io.cpp.o
[ 12%] Building CXX object io/CMakeFiles/pcl_io.dir/src/obj_io.cpp.o
Linking CXX shared library ../lib/libpcl_octree.so
[ 12%] Built target pcl_octree
[ 12%] Building CXX object io/CMakeFiles/pcl_io.dir/src/ifs_io.cpp.o
[ 12%] Building CXX object io/CMakeFiles/pcl_io.dir/src/image_grabber.cpp.o
[ 12%] Building CXX object io/CMakeFiles/pcl_io.dir/src/hdl_grabber.cpp.o
[ 13%] Building CXX object io/CMakeFiles/pcl_io.dir/src/robot_eye_grabber.cpp.o
[ 13%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_circle3d.cpp.o
[ 13%] Building CXX object io/CMakeFiles/pcl_io.dir/src/file_io.cpp.o
[ 13%] Building CXX object io/CMakeFiles/pcl_io.dir/src/io_exception.cpp.o
Linking CXX shared library ../lib/libpcl_kdtree.so
[ 14%] Building CXX object io/CMakeFiles/pcl_io.dir/src/vtk_lib_io.cpp.o
[ 14%] Built target pcl_kdtree
Scanning dependencies of target pcl_search
[ 14%] Building CXX object search/CMakeFiles/pcl_search.dir/src/search.cpp.o
[ 14%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_cylinder.cpp.o
[ 14%] Building CXX object io/CMakeFiles/pcl_io.dir/src/png_io.cpp.o
[ 14%] Building CXX object io/CMakeFiles/pcl_io.dir/src/image_rgb24.cpp.o
[ 14%] Building CXX object io/CMakeFiles/pcl_io.dir/src/image_yuv422.cpp.o
[ 15%] Building CXX object io/CMakeFiles/pcl_io.dir/src/image_ir.cpp.o
[ 15%] Building CXX object io/CMakeFiles/pcl_io.dir/src/image_depth.cpp.o
[ 15%] Building CXX object io/CMakeFiles/pcl_io.dir/src/dinast_grabber.cpp.o
[ 15%] Building CXX object io/CMakeFiles/pcl_io.dir/src/libpng_wrapper.cpp.o
[ 15%] Building CXX object search/CMakeFiles/pcl_search.dir/src/kdtree.cpp.o
[ 15%] Building CXX object search/CMakeFiles/pcl_search.dir/src/brute_force.cpp.o
[ 16%] Building CXX object search/CMakeFiles/pcl_search.dir/src/organized.cpp.o
[ 16%] Building CXX object search/CMakeFiles/pcl_search.dir/src/octree.cpp.o
[ 16%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_cone.cpp.o
Linking CXX shared library ../lib/libpcl_io.so
[ 17%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_line.cpp.o
[ 17%] Built target pcl_io
Scanning dependencies of target pcl_convert_pcd_ascii_binary
[ 17%] Building CXX object io/tools/CMakeFiles/pcl_convert_pcd_ascii_binary.dir/convert_pcd_ascii_binary.cpp.o
Scanning dependencies of target pcl_hdl_grabber
[ 17%] Building CXX object io/tools/CMakeFiles/pcl_hdl_grabber.dir/hdl_grabber_example.cpp.o
[ 17%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_stick.cpp.o
[ 17%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_normal_parallel_plane.cpp.o
Linking CXX executable ../../bin/pcl_convert_pcd_ascii_binary
../../lib/libpcl_io.so.1.7.2: undefined reference to `png_set_longjmp_fn'
collect2: error: ld returned 1 exit status
io/tools/CMakeFiles/pcl_convert_pcd_ascii_binary.dir/build.make:215: recipe for target 'bin/pcl_convert_pcd_ascii_binary' failed
make[2]: *** [bin/pcl_convert_pcd_ascii_binary] Error 1
CMakeFiles/Makefile2:565: recipe for target 'io/tools/CMakeFiles/pcl_convert_pcd_ascii_binary.dir/all' failed
make[1]: *** [io/tools/CMakeFiles/pcl_convert_pcd_ascii_binary.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 18%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_normal_plane.cpp.o
Linking CXX executable ../../bin/pcl_hdl_grabber
../../lib/libpcl_io.so.1.7.2: undefined reference to `png_set_longjmp_fn'
collect2: error: ld returned 1 exit status
io/tools/CMakeFiles/pcl_hdl_grabber.dir/build.make:215: recipe for target 'bin/pcl_hdl_grabber' failed
make[2]: *** [bin/pcl_hdl_grabber] Error 1
CMakeFiles/Makefile2:602: recipe for target 'io/tools/CMakeFiles/pcl_hdl_grabber.dir/all' failed
make[1]: *** [io/tools/CMakeFiles/pcl_hdl_grabber.dir/all] Error 2
[ 18%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_normal_sphere.cpp.o
Linking CXX shared library ../lib/libpcl_search.so
[ 18%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_plane.cpp.o
[ 18%] Built target pcl_search
[ 18%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_registration.cpp.o
[ 19%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_sphere.cpp.o
Linking CXX shared library ../lib/libpcl_sample_consensus.so
[ 19%] Built target pcl_sample_consensus
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2

CMakeLists.txt(检查 PCL 源文件夹)中的这种修改对我的情况有效。 (来自 CMake compile options for libpng)。您应该使用下面的 cmake 配置而不是原始配置。

# LibPNG
option(WITH_PNG "PNG file support" TRUE)
if(WITH_PNG)
    # search for pkg-config
    include (FindPkgConfig)
    if (NOT PKG_CONFIG_FOUND)
        message (FATAL_ERROR "pkg-config not found")
    endif ()

    # check for libpng
    pkg_check_modules (LIBPNG libpng16 REQUIRED)
    if (NOT LIBPNG_FOUND)
        message(FATAL_ERROR "You don't seem to have libpng16 development libraries installed")
    else ()
        include_directories (${LIBPNG_INCLUDE_DIRS})
        link_directories (${LIBPNG_LIBRARY_DIRS})
        link_libraries (${LIBPNG_LIBRARIES})
    endif ()
endif(WITH_PNG)