Hi

I'm new to C++ and I'd like to make a program that responds to MIDI input from an external device (e.g. MIDI keyboard). I've found a library that should do what I want here:

http://www.music.mcgill.ca/~gary/rtmidi/index.htm.

I'm using VC++ 2010 Express, and I can't figure out how to actually use the library in my project. I've tried importing the source files and headers and then using an include directive, but I keep getting 'LNK2019 - unresolved external symbol' errors. I've also tried compiling the source files as a static library (.lib) file and importing that, but that doesn't work either.

Does anybody know how I can actually use this library? :confused:

Thanks :)

Recommended Answers

All 7 Replies

Unarchive it to a directory. There's a MSW directory that contains a VS project. Open that up and build it. Check the lib directory for the lib files (it probably does a debug build initially, so you may have to do a release build later).

After that's all built, go under Project/<projectname>Properties/Configuration Properties/CC++/Additional Include Directories and enter in the directory where the header files for the library are.

Then also under Configuration Properties/Linker/General/Additional Library Directories enter in the location of the lib directory.

Then under Configuration Properties/Linker/Input/Additional dependencies put the name(s) of the lib files in the lib directory.

The first part is specific to this particular library, but the last 3 steps apply to any library.

Give that a go and see if you have any more problems.

Hi jonsca,

Thanks for the suggestion. Unfortunately, when I try to open the solution or project file in the MSW directory, I get the following error:

<file> cannot be opened because its project type (.vcproj) is not supported by this version of the application. To open it, please use a version that supports this type of project.

Is this because it was written for an older version of VC++? Any ideas? :?:

The conversion wizard didn't pop up? Try opening the .sln file from within Visual C++ instead of by double clicking it.

OK, I've found out how to open the project and have built the library as you suggested. However, even after adjusting all the linker settings accordingly, I still get build errors when I try to compile my project. This is the full build output:

1>------ Build started: Project: midi_test, Configuration: Debug Win32 ------
1>LINK : warning LNK4067: ambiguous entry point; selected 'mainCRTStartup'
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiInGetNumDevs@0 referenced in function "private: void __thiscall RtMidiIn::initialize(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?initialize@RtMidiIn@@AAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiInStart@4 referenced in function "public: virtual void __thiscall RtMidiIn::openPort(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?openPort@RtMidiIn@@UAEXIV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiInAddBuffer@12 referenced in function "public: virtual void __thiscall RtMidiIn::openPort(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?openPort@RtMidiIn@@UAEXIV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiInClose@4 referenced in function "public: virtual void __thiscall RtMidiIn::openPort(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?openPort@RtMidiIn@@UAEXIV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiInPrepareHeader@12 referenced in function "public: virtual void __thiscall RtMidiIn::openPort(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?openPort@RtMidiIn@@UAEXIV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiInOpen@20 referenced in function "public: virtual void __thiscall RtMidiIn::openPort(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?openPort@RtMidiIn@@UAEXIV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiInUnprepareHeader@12 referenced in function "public: virtual void __thiscall RtMidiIn::closePort(void)" (?closePort@RtMidiIn@@UAEXXZ)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiInStop@4 referenced in function "public: virtual void __thiscall RtMidiIn::closePort(void)" (?closePort@RtMidiIn@@UAEXXZ)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiInReset@4 referenced in function "public: virtual void __thiscall RtMidiIn::closePort(void)" (?closePort@RtMidiIn@@UAEXXZ)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiInGetDevCapsW@12 referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall RtMidiIn::getPortName(unsigned int)" (?getPortName@RtMidiIn@@UAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiOutGetNumDevs@0 referenced in function "public: virtual unsigned int __thiscall RtMidiOut::getPortCount(void)" (?getPortCount@RtMidiOut@@UAEIXZ)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiOutGetDevCapsW@12 referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall RtMidiOut::getPortName(unsigned int)" (?getPortName@RtMidiOut@@UAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiOutOpen@20 referenced in function "public: virtual void __thiscall RtMidiOut::openPort(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?openPort@RtMidiOut@@UAEXIV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiOutClose@4 referenced in function "public: virtual void __thiscall RtMidiOut::closePort(void)" (?closePort@RtMidiOut@@UAEXXZ)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiOutReset@4 referenced in function "public: virtual void __thiscall RtMidiOut::closePort(void)" (?closePort@RtMidiOut@@UAEXXZ)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiOutShortMsg@8 referenced in function "public: void __thiscall RtMidiOut::sendMessage(class std::vector<unsigned char,class std::allocator<unsigned char> > *)" (?sendMessage@RtMidiOut@@QAEXPAV?$vector@EV?$allocator@E@std@@@std@@@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiOutUnprepareHeader@12 referenced in function "public: void __thiscall RtMidiOut::sendMessage(class std::vector<unsigned char,class std::allocator<unsigned char> > *)" (?sendMessage@RtMidiOut@@QAEXPAV?$vector@EV?$allocator@E@std@@@std@@@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiOutLongMsg@12 referenced in function "public: void __thiscall RtMidiOut::sendMessage(class std::vector<unsigned char,class std::allocator<unsigned char> > *)" (?sendMessage@RtMidiOut@@QAEXPAV?$vector@EV?$allocator@E@std@@@std@@@Z)
1>rtmidi.lib(RtMidi.obj) : error LNK2019: unresolved external symbol __imp__midiOutPrepareHeader@12 referenced in function "public: void __thiscall RtMidiOut::sendMessage(class std::vector<unsigned char,class std::allocator<unsigned char> > *)" (?sendMessage@RtMidiOut@@QAEXPAV?$vector@EV?$allocator@E@std@@@std@@@Z)
1>C:\Users\James\Desktop\midi_test\Debug\midi_test.exe : fatal error LNK1120: 19 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Why is this happening? Any suggestions?

Go to the "Compiling" link at the top of the page you linked above. It looks like it requires the windows multimedia library. I'm not familiar with it, so google around and see, but you might only have to add winmm.dll to the dependencies (under Linker/Input under all of the Project/<yourproject>Properties).

Beyond that Compiling page, the authors might be able to help you via email...

A few changes to the library references fixed the problem nicely. Thanks for your help. :)

what changes did you make to solve problem with linker error 2019?
how to add library "winmm.lib" ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.