airockchip / rknn_model_zoo

Apache License 2.0
996 stars 182 forks source link

使用build-linux.sh执行编译whisper出现问题,libfftw3f.a库的问题 #158

Open 7288Fzq opened 2 months ago

7288Fzq commented 2 months ago

使用build-linux.sh执行编译whisper出现问题: image

指令内容: ./build-linux.sh -t rk3588 -a aarch64 -d whisper

7288Fzq commented 2 months ago

下午研究了下解决了问题。,应该是不在同一台机器上编译静态库导致的问题 需要重新编译libsndfile库和libfftw库。

image

https://github.com/libsndfile/libsndfile https://fftw.org/download.html

然后直接采用./configure 指令,make ,make install即可得到能够正常使用的库

参考cmake: ./configure --enable-shared --enable-static CFLAGS="-fPIC" --prefix=/home/linaro/libsndfile ./configure --enable-shared --enable-static CFLAGS="-fPIC" --prefix=/home/linaro/fftw/ --enable-float

特别注意需要 ### --enable-float

7288Fzq commented 2 months ago

有个新的问题是运行没有结果: image

jxx-xi commented 2 months ago

1.关于库的问题,请使用https://github.com/airockchip/rknn_model_zoo/blob/main/docs/Compilation_Environment_Setup_Guide_CN.md 中推荐的版本,其他版本有可能出现不兼容情况 2.看你截图信息,没更新到2.1.0吧,请更新toolkit和runtime到2.1.0再试试

swdee commented 2 months ago

For English readers, the 3rdparty/fftw/Linux/aarch64/libfftw3f.a and 3rdparty/libsndfile/Linux/aarch64/libsndfile.a files shipped by Rockchip were not compiled with -fPIC enabled so building the whisper demo fails with:

[100%] Linking CXX executable rknn_whisper_demo
/usr/bin/ld: /home/rock/devel/rknn_model_zoo/3rdparty/fftw/Linux/aarch64/libfftw3f.a(assert.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol stdout@@GLIBC_2.17' which may bind externally can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/rock/devel/rknn_model_zoo/3rdparty/fftw/Linux/aarch64/libfftw3f.a(assert.o)(.text+0x14): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol stdout@@GLIBC_2.17'
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/rknn_whisper_demo.dir/build.make:154: rknn_whisper_demo] Error 1
make[1]: *** [CMakeFiles/Makefile2:143: CMakeFiles/rknn_whisper_demo.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

To fix the problem use the following steps.

Recompile fftw

wget https://fftw.org/fftw-3.3.10.tar.gz
tar -zxvf fftw-3.3.10.tar.gz
cd fftw-3.3.10/
./configure CFLAGS="-fPIC" --enable-float --enable-shared
make

Copy the fftw libraries over the rockchip ones.

cp .libs/libfftw3f.a <path to rknn_model_zoo>/3rdparty/fftw/Linux/aarch64/
cp ./api/fftw3.h <path to rknn_model_zoo>/3rdparty/fftw/include/

Recompile libsndfile

wget https://github.com/libsndfile/libsndfile/archive/refs/tags/1.2.2.tar.gz
tar -zxvf 1.2.2.tar.gz
cd libsndfile-1.2.2
mkdir build
cd build
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_C_FLAGS="-fPIC"
make

Copy the libsndfile libraries over the rockchip ones.

cp ./libsndfile.a <path to rknn_model_zoo>/3rdparty/libsndfile/Linux/aarch64/
cp ../include/sndfile.h <path to rknn_model_zoo>/3rdparty/libsndfile/include/
cp ../include/sndfile.hh <path to rknn_model_zoo>/3rdparty/libsndfile/include/

Now you can build the whisper demo

./build-linux.sh -t rk3588 -a aarch64 -b Debug -d whisper