简体   繁体   中英

Aquila/C++ compiling causes an undefined reference

I am trying to compile the code below using Aquila:

#include "fft.h"
Aquila::SpectrumType ffm::FFT() 
{
    // WAV file.
    Aquila::WaveFile mywav("sound.wav");
    // input signal parameters
    const std::size_t SIZE = 52117000;
    const Aquila::FrequencyType sampleFreq = mywav.getSampleFrequency();
    const Aquila::FrequencyType f1 = 125, f2 = 700;

    Aquila::SineGenerator sineGenerator1 = Aquila::SineGenerator(sampleFreq);
    sineGenerator1.setAmplitude(32).setFrequency(f1).generate(SIZE);
    Aquila::SineGenerator sineGenerator2 = Aquila::SineGenerator(sampleFreq);
    sineGenerator2.setAmplitude(8).setFrequency(f2).setPhase(0.75).generate(SIZE);
    auto sum = sineGenerator1 + sineGenerator2;

    auto fft = Aquila::FftFactory::getFft(SIZE);
    Aquila::SpectrumType spectrum = fft->fft(sum.toArray());
    return spectrum;
}

I compile using:

g++ -o main.exe fft.cpp -L . -lAquila  -lOoura_fft

But I keep getting undefined references!

c:/users/omanb/scoop/apps/gcc/current/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\omanb\AppData\Local\Temp\ccMPdyPz.o:fft.cpp:(.text+0x1bf): undefined reference to `Aquila::FftFactory::getFft(unsigned long long)'
c:/users/omanb/scoop/apps/gcc/current/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\omanb\AppData\Local\Temp\ccMPdyPz.o:fft.cpp:(.text+0x236): undefined reference to `Aquila::WaveFile::~WaveFile()'
c:/users/omanb/scoop/apps/gcc/current/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\omanb\AppData\Local\Temp\ccMPdyPz.o:fft.cpp:(.text+0x2bf): undefined reference to `Aquila::WaveFile::~WaveFile()'

Here is the header file containing all files for Aquila.

#ifndef FFT_CLASS_H
#define FFT_CLASS_H
#include "../aquila/aquila/aquila.h"
#include "../aquila/aquila/global.h"
#include "../aquila/aquila/tools/TextPlot.h"
#include "../aquila/aquila/source/WaveFile.h"
#include "../aquila/aquila/source/generator/SineGenerator.h"
#include "../aquila/aquila/transform/FftFactory.h"
class ffm 
{
  public:

    Aquila::SpectrumType  FFT();
};

#endif

You still need to include the Aquila header file like this:

#include "aquila/aquila.h"

See an example on Github .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM