Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link libs in netbeans (linux)?

Tags:

c++

g++

netbeans

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() {
    }
}
like image 401
varan Avatar asked Feb 23 '13 11:02

varan


2 Answers

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

like image 129
varan Avatar answered Oct 29 '22 16:10

varan


You need to link against -lsndfile library...make sure library path are included so it find library from correct location...check /usr/lib/ to make sure it is present on your system, or add path of correct location for your libs...

like image 27
Saqlain Avatar answered Oct 29 '22 16:10

Saqlain