I use openFrameworks with the addon ofxMidi to use physical midi controllers for my software. If I was going to write from scratch I would use today Libremidi for c++, this is a great one https://github.com/jcelerier/libremidi