libpng16.so.16错误

linux编译Opencv2.4.10时make之后出现类似以下错误的解决办法:

[ 36%] Linking CXX executable ../../bin/opencv_perf_highgui
/usr/bin/ld: warning: libpng16.so.16, needed by /anaconda/lib/libcairo.so.2, not found (try using -rpath or -rpath-link)
/anaconda/lib/libcairo.so.2: undefined reference to `png_create_read_struct@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_interlace_handling@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_IHDR@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_get_io_ptr@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_tRNS_to_alpha@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_longjmp_fn@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_gray_to_rgb@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_read_user_transform_fn@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_filler@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_get_valid@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_get_error_ptr@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_destroy_read_struct@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_get_IHDR@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_palette_to_rgb@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_write_info@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_bKGD@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_write_user_transform_fn@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_packing@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_read_fn@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_create_info_struct@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_read_end@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_read_update_info@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_write_image@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_write_end@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_expand_gray_1_2_4_to_8@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_create_write_struct@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_read_image@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_read_info@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_write_fn@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_destroy_write_struct@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_error@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_packswap@PNG16_0'
/anaconda/lib/libcairo.so.2: undefined reference to `png_set_strip_16@PNG16_0'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/opencv_perf_highgui] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_perf_highgui.dir/all] Error 2
make: *** [all] Error 2


首先确定电脑中有libpng16.so.16文件

将文件放入cmake后的文件夹lib/中。

如果问题没有解决,怎按照下面的来做:

找到对应的出错的文件夹的link.txt,如上述错误就找modules/highgui/CMakeFiles/opencv_perf_highgui.dir/link.txt文件,修改如下:

/usr/bin/c++      -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -Wno-deprecated-declarations    CMakeFiles/opencv_perf_highgui.dir/perf/perf_input.cpp.o CMakeFiles/opencv_perf_highgui.dir/perf/perf_main.cpp.o CMakeFiles/opencv_perf_highgui.dir/perf/perf_output.cpp.o  -o ../../bin/opencv_perf_highgui -rdynamic ../../lib/libopencv_ts.a ../../lib/libopencv_features2d.so.2.4.10 ../../lib/libopencv_video.so.2.4.10 -ldl -lm -lpthread -lrt ../../lib/libopencv_highgui.so.2.4.10 ../../lib/libopencv_flann.so.2.4.10 ../../lib/libopencv_imgproc.so.2.4.10 ../../lib/libopencv_core.so.2.4.10 /anaconda/lib/libpng16.so.16 -Wl,-rpath,/home/ice/software/opencv-2.4.10/build/lib 


此办法要修改好多文件,比较笨,但是能解决问题,有好的解决办法可以给我留个言。多谢。

你可能感兴趣的:(libpng16.so.16错误)