I want to use libmpdclient-dev
in my C++ program. I installed it on my system.
Under /usr/include/mpd
I found all the header files.
My test program looks like this:
#include<iostream>
#include<mpd/client.h>
using namespace std;
struct mpd_connection *conn;
int main() {
conn = mpd_connection_new("192.168.1.151", 6600, 0);
if(conn == NULL) {
cout << "Not connected \n";
}
else {
cout << "Connected \n";
}
return 0;
}
It compiles fine:
g++ -g -Wfatal-errors -std=c++11 main.cpp -c -o main.o
However, running the linker as follows:
g++ -g -Wfatal-errors -std=c++11 main.o -o run
gives this error:
main.o: In Function `main':
~/mpd/main.cpp:13: undefined reference to `mpd_connection_new'
collect2: error: ld returned 1 exit status
What do I need to add or change to link successfully?