问题描述:
这里复制一下问题,来源:https://www.cnblogs.com/guiguzhixing/p/6347602.html
g++ -o opencv_test opencv_test.cpp `pkg-config --cflags --libs opencv` -Wall
/usr/bin/ld: warning: libicui18n.so.54, needed by //home/yyh/anaconda2/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libicuuc.so.54, needed by //home/yyh/anaconda2/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libicudata.so.54, needed by //home/yyh/anaconda2/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libpng16.so.16, needed by //home/yyh/anaconda2/lib/libQt5Gui.so.5, not found (try using -rpath or -rpath-link)
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_clone_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_interlace_handling@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_IHDR@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_io_ptr@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_image_width@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `u_strToLower_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_longjmp_fn@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_gray_to_rgb@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_setMillis_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_bgr@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_valid@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_fromUnicode_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_write_rows@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_getDefaultName_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_PLTE@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_sig_bytes@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_write_chunk@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_pHYs@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_destroy_read_struct@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_inDaylightTime_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_x_pixels_per_meter@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_read_row@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_tRNS@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_get_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_close_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_error_fn@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_openTimeZones_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_toUnicode_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `u_strToUpper_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_close_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_packing@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_read_end@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_getMaxCharSize_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_countAvailable_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_read_fn@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_write_end@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_invert_mono@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_write_fn@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_tRNS@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_create_write_struct@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_getDefaultTimeZone_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_error@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_destroy_write_struct@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_packswap@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_text@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_strip_16@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_create_read_struct@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_oFFs@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `uenum_next_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_getStandardName_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucol_setAttribute_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_PLTE@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_compression_level@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucol_strcoll_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_text@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_setSubstChars_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_filler@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_gAMA@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_getTimeZoneDisplayName_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_openCountryTimeZones_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_open_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucol_open_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_IHDR@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucol_close_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucol_getSortKey_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_expand@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_getAvailableName_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_write_info@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_getDSTSavings_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_openTimeZoneIDEnumeration_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucal_open_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `u_errorName_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `uenum_close_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_oFFs@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_create_info_struct@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_read_update_info@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_write_image@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_gamma@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_getAlias_54'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_y_pixels_per_meter@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_image_height@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_read_image@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_read_info@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_set_gAMA@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Gui.so.5: undefined reference to `png_get_channels@PNG16_0'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_compareNames_54'
//home/yyh/anaconda2/lib/libQt5Core.so.5: undefined reference to `ucnv_countAliases_54'
问题解释:就是调用opencv的时候去查找Qt库,发现找不到。
原因:“QT安装在了用户目录下,没有配置环境变量,出现了链接错误”
解决办法:
ldd 上面提示的路径/libQt5Core.so.5
查找其指向的路径,然后将其添加到路径,打开终端输入:
export LD_LIBRARY_PATH= 上面ldd的路径结果