东方耀AI技术分享

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 1847|回复: 8
打印 上一主题 下一主题

[C/C++] 源码编译安装C++的DSP框架kfr-4.2.0

[复制链接]

1365

主题

1856

帖子

1万

积分

管理员

Rank: 10Rank: 10Rank: 10

积分
14451
QQ
跳转到指定楼层
楼主
发表于 2021-10-19 10:56:03 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式


源码编译安装C++的DSP框架kfr-4.2.0


https://github.com/kfrlib/kfr
Documentation home:
https://www.kfrlib.com/newdocs/


官方测试通过的:
(Intel AVX2) Ubuntu 18.04 / gcc-7.x / clang version 7.0.0 (tags/RELEASE_700/final)


Ubuntu 18.04下安装多版本clang并灵活切换
jiang@jiang-Ubuntu:~$ sudo apt install clang
正在读取软件包列表... 完成
正在分析软件包的依赖关系树      
正在读取状态信息... 完成      
clang 已经是最新版 (1:6.0-41~exp5~ubuntu1)。
查看版本号:
clang --version
clang++ --version
我的是:clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)


gcc --version
g++ --version
我的版本是:g++ (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0


网上有人说:这个库最坑的是要使用clang7.0往上才能用,所以开始修改版本了:
sudo apt install clang-7   安装后:clang-7 已经是最新版 (1:7-3~ubuntu0.18.04.1)
Clang不同版本的切换:类似的http://www.ai111.vip/thread-1052-1-1.html
ls /usr/bin/clang*
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-7 30
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 60


sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-7 30
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-6.0 60


sudo update-alternatives --config clang      键入选择的编号
sudo update-alternatives --config clang++    键入选择的编号


再次查看版本号:
clang --version
clang++ --version
我的是:clang version 7.0.0-3~ubuntu0.18.04.1 (tags/RELEASE_700/final)








安装步骤:
mkdir build && cd build
cmake -DENABLE_TESTS=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release ..
make -j8
测试一下:
cd <path_to_cmake_build_directory>
cd tests
ctest -V
安装到系统:
sudo make install
sudo ldconfig





  1. jiang@jiang-Ubuntu:~/jjj_kfrlib_works/kfr-4.2.0/build$ sudo make install
  2. [sudo] jiang 的密码:
  3. [  3%] Built target detect_cpu
  4. [ 13%] Built target kfr_dft
  5. [ 16%] Built target kfr_io
  6. [ 19%] Built target ccv
  7. [ 22%] Built target fir
  8. [ 26%] Built target biquads
  9. [ 29%] Built target window
  10. [ 32%] Built target dft
  11. [ 36%] Built target iir
  12. [ 39%] Built target sample_rate_conversion
  13. [ 45%] Built target multiarch
  14. [ 93%] Built target all_tests
  15. [ 96%] Built target ebu_test
  16. [100%] Built target sample_rate_converter
  17. Install the project...
  18. -- Install configuration: "Release"
  19. -- Installing: /usr/local/lib/libkfr_io.a
  20. -- Installing: /usr/local/lib/libkfr_dft.a
  21. -- Up-to-date: /usr/local/include/kfr
  22. -- Installing: /usr/local/include/kfr/all.hpp
  23. -- Installing: /usr/local/include/kfr/io.hpp
  24. -- Up-to-date: /usr/local/include/kfr/runtime
  25. -- Installing: /usr/local/include/kfr/runtime/cpuid.hpp
  26. -- Installing: /usr/local/include/kfr/runtime/cpuid_auto.hpp
  27. -- Installing: /usr/local/include/kfr/capi.h
  28. -- Up-to-date: /usr/local/include/kfr/base
  29. -- Installing: /usr/local/include/kfr/base/univector.hpp
  30. -- Installing: /usr/local/include/kfr/base/small_buffer.hpp
  31. -- Installing: /usr/local/include/kfr/base/generators.hpp
  32. -- Installing: /usr/local/include/kfr/base/filter.hpp
  33. -- Installing: /usr/local/include/kfr/base/fraction.hpp
  34. -- Installing: /usr/local/include/kfr/base/memory.hpp
  35. -- Installing: /usr/local/include/kfr/base/reduce.hpp
  36. -- Installing: /usr/local/include/kfr/base/pointer.hpp
  37. -- Installing: /usr/local/include/kfr/base/expression.hpp
  38. -- Installing: /usr/local/include/kfr/base/basic_expressions.hpp
  39. -- Installing: /usr/local/include/kfr/base/random.hpp
  40. -- Installing: /usr/local/include/kfr/base/function_expressions.hpp
  41. -- Installing: /usr/local/include/kfr/base/sort.hpp
  42. -- Installing: /usr/local/include/kfr/base/conversion.hpp
  43. -- Installing: /usr/local/include/kfr/dsp.hpp
  44. -- Up-to-date: /usr/local/include/kfr/simd
  45. -- Installing: /usr/local/include/kfr/simd/types.hpp
  46. -- Installing: /usr/local/include/kfr/simd/comparison.hpp
  47. -- Installing: /usr/local/include/kfr/simd/horizontal.hpp
  48. -- Up-to-date: /usr/local/include/kfr/simd/impl
  49. -- Installing: /usr/local/include/kfr/simd/impl/backend_clang.hpp
  50. -- Installing: /usr/local/include/kfr/simd/impl/basicoperators_generic.hpp
  51. -- Installing: /usr/local/include/kfr/simd/impl/basicoperators_clang.hpp
  52. -- Installing: /usr/local/include/kfr/simd/impl/specializations.i
  53. -- Installing: /usr/local/include/kfr/simd/impl/function.hpp
  54. -- Installing: /usr/local/include/kfr/simd/impl/intrinsics.h
  55. -- Installing: /usr/local/include/kfr/simd/impl/backend.hpp
  56. -- Installing: /usr/local/include/kfr/simd/impl/simd.hpp
  57. -- Installing: /usr/local/include/kfr/simd/impl/specialconstants.hpp
  58. -- Installing: /usr/local/include/kfr/simd/impl/backend_generic.hpp
  59. -- Installing: /usr/local/include/kfr/simd/impl/read_write.hpp
  60. -- Installing: /usr/local/include/kfr/simd/impl/operators.hpp
  61. -- Installing: /usr/local/include/kfr/simd/complex.hpp
  62. -- Installing: /usr/local/include/kfr/simd/read_write.hpp
  63. -- Installing: /usr/local/include/kfr/simd/vec.hpp
  64. -- Installing: /usr/local/include/kfr/simd/operators.hpp
  65. -- Installing: /usr/local/include/kfr/simd/platform.hpp
  66. -- Installing: /usr/local/include/kfr/simd/constants.hpp
  67. -- Installing: /usr/local/include/kfr/simd/digitreverse.hpp
  68. -- Installing: /usr/local/include/kfr/simd/mask.hpp
  69. -- Installing: /usr/local/include/kfr/simd/shuffle.hpp
  70. -- Installing: /usr/local/include/kfr/version.hpp
  71. -- Installing: /usr/local/include/kfr/math.hpp
  72. -- Installing: /usr/local/include/kfr/runtime.hpp
  73. -- Installing: /usr/local/include/kfr/config.h
  74. -- Installing: /usr/local/include/kfr/base.hpp
  75. -- Installing: /usr/local/include/kfr/simd.hpp
  76. -- Up-to-date: /usr/local/include/kfr/dsp
  77. -- Installing: /usr/local/include/kfr/dsp/fir_design.hpp
  78. -- Installing: /usr/local/include/kfr/dsp/dcremove.hpp
  79. -- Installing: /usr/local/include/kfr/dsp/iir_design.hpp
  80. -- Installing: /usr/local/include/kfr/dsp/delay.hpp
  81. -- Installing: /usr/local/include/kfr/dsp/ebu.hpp
  82. -- Installing: /usr/local/include/kfr/dsp/weighting.hpp
  83. -- Installing: /usr/local/include/kfr/dsp/units.hpp
  84. -- Installing: /usr/local/include/kfr/dsp/goertzel.hpp
  85. -- Installing: /usr/local/include/kfr/dsp/fir.hpp
  86. -- Installing: /usr/local/include/kfr/dsp/fracdelay.hpp
  87. -- Up-to-date: /usr/local/include/kfr/dsp/impl
  88. -- Installing: /usr/local/include/kfr/dsp/impl/dsp-impl.cpp
  89. -- Installing: /usr/local/include/kfr/dsp/waveshaper.hpp
  90. -- Installing: /usr/local/include/kfr/dsp/mixdown.hpp
  91. -- Installing: /usr/local/include/kfr/dsp/window.hpp
  92. -- Installing: /usr/local/include/kfr/dsp/sample_rate_conversion.hpp
  93. -- Installing: /usr/local/include/kfr/dsp/biquad_design.hpp
  94. -- Installing: /usr/local/include/kfr/dsp/biquad.hpp
  95. -- Installing: /usr/local/include/kfr/dsp/oscillators.hpp
  96. -- Installing: /usr/local/include/kfr/dsp/state_holder.hpp
  97. -- Installing: /usr/local/include/kfr/dsp/speaker.hpp
  98. -- Installing: /usr/local/include/kfr/dsp/special.hpp
  99. -- Installing: /usr/local/include/kfr/graphics.hpp
  100. -- Up-to-date: /usr/local/include/kfr/dft
  101. -- Installing: /usr/local/include/kfr/dft/reference_dft.hpp
  102. -- Installing: /usr/local/include/kfr/dft/convolution.hpp
  103. -- Installing: /usr/local/include/kfr/dft/cache.hpp
  104. -- Up-to-date: /usr/local/include/kfr/dft/impl
  105. -- Installing: /usr/local/include/kfr/dft/impl/dft-impl-f64.cpp
  106. -- Installing: /usr/local/include/kfr/dft/impl/convolution-impl.cpp
  107. -- Installing: /usr/local/include/kfr/dft/impl/ft.hpp
  108. -- Installing: /usr/local/include/kfr/dft/impl/fft-impl-f32.cpp
  109. -- Installing: /usr/local/include/kfr/dft/impl/dft-fft.hpp
  110. -- Installing: /usr/local/include/kfr/dft/impl/fft-impl-f64.cpp
  111. -- Installing: /usr/local/include/kfr/dft/impl/dft-templates.hpp
  112. -- Installing: /usr/local/include/kfr/dft/impl/dft-impl.hpp
  113. -- Installing: /usr/local/include/kfr/dft/impl/fft-impl.hpp
  114. -- Installing: /usr/local/include/kfr/dft/impl/dft-impl-f32.cpp
  115. -- Installing: /usr/local/include/kfr/dft/impl/fft-templates.hpp
  116. -- Installing: /usr/local/include/kfr/dft/impl/bitrev.hpp
  117. -- Installing: /usr/local/include/kfr/dft/fft.hpp
  118. -- Up-to-date: /usr/local/include/kfr/dft/data
  119. -- Installing: /usr/local/include/kfr/dft/data/bitrev.hpp
  120. -- Installing: /usr/local/include/kfr/dft/data/sincos.hpp
  121. -- Installing: /usr/local/include/kfr/dft.hpp
  122. -- Installing: /usr/local/include/kfr/cometa.hpp
  123. -- Up-to-date: /usr/local/include/kfr/io
  124. -- Installing: /usr/local/include/kfr/io/python_plot.hpp
  125. -- Installing: /usr/local/include/kfr/io/tostring.hpp
  126. -- Up-to-date: /usr/local/include/kfr/io/impl
  127. -- Installing: /usr/local/include/kfr/io/impl/audiofile-impl.cpp
  128. -- Installing: /usr/local/include/kfr/io/file.hpp
  129. -- Up-to-date: /usr/local/include/kfr/io/dr
  130. -- Installing: /usr/local/include/kfr/io/dr/README.txt
  131. -- Installing: /usr/local/include/kfr/io/dr/dr_mp3.h
  132. -- Installing: /usr/local/include/kfr/io/dr/dr_wav.h
  133. -- Installing: /usr/local/include/kfr/io/dr/dr_flac.h
  134. -- Installing: /usr/local/include/kfr/io/audiofile.hpp
  135. -- Up-to-date: /usr/local/include/kfr/graphics
  136. -- Installing: /usr/local/include/kfr/graphics/color.hpp
  137. -- Installing: /usr/local/include/kfr/graphics/scaled.hpp
  138. -- Installing: /usr/local/include/kfr/graphics/geometry.hpp
  139. -- Up-to-date: /usr/local/include/kfr/cometa
  140. -- Installing: /usr/local/include/kfr/cometa/function.hpp
  141. -- Installing: /usr/local/include/kfr/cometa/array.hpp
  142. -- Installing: /usr/local/include/kfr/cometa/result.hpp
  143. -- Installing: /usr/local/include/kfr/cometa/string.hpp
  144. -- Installing: /usr/local/include/kfr/cometa/memory.hpp
  145. -- Installing: /usr/local/include/kfr/cometa/range.hpp
  146. -- Installing: /usr/local/include/kfr/cometa/numeric.hpp
  147. -- Installing: /usr/local/include/kfr/cometa/cstring.hpp
  148. -- Installing: /usr/local/include/kfr/cometa/named_arg.hpp
  149. -- Installing: /usr/local/include/kfr/cometa/ctti.hpp
  150. -- Installing: /usr/local/include/kfr/cometa/tuple.hpp
  151. -- Installing: /usr/local/include/kfr/kfr.h
  152. -- Up-to-date: /usr/local/include/kfr/math
  153. -- Installing: /usr/local/include/kfr/math/abs.hpp
  154. -- Installing: /usr/local/include/kfr/math/interpolation.hpp
  155. -- Installing: /usr/local/include/kfr/math/atan.hpp
  156. -- Installing: /usr/local/include/kfr/math/hyperbolic.hpp
  157. -- Installing: /usr/local/include/kfr/math/round.hpp
  158. -- Installing: /usr/local/include/kfr/math/tan.hpp
  159. -- Installing: /usr/local/include/kfr/math/saturation.hpp
  160. -- Installing: /usr/local/include/kfr/math/asin_acos.hpp
  161. -- Installing: /usr/local/include/kfr/math/min_max.hpp
  162. -- Installing: /usr/local/include/kfr/math/sqrt.hpp
  163. -- Installing: /usr/local/include/kfr/math/logical.hpp
  164. -- Installing: /usr/local/include/kfr/math/sin_cos.hpp
  165. -- Up-to-date: /usr/local/include/kfr/math/impl
  166. -- Installing: /usr/local/include/kfr/math/impl/abs.hpp
  167. -- Installing: /usr/local/include/kfr/math/impl/atan.hpp
  168. -- Installing: /usr/local/include/kfr/math/impl/hyperbolic.hpp
  169. -- Installing: /usr/local/include/kfr/math/impl/round.hpp
  170. -- Installing: /usr/local/include/kfr/math/impl/tan.hpp
  171. -- Installing: /usr/local/include/kfr/math/impl/saturation.hpp
  172. -- Installing: /usr/local/include/kfr/math/impl/asin_acos.hpp
  173. -- Installing: /usr/local/include/kfr/math/impl/min_max.hpp
  174. -- Installing: /usr/local/include/kfr/math/impl/sqrt.hpp
  175. -- Installing: /usr/local/include/kfr/math/impl/logical.hpp
  176. -- Installing: /usr/local/include/kfr/math/impl/sin_cos.hpp
  177. -- Installing: /usr/local/include/kfr/math/impl/modzerobessel.hpp
  178. -- Installing: /usr/local/include/kfr/math/impl/select.hpp
  179. -- Installing: /usr/local/include/kfr/math/impl/gamma.hpp
  180. -- Installing: /usr/local/include/kfr/math/impl/log_exp.hpp
  181. -- Installing: /usr/local/include/kfr/math/impl/clamp.hpp
  182. -- Installing: /usr/local/include/kfr/math/complex_math.hpp
  183. -- Installing: /usr/local/include/kfr/math/modzerobessel.hpp
  184. -- Installing: /usr/local/include/kfr/math/select.hpp
  185. -- Installing: /usr/local/include/kfr/math/gamma.hpp
  186. -- Installing: /usr/local/include/kfr/math/compiletime.hpp
  187. -- Installing: /usr/local/include/kfr/math/log_exp.hpp
  188. -- Installing: /usr/local/include/kfr/math/clamp.hpp
  189. -- Up-to-date: /usr/local/include/kfr/testo
  190. -- Installing: /usr/local/include/kfr/testo/testo.hpp
  191. -- Installing: /usr/local/include/kfr/testo/assert.hpp
  192. -- Installing: /usr/local/include/kfr/testo/double_double.hpp
  193. -- Installing: /usr/local/include/kfr/testo/comparison.hpp
  194. -- Installing: /usr/local/include/kfr/testo/console_colors.hpp
  195. -- Installing: /usr/local/include/kfr/cident.h
  196. -- Installing: /usr/local/include/kfr/config.h
复制代码





运行官方的example报错:
/usr/bin/ld: 找不到 -lkfr
这样解决也不行:
include_directories("/usr/local/include/kfr/")

libkfr.a  libkfr.so 根本没有  这是一个接口库

# KFR library  interface library
# 这类库有属性,能install(),export和imported,但可能没有build过程
add_library(kfr INTERFACE)
//库的源文件可指定,也可用target_sources()后续指定
target_sources(kfr INTERFACE ${KFR_SRC})
target_include_directories(kfr INTERFACE include)
target_compile_options(kfr INTERFACE "$<$<CONFIGEBUG>:-DKFR_DEBUG>")


# 这里找不到 库: kfr  use_arch
# /usr/bin/ld: 找不到 -lkfr
# /usr/bin/ld: 找不到 -luse_arch
这个又可以?
# target_include_directories(biquads INTERFACE "/usr/local/include/kfr/")
# target_link_libraries(biquads INTERFACE "/usr/local/include/kfr/")


解决:
# 接口库 类似一个 纯头文件库
# target_link_libraries(iir INTERFACE "/usr/local/include/kfr/")




  1. CMakeFiles/iir.dir/iir.cpp.o:在函数‘kfr::sse2::vec<double, 1ul> kfr::sse2::intrinsics::exp<1ul>(kfr::sse2::vec<double, 1ul> const&)’中:
  2. iir.cpp:(.text._ZN3kfr4sse210intrinsics3expILm1EEENS0_3vecIdXT_EEERKS4_[_ZN3kfr4sse210intrinsics3expILm1EEENS0_3vecIdXT_EEERKS4_]+0x40):对‘kfr::scalar_constants<double>::recip_log_2’未定义的引用
  3. iir.cpp:(.text._ZN3kfr4sse210intrinsics3expILm1EEENS0_3vecIdXT_EEERKS4_[_ZN3kfr4sse210intrinsics3expILm1EEENS0_3vecIdXT_EEERKS4_]+0x3bd):对‘kfr::scalar_constants<double>::neginfinity’未定义的引用
  4. CMakeFiles/iir.dir/iir.cpp.o:在函数‘kfr::sse2::vec<double, 1ul> kfr::sse2::intrinsics::log<1ul>(kfr::sse2::vec<double, 1ul> const&)’中:
  5. iir.cpp:(.text._ZN3kfr4sse210intrinsics3logILm1EEENS0_3vecIdXT_EEERKS4_[_ZN3kfr4sse210intrinsics3logILm1EEENS0_3vecIdXT_EEERKS4_]+0x103):对‘kfr::scalar_constants<double>::qnan’未定义的引用
  6. iir.cpp:(.text._ZN3kfr4sse210intrinsics3logILm1EEENS0_3vecIdXT_EEERKS4_[_ZN3kfr4sse210intrinsics3logILm1EEENS0_3vecIdXT_EEERKS4_]+0x10d):对‘kfr::scalar_constants<double>::neginfinity’未定义的引用
  7. iir.cpp:(.text._ZN3kfr4sse210intrinsics3logILm1EEENS0_3vecIdXT_EEERKS4_[_ZN3kfr4sse210intrinsics3logILm1EEENS0_3vecIdXT_EEERKS4_]+0x2d4):对‘kfr::scalar_constants<double>::log_2’未定义的引用
复制代码

解决:cmake ..KFR 从 4.0 版开始需要 C++17 标准   SET(CMAKE_CXX_STANDARD 17)








接口库.png (73.2 KB, 下载次数: 133)

接口库.png
让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

0

主题

19

帖子

42

积分

新手上路

Rank: 1

积分
42
沙发
发表于 2021-10-31 20:57:06 | 只看该作者
GOODGOODGOODGOODGOODGOODGOODGOODGOODGOODGOOD
回复

使用道具 举报

0

主题

19

帖子

42

积分

新手上路

Rank: 1

积分
42
板凳
发表于 2021-10-31 20:57:52 | 只看该作者
SANADA 发表于 2021-10-31 20:57
GOODGOODGOODGOODGOODGOODGOODGOODGOODGOODGOOD

为了积分拼了GOODGOODGOODGOODGOODGOODGOODGOODGOODGOODGOOD
回复

使用道具 举报

0

主题

19

帖子

42

积分

新手上路

Rank: 1

积分
42
地板
发表于 2021-10-31 20:58:09 | 只看该作者
SANADA 发表于 2021-10-31 20:57
为了积分拼了GOODGOODGOODGOODGOODGOODGOODGOODGOODGOODGOOD

为了积分拼了GOODGOODGOODGOODGOODGOODGOODGOODGOODGOODGOOD
回复

使用道具 举报

0

主题

19

帖子

42

积分

新手上路

Rank: 1

积分
42
5#
发表于 2021-10-31 20:58:56 | 只看该作者
SANADA 发表于 2021-10-31 20:58
为了积分拼了GOODGOODGOODGOODGOODGOODGOODGOODGOODGOODGOOD

为了积分拼了GOODGOODGOODGOODGOODGOODGOODGOODGOODGOODGOOD
回复

使用道具 举报

0

主题

19

帖子

42

积分

新手上路

Rank: 1

积分
42
6#
发表于 2021-10-31 20:59:31 | 只看该作者
为了积分拼了GOODGOODGOODGOODGOODGOODGOODGOODGOODGOODGOOD
回复

使用道具 举报

0

主题

19

帖子

42

积分

新手上路

Rank: 1

积分
42
7#
发表于 2021-10-31 20:59:56 | 只看该作者
SANADA 发表于 2021-10-31 20:59
为了积分拼了GOODGOODGOODGOODGOODGOODGOODGOODGOODGOODGOOD

.................为了积分拼了GOODGOODGOODGOODGOODGOODGOODGOODGOODGOODGOOD
回复

使用道具 举报

0

主题

98

帖子

200

积分

中级会员

Rank: 3Rank: 3

积分
200
8#
发表于 2021-11-23 19:22:41 | 只看该作者
让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

0

主题

98

帖子

200

积分

中级会员

Rank: 3Rank: 3

积分
200
9#
发表于 2021-11-23 19:23:11 | 只看该作者
让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|人工智能工程师的摇篮 ( 湘ICP备2020019608号-1 )

GMT+8, 2024-6-18 21:58 , Processed in 0.199953 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表