RtMIDI library causes undifined reference error

I have some experience in VB.net and python, but decided to switch to C++. So I know something about programming, but am still a noob in c++.
I'm trying to use a opensource library to communicate with a MIDI device (RtMidi.h). I tried the simpelest code, the first tutorial code on their website
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "RtMidi.h"

int main()
{
  RtMidiIn *midiin = 0;

  // RtMidiIn constructor
  try {
    midiin = new RtMidiIn();
  }
  catch (RtError &error) {
    // Handle the exception here
    error.printMessage();
  }

  // Clean up
  delete midiin;
}

It's just a copy-paste, I did not write this, so I suppose this should work. But it gives an 'undefined reference error to RtMidiIn::RtMidiIn(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'

All the header files on their right place, my IDE (NetBeans) recognises them and their functions, so that's not the problem.

the source code of the RtMidi library can be found here: http://www.music.mcgill.ca/~gary/rtmidi/RtMidi_8h-source.html
Are you linking to the library?
I suppose so, I thought the #include "RtMidi.h" does the linking.
No that only includes the header, you should tell your compiler -or your IDE- that you want to use that library
I fixed it, I switched IDE on the way though. I now work in Qt Creator. The problem was indeed that the compiler needed to know a library, but apparently the RtMidi library depends on two extra libraries (asound and pthread), which should also be added to the ide. So although the .h and the .cpp files were linked alright and loaded correctly, the compiler still missed references from these libraries. the code to be added to the .pro file of the project to fix this in linux is:
LIBS += -L/alsa/ -lasound \
-lpthread
Topic archived. No new replies allowed.