Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
144 views
in Technique[技术] by (71.8m points)

c++ - How to link libs in netbeans (linux)?

I'm trying to write a program in c++ to analyze sound. I want to use libsndfile library. I added an option -lsndfile to g++ compiler options. But I get the error: WavReader.cpp:18: undefined reference to `sf_open'

How to link the library? Please help!

#include <cstdlib>
#include "WavReader.h"
#include <sndfile.h>
#include <iostream>


namespace SA {

    WavReader::WavReader(char* fileName, SoundProcessor* soundProcessor) {
        this->fileName = fileName;
        this->soundProcessor = soundProcessor;
    }

    void WavReader::readFile() {
        SNDFILE* sf = NULL;
        SF_INFO info;
        info.format = 0; 
        sf = sf_open(this->fileName, SFM_READ, &info);

    }

    WavReader::~WavReader() {
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

project properties -> linker -> libraries -> add option -> another option: -lsndfile


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...