breakfastquay / rubberband

Official mirror of Rubber Band Library, an audio time-stretching and pitch-shifting library.
http://breakfastquay.com/rubberband/
GNU General Public License v2.0
561 stars 89 forks source link

Build rubberband cli failed with errors about openmp #90

Open LilyWangLL opened 1 year ago

LilyWangLL commented 1 year ago

I use rubberband 3.2.1 on vcpkg, when I build rubberband[cli] on Linux, it built failed with the following errors:

/usr/bin/c++  -o rubberband-r3 rubberband-r3.p/main_main.cpp.o -L/home/user/lily/0725/installed/x64-linux/debug/lib -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group librubberband_objlib.a -lsleefdft -lsleef /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libsamplerate.a -lm -pthread /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libsndfile.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libmp3lame.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libFLAC.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libvorbisenc.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libvorbis.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libogg.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libopus.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libmpg123.a -lsleefdft -lsleef -Wl,--end-group
FAILED: rubberband-r3
/usr/bin/c++  -o rubberband-r3 rubberband-r3.p/main_main.cpp.o -L/home/user/lily/0725/installed/x64-linux/debug/lib -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group librubberband_objlib.a -lsleefdft -lsleef /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libsamplerate.a -lm -pthread /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libsndfile.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libmp3lame.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libFLAC.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libvorbisenc.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libvorbis.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libogg.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libopus.a /home/user/lily/0725/installed/x64-linux/debug/lib/pkgconfig/../../lib/libmpg123.a -lsleefdft -lsleef -Wl,--end-group
/usr/bin/ld: /home/user/lily/0725/installed/x64-linux/debug/lib/libsleefdft.a(dftcommon.c.o): in function `initPlanMapLock':
/home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:183: undefined reference to `GOMP_critical_start'
/usr/bin/ld: /home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:187: undefined reference to `omp_init_lock'
/usr/bin/ld: /home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:183: undefined reference to `GOMP_critical_end'
/usr/bin/ld: /home/user/lily/0725/installed/x64-linux/debug/lib/libsleefdft.a(dftcommon.c.o): in function `PlanManager_loadMeasurementResultsP':
/home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:330: undefined reference to `omp_set_lock'
/usr/bin/ld: /home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:337: undefined reference to `omp_unset_lock'
/usr/bin/ld: /home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:354: undefined reference to `omp_unset_lock'
/usr/bin/ld: /home/user/lily/0725/installed/x64-linux/debug/lib/libsleefdft.a(dftcommon.c.o): in function `PlanManager_saveMeasurementResultsP':
/home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:365: undefined reference to `omp_set_lock'
/usr/bin/ld: /home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:371: undefined reference to `omp_unset_lock'
/usr/bin/ld: /home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:386: undefined reference to `omp_unset_lock'
/usr/bin/ld: /home/user/lily/0725/installed/x64-linux/debug/lib/libsleefdft.a(dftcommon.c.o): in function `PlanManager_loadMeasurementResultsT':
/home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:398: undefined reference to `omp_set_lock'
/usr/bin/ld: /home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:406: undefined reference to `omp_unset_lock'
/usr/bin/ld: /home/user/lily/0725/installed/x64-linux/debug/lib/libsleefdft.a(dftcommon.c.o): in function `PlanManager_saveMeasurementResultsT':
/home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:419: undefined reference to `omp_set_lock'
/usr/bin/ld: /home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dftcommon.c:429: undefined reference to `omp_unset_lock'
/usr/bin/ld: /home/user/lily/0725/installed/x64-linux/debug/lib/libsleefdft.a(dft.c.o): in function `omp_thread_count':
/home/user/lily/0725/buildtrees/sleef/src/3.5.1-7f3a2e645a.clean/src/dft/dft.c:237: undefined reference to `GOMP_parallel'

It seems need link -fopenmp, but rubberband depends on sleef, and sleef have flags -fopenmp, the version of sleef is 3.5.1. Could someone help me to take a look this issue? If need any logs, please ping me. Thanks in advance.

cannam commented 1 year ago

The Sleef support in Rubber Band is relatively new and hasn't had a huge amount of real-world exposure yet, but the build system does attempt to use pkg-config to identify any dependencies it may have.

I guess that isn't working here, which could mean

  1. Sleef's pkg-config doesn't declare this dependency, or
  2. Sleef lacks a pkg-config description entirely, or
  3. Sleef is not normally built to use OpenMP but for some reason it has been wrongly enabled, or
  4. Rubber Band's build system has some error in how it handles the dependency

Only the last would be fixable in Rubber Band itself. So it is perhaps worth checking what Sleef provides by way of pkg-config support.

(It isn't appropriate for Rubber Band's build system to simply guess at the flags or libraries required for any given dependency, at least when they are not universal - i.e. Sleef does not always use OpenMP and we do not want to add this dependency unnecessarily since Rubber Band never uses it itself.)

I guess you, or somebody, explicitly requested Sleef support when building Rubber Band? (It doesn't get used by default, not even when the libraries are present.) If so, presumably that means some custom Meson command line args have been provided already when configuring Rubber Band (such as -Dfft=sleef). So a workaround would be to add another argument that gives the OpenMP dependency explicitly, e.g. -Dcpp_link_args=-fopenmp. Or to drop the Sleef configuration and use the built-in FFT or another library.

diizzyy commented 1 year ago

Sleef is kinda dead right now (https://github.com/shibatch/sleef/issues/442) and there are quite a bit of bugs fixed (not all known though) using bleeding edge compared to release. Might be worth doing a quick evaluation if it offers any type of performance enhancement otherwise drop support completely.

cannam commented 11 months ago

I mentioned this in the linked vcpkg issue, but Sleef DFT is measurably faster than other open source options, so provided it produces the right results with Rubber Band (which in my limited tests it does) it could be a valuable option for certain uses even if it isn't actively supported.

But the above comment does suggest it might not be the wisest choice for general use when packaging Rubber Band.

diizzyy commented 11 months ago

Have you considered KFR which seems pretty fast? https://github.com/kfrlib/kfr