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

fft.hpp:173: undefined reference to `void kfr::sse2::dft_initialize<float>(kfr::dft_plan<float>&)' #161

Closed phlorek closed 1 year ago

phlorek commented 1 year ago

Hello,

I've been trying to implement KFR into my own project which requires FFT usage. I have compiled kfr_dft and included it in CMake:

cmake_minimum_required(VERSION 3.24.0)
project(prtest VERSION 1.0.0)

add_library(kfr STATIC IMPORTED)
set_property(TARGET kfr IMPORTED_LOCATION <path-to-kfr_dft>)
include_directories(${CMAKE_SOURCE_DIR}/kfr/include)
add_executable(main main.cpp)
target_link_libraries(main kfr_dft)

Minimal reproducable example of my code:

#include <iostream>
#include <dft.hpp>

#include <iostream>
#include <dft.hpp>

int main()
{
    kfr::univector<kfr::complex<cometa::f32>> data;
    //...some data inputs

    kfr::univector<kfr::complex<cometa::f32>> freq;
    freq = kfr::dft(data);
    return 0;
}

CMake does not flag anything against my syntax however compiling the code results in the error presented in the title of this issue. I've looked through fft.hpp file and dft_initialize does not seem to be linked with its definition in any particular way which would explain the error. I have attempted at linking ftt-templates.hpp into my project, but obviously that did not result in anything in particular since the fft.hpp does not have any #includes to files placed in impl subdirectory of dft directory. Is there a way to fix this issue?

I'm working on Windows using VSCode with GCC compiler. The kfr libs were compiled using Clang

Thank you so much for your help!

durfejs commented 1 year ago

I have the same issue...

phlorek commented 1 year ago

@durfejs, totally forgot about my issue, but managed to solve it. Include <dft/impl/dft-impl.hpp> as well as <dft/impl/fft-impl.hpp> alongside with a change of compiler (GCC seems to still have some issues) to Clang (I recommend Clang using MSYS2 if you are working on Windows as well - no need for installing additional packages).

durfejs commented 1 year ago

@phlorek 👍 that solved the problem