Tencent / ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform
Other
20.14k stars 4.14k forks source link

Ubuntu20.04编译NCNN报错:/usr/bin/ld: mish_x86_avx2.cpp:(.text+0x74d): undefined reference to `__logf_finite' #4033

Open victorming666 opened 2 years ago

victorming666 commented 2 years ago

如题所示,Ubuntu20.04+GCC7.5编译NCNN报链接错误: /usr/bin/ld: ../ncnn/lib/libncnn.a(mish_x86_avx2.cpp.o): in function ncnn::Mish_x86_avx2::forward_inplace(ncnn::Mat&, ncnn::Option const&) const [clo ne ._omp_fn.2]': mish_x86_avx2.cpp:(.text+0x740): undefined reference toexpf_finite' /usr/bin/ld: mish_x86_avx2.cpp:(.text+0x74d): undefined reference to __logf_finite' /usr/bin/ld: mish_x86_avx2.cpp:(.text+0x781): undefined reference toexpf_finite' /usr/bin/ld: mish_x86_avx2.cpp:(.text+0x78e): undefined reference to __logf_finite' /usr/bin/ld: mish_x86_avx2.cpp:(.text+0x7c7): undefined reference to__expf_finite' /usr/bin/ld: mish_x86_avx2.cpp:(.text+0x7d4): undefined reference to __logf_finite' /usr/bin/ld: ../ncnn/lib/libncnn.a(mish_x86_avx.cpp.o): in functionncnn::Mish_x86_avx::forward_inplace(ncnn::Mat&, ncnn::Option const&) const [clone ._omp_fn.2]' libc版本是2.31,原来预装的GCC是9.3,降为7.5,编译时报上述链接错误。

zchrissirhcz commented 2 years ago

Tested with the latest of ncnn, can't reproduce the reported error.

OS

Ubuntu 20.04

(base) zz@home% uname -a
Linux home 5.8.0-50-generic #56~20.04.1-Ubuntu SMP Mon Apr 12 21:46:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

GCC version

sudo apt install gcc-7 g++-7
(base) zz@home% gcc-7 --version
gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(base) zz@home% g++-7 --version
g++-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ncnn version

(base) zz@home% git log -n 1 --pretty=oneline
627be612c671914c7c8a25e44d705517af91c020 (HEAD -> master, upstream/master) fix(examples): optimize nms_sorted_bboxes (#4030)

How I build ncnn with gcc-7 and g++-7

cd ~/work/ncnn
git pull
mkdir build
cd build
export CC=gcc-7
export CXX=g++-7

cmake ../.. -GNinja \
    -DCMAKE_BUILD_TYPE=Release \
    -DNCNN_OPENMP=ON \
    -DNCNN_SHARED_LIB=OFF \
    -DNCNN_BUILD_TESTS=OFF
cmake --build .