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 `void kfr::avx512::dft_initialize<double>(kfr::dft_plan<double>&)' #156

Closed xkzl closed 2 years ago

xkzl commented 2 years ago

I have been playing with some examples and I am facing an issue I don't know how to fix:

The code below is put in a file in examples directory and compiling returns:

/home/marcomeyer/Software/kfr/kfr/include/kfr/dft/fft.hpp:173: undefined reference to 'oid kfr::avx512::dft_initialize<double>(kfr::dft_plan<double>&)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [examples/CMakeFiles/window.dir/build.make:84: bin/window] Error 1
make[1]: *** [CMakeFiles/Makefile2:723: examples/CMakeFiles/window.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Any hint how I can fix it ?


#include <kfr/all.hpp>
using namespace kfr;

template <typename T>
void Print(const std::vector<kfr::complex<T>> &v, int n = 10)
{
        for(int i = 0, N = v.size(); i < N; i++) {
                std::cout << v[i].real() << "+" << v[i].imag() << "i\t";
                if(i && (i%n == 0 || i == N-1)) std::cout << std::endl;
        }
}

template <typename T>
inline void Print(const std::vector<T> &v, int n = 10)
{
        for(int i = 0, N = v.size(); i < N; i++) {
                std::cout << v[i] << "\t";
                if(i && (i%n == 0 || i == N-1)) std::cout << std::endl;
        }
}

template <typename T, kfr::univector_tag Tag>
inline void Print(kfr::univector<T, Tag> u, int n = 10)
{
        for(int i = 0, N = u.size(); i < N; i++) {
                std::cout << u[i] << "\t";
                if(i && (i%n == 0 || i == N-1)) std::cout << std::endl;
        }
}

template <typename T>
std::vector<kfr::complex<T>> _dft(const std::vector<kfr::complex<T>>& input)
{
        kfr::dft_plan_ptr<T> dft = kfr::dft_cache::instance().get(kfr::ctype_t<T>(), input.size());
        std::vector<kfr::complex<T>> output(input.size(), std::numeric_limits<T>::quiet_NaN());
        std::vector<kfr::u8> temp(input.size());

        dft->execute(&output[0], &input[0], &temp[0]);
        return output;
}

int main()
{
    println(library_version());

    int n = 256;

    //Fill the histogram with function values
    std::vector<complex<double>> d;
    for (int i=0; i<n; i++)
        d.push_back(complex<double>(i));

    Print(_dft(d));

    kfr::univector<double> w = kfr::window_hann(100);
    Print(w);

    return 0;
}
xkzl commented 2 years ago

I was missing kfr_dft library in CMakeLists.txt