未定义的参考Aquila :: WaveFile

时间:2017-06-01 21:33:10

标签: c++11 compiler-errors open-source signal-processing

我正在尝试使用Aquila dsp库编译程序。 代码是:

#include "/usr/aquila/include/aquila/source/WaveFile.h"
#include <iostream>

int main(int argc, char *argv[])
{
    if (argc < 2)
    {
        std::cout << "Usage: wave_info <FILENAME>" << std::endl;
        return 1;
    }
    Aquila::WaveFile wav(argv[1]);
    std::cout << "Filename: "           << wav.getFilename();
    std::cout << "\nLength: "           << wav.getAudioLength()     << " ms";
    std::cout << "\nSample frequency: " << wav.getSampleFrequency() << " Hz";
    std::cout << "\nChannels: "         << wav.getChannelsNum();
    std::cout << "\nByte rate: "        << wav.getBytesPerSec()/1024 << " kB/s";
    std::cout << "\nBits per sample: "  << wav.getBitsPerSample() << "b\n";

    return 0;
}

make文件是:

MFCC: main.o 
    g++-5 -Wall -std=c++11 -L/usr/aquila/lib -lOoura_fft -lAquila main.o -o MFCC

main.o: main.cpp
    g++-5 -c -Wall -std=c++11 main.cpp

clean:
    rm *.o MFCC

当我尝试编译它时,会显示以下消息:

dario@dario-Lenovo-G460:~/Contenidos/HSTM/C++/MFCC$ make
g++-5 -Wall -std=c++11 -L/usr/aquila/lib -lOoura_fft -lAquila main.o -o MFCC
main.o: In function `main':
main.cpp:(.text+0xa4): undefined reference to `Aquila::WaveFile::WaveFile(std::string const&, Aquila::StereoChannel)'
main.cpp:(.text+0x117): undefined reference to `Aquila::WaveFile::getAudioLength() const'
main.cpp:(.text+0x224): undefined reference to `Aquila::WaveFile::~WaveFile()'
main.cpp:(.text+0x28b): undefined reference to `Aquila::WaveFile::~WaveFile()'
collect2: error: ld returned 1 exit status
make: *** [MFCC] Error 1

我找到的最近的论坛位于:Undefined reference with extern C

我尝试应用那里给出的所有建议,但错误仍然存​​在。 我的操作系统是:

dario@dario-Lenovo-G460:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:    14.04
Codename:   trusty

谢谢!

1 个答案:

答案 0 :(得分:0)

在Makefile中,在MFCC的目标中,在库包含之前放置主对象文件和可执行文件名(MFCC)。

根据这里的答案:c++ undefined references with static library