First problem: exceptions
No idea what “N3cms12CMSExceptionE” is? Use getCause() on cms::CMSException
objects to get std::exception*. Do not call what() directly. Do not try to call what() from any base classes.
cout << e.getCause()->what() << endl;
And now “N3cms12CMSExceptionE” is “No Matching Factory Registered for format := tcp”.
Second problem: library initialization
“No Matching Factory Registered for format := tcp” suggests that library was not initialized properly or some protocol-related modules was not loaded. Version 3.0 (and above) requires explicit initialization of ActiveMQ library.
To fix this problem include activemq/library/ActiveMQCPP.h and call ActiveMQCPP::initializeLibrary().