I have generated a MIDI clock from scratch. It is simple since you just need to send some data periodically.
You need to create a thread running a loop with a variable sleep and a wall clock to have a precise enough clock. Look into C++ threads
http://www.cplusplus.com/reference/thread/thread