目录
1 报错
2 查找错误原因
2.1 方法一:ldd命令
2.2 方法二:警告信息里面
3 解决错误
3.1 libpng16.so.16 和 libbrotlidec.so.1 问题
3.2 libdevmmap.so 和 libslog.so库问题
3.3 剩余错误
3.3.1 libacllite.so错误解决
3.3.2 libtaclstream_va.so.1.0.0错误解决
1 报错
编译某个项目的C++代码时提示
/usr/bin/ld: warning: libpng16.so.16, needed by /opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libbrotlidec.so.1, needed by /opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libdevmmap.so, needed by /opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libslog.so, needed by /opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so, not found (try using -rpath or -rpath-link)
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_interlace_handling@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_get_io_ptr@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_longjmp_fn@PNG16_0'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so: undefined reference to `MapGetInRange'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so: undefined reference to `DlogErrorInner'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_palette_to_rgb@PNG16_0'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_cas8_sync'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `BrotliDecoderDecompress'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `std::condition_variable::wait(std::unique_lock<std::mutex>&)@GLIBCXX_3.4.30'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_packing@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_read_end@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_error@PNG16_0'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so: undefined reference to `DlogWarnInner'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_strip_16@PNG16_0'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_ldadd4_sync'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_swp4_sync'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_tRNS_to_alpha@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_filler@PNG16_0'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_swp8_sync'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `pthread_join@GLIBC_2.34'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so: undefined reference to `MapInsert'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_read_update_info@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_read_info@PNG16_0'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `std::__throw_bad_array_new_length()'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so: undefined reference to `DlogInfoInner'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so: undefined reference to `CheckLogLevel'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_gray_to_rgb@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_read_user_transform_fn@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_get_valid@PNG16_0'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `stat64@GLIBC_2.33'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `pthread_create@GLIBC_2.34'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_get_error_ptr@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_destroy_read_struct@PNG16_0'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `__libc_single_threaded@GLIBC_2.32'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_cas4_sync'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so: undefined reference to `MapErase'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_read_fn@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_set_expand_gray_1_2_4_to_8@PNG16_0'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so: undefined reference to `DlogDebugInner'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_create_read_struct@PNG16_0'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `std::__throw_bad_array_new_length()@GLIBCXX_3.4.29'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_get_IHDR@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_create_info_struct@PNG16_0'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `fstat@GLIBC_2.33'
/opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6: undefined reference to `png_read_image@PNG16_0'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so: undefined reference to `DlogEventInner'
collect2: error: ld returned 1 exit status
make[2]: *** [app/CMakeFiles/app.dir/build.make:587: ../app/bin/app] Error 1
make[2]: Leaving directory '/opt/chw/aclstream/build'
make[1]: *** [CMakeFiles/Makefile2:321: app/CMakeFiles/app.dir/all] Error 2
make[1]: Leaving directory '/opt/chw/aclstream/build'
make: *** [Makefile:130: all] Error 2
这种undefined reference的错误肯定是少了某个库,有两种方法去看缺少哪个库,
2 查找错误原因
2.1 方法一:ldd命令
2.2 方法二:警告信息里面
从上面的警告信息就能看到
/usr/bin/ld: warning: libpng16.so.16, needed by /opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libbrotlidec.so.1, needed by /opt/chw/aclstream/3rdparty/freetype/lib/linux_lib/libfreetype.so.6, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libdevmmap.so, needed by /opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libslog.so, needed by /opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libascend_hal.so, not found (try using -rpath or -rpath-link)
所以这很明显是缺少这几个库。
3 解决错误
3.1 libpng16.so.16 和 libbrotlidec.so.1 问题
这两个库可以看到都是libfreetype.so.6需要的,这让我想起来之前盒子上的libfreetype.so.6库是新的,而现在我在ARM服务器上这个libfreetype.so.6应该用旧的,所以我搜了下,
所以现在用的是6.18.1链接成libfreetype.so.6的,我只需要把libfreetype.so.6.14.0_backup链接成libfreetype.so.6即可。这样做之后上面两个错误消失。
3.2 libdevmmap.so 和 libslog.so库问题
这两个库我在华为ARM服务器上搜,直接就没有任何东西
然后我去华为盒子上搜
我发现他们的路径是 /usr/local/Ascend/driver/lib64/libdevmmap.so。那我感觉应该是因为这个华为服务器没有安装最新的驱动。
然后我去下载个昇腾710的最新驱动试试(华为老版本的驱动固件把310P称为710,现在同一都
是310系列了,所以我现在下载310P的)。
社区版-固件与驱动-昇腾社区
然后用下面的命令安装驱动
Usage: ./Ascend-hdk-310p-npu-driver_23.0.rc3_linux-aarch64.run [options]
Options:--help | -h Print this message--info Print embedded info : title, default target directory, embedded script ...--list Print the list of files in the archive--check Checks integrity and version dependency of the archive--quiet Quiet install mode, skip human-computer interactions--nox11 Do not spawn an xterm--noexec Do not run embedded script--extract=<path> Extract directly to a target directory (absolute or relative)Usually used with --noexec to just extract files without running--tar arg1 [arg2 ...] Access the contents of the archive through the tar command--repack [package_name] Build a precompiled kernel module for the currently running kernel and repackthe .run file. The new .run file will be renamed to package_name or appendthe string \"-custom\" to its name when package_name not present.--repack-path=<path> [package_name] Build a precompiled kernel module for the currently running kernel frompath and repack the .run file. The new .run file will be renamed topackage_name or append the string \"-custom\" to its name whenpackage_name not present.--full Install full mode--run Install run mode--devel Install devel mode--docker Install docker mode--upgrade Upgrade product immediately--vnpu_guest Install vnpu_guest mode, eg: ./xxx.run --full/--run --vnpu_guest--install-path=<path> Install to specific dir--install-username=<username> Install to specific username--install-usergroup=<usergroup> Install to specific usrgroup--uninstall Uninstall product--version Query the package version--install-for-all Install for all user--force Forcibly install, upgrade, or uninstall the package, and take effect after host restart
./Ascend-hdk-310p-npu-driver_23.0.rc3_linux-aarch64.run --full --force
驱动安装完之后需要重启才能生效。
然后toolkit包我也直接重新下载
社区版资源下载-资源下载中心-昇腾社区
然后也重新安装
./Ascend-cann-toolkit_7.0.0.alpha003_linux-aarch64.run --full --force
3.3 剩余错误
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_cas8_sync'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `std::condition_variable::wait(std::unique_lock<std::mutex>&)@GLIBCXX_3.4.30'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_ldadd4_sync'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_swp4_sync'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_swp8_sync'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `pthread_join@GLIBC_2.34'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `std::__throw_bad_array_new_length()'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `stat64@GLIBC_2.33'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `pthread_create@GLIBC_2.34'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `__libc_single_threaded@GLIBC_2.32'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_cas4_sync'
/opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so: undefined reference to `std::__throw_bad_array_new_length()@GLIBCXX_3.4.29'
collect2: error: ld returned 1 exit status
make[2]: *** [app/CMakeFiles/app.dir/build.make:587: ../app/bin/app] Error 1
make[2]: Leaving directory '/opt/chw/aclstream/build'
make[1]: *** [CMakeFiles/Makefile2:321: app/CMakeFiles/app.dir/all] Error 2
make[1]: Leaving directory '/opt/chw/aclstream/build'
make: *** [Makefile:130: all] Error 2
3.3.1 libacllite.so错误解决
这里面的这个库相关的报错,一看都是glibc相关的,那么感觉就是系统相关的,这让我想起来了这个库我没有重新编译,我用
ll /opt/chw/aclstream/3rdparty/ascend/lib/linux_lib/libacllite.so
看了下时间确实不对,那么这个库还是从华为盒子拷贝过来的版本,所以这里我去到/opt/chw/aclstream/3rdparty/ascend/acllite重新编译一下这个库,然后再次编译整个工程之后上面的libacllite.so相关的报错就没了。
3.3.2 libtaclstream_va.so.1.0.0错误解决
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_cas8_sync'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_ldadd4_sync'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_swp4_sync'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_swp8_sync'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `std::__throw_bad_array_new_length()'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_cas4_sync'
collect2: error: ld returned 1 exit status
make[2]: *** [app/CMakeFiles/app.dir/build.make:587: ../app/bin/app] Error 1
make[2]: Leaving directory '/opt/chw/aclstream/build'
make[1]: *** [CMakeFiles/Makefile2:321: app/CMakeFiles/app.dir/all] Error 2
make[1]: Leaving directory '/opt/chw/aclstream/build'
make: *** [Makefile:130: all] Error 2
我搜索undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_os找到
已解决: Re: icpx: error: linker command failed - Intel Community
然后按照他说的
sudo yum install libstdc++
然后报
我的centos上面的gcc最开始就是4.8.5的,然后我把gcc升级到了8.5.0,但是现在看libstdc++库并没有到8.5.0,还是老的,所以问题应该在这里。
cp /usr/local/lib64/libstdc++.so.6.0.25 /usr/lib64
cd /usr/lib64
ln -snf libstdc++.so.6.0.25 libstdc++.so.6
按照这个方法修改之后,问题依然存在,说明不是gcc版本的问题,然后这时候静下心来想一下,类似这种../../lib/libtaclstream_va.so.1.0.0: undefined reference to `__aarch64_swp8_sync'的错误其实可能问题并不在libtaclstream_va.so.1.0.0这个库,有可能是这个库他所依赖的其他库有问题,由于我的整个工程是从华为盒子拷贝到华为服务器的,所以可能就是libtaclstream_va.so.1.0.0依赖的一些库跟目前的华为服务器的一些库版本不太一样。
然后我突然想起来:/usr/bin/ld: /lib/aarch64-linux-gnu/libcairo.so.2: undefined reference to `FT_Done_MM_Var‘_libcairo undefined reference-CSDN博客
当初刚开始往盒子上面移植的时候,activeMQ这个库重新编译过,而现在直接把盒子上重新编译的库拷贝过来了,在华为服务器上库不匹配。
另外从这几个错误也能总结点经验:
1.很多时候报错在libtaclstream_va.so.1.0.0这个库,但是错误的原因可能是在另一个库。
2.如果库明明找到了,却还是提示未定义的东西,那很可能就是库不匹配。
参考文献:
/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21‘ not found (required by_libstdc++.so.6.0.25下载-CSDN博客
/usr/bin/ld: /lib/aarch64-linux-gnu/libcairo.so.2: undefined reference to `FT_Done_MM_Var‘_libcairo undefined reference-CSDN博客