kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.64k stars 252 forks source link

undefined reference to `kfr::scalar_constants<double>::log_2' #159

Closed Aziz891 closed 2 years ago

Aziz891 commented 2 years ago

i get the following error when linking the dft.cpp example

[build] : && /bin/clang++-10  -g  -rdynamic CMakeFiles/demo.dir/test2.cpp.o  -o demo  kfr/libkfr_io.a  kfr/libkfr_dft.a  -lstdc++  -lpthread  -lm && :
[build] /bin/ld: CMakeFiles/demo.dir/test2.cpp.o: in function `kfr::avx2::vec<double, 4ul> kfr::avx2::intrinsics::log<4ul>(kfr::avx2::vec<double, 4ul> const&)':
[build] /home/aziz/Projects/audio_pulse/build/../kfr/include/kfr/io/../base/../math/impl/log_exp.hpp:121: undefined reference to `kfr::scalar_constants<double>::qnan'
[build] /bin/ld: /home/aziz/Projects/audio_pulse/build/../kfr/include/kfr/io/../base/../math/impl/log_exp.hpp:132: undefined reference to `kfr::scalar_constants<double>::log_2'
[build] /bin/ld: CMakeFiles/demo.dir/test2.cpp.o: in function `kfr::avx2::vec<double, 1ul> kfr::avx2::intrinsics::log<1ul>(kfr::avx2::vec<double, 1ul> const&)':
[build] /home/aziz/Projects/audio_pulse/build/../kfr/include/kfr/io/../base/../math/impl/log_exp.hpp:121: undefined reference to `kfr::scalar_constants<double>::qnan'
[build] /bin/ld: /home/aziz/Projects/audio_pulse/build/../kfr/include/kfr/io/../base/../math/impl/log_exp.hpp:132: undefined reference to `kfr::scalar_constants<double>::log_2'

and this my CMakeLists.txt file

cmake_minimum_required(VERSION 3.0.0)
project(demo VERSION 0.1.0)

include(CTest)
enable_testing()

add_executable(demo test2.cpp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

add_subdirectory(kfr) 
target_link_libraries(demo kfr kfr_io kfr_dft use_arch ) 

any help would be highly appreciated

dancazarin commented 2 years ago

Hi, It looks like C++17 is not enabled properly. What is the version of your cmake installation? CMAKE_CXX_STANDARD is introduced in 3.1 but your CMakeLists requires 3.0. 3.10 or newer is recommended for KFR.

Aziz891 commented 2 years ago

Works like a charm now! I also had to add this line set_property(TARGET demo PROPERTY CXX_STANDARD 17) for the -std=gnu++17 flag to appear in the compile command.

Thanks a lot.