Maya C++ API no output

Hi, I’m trying to use Visual Studio to start learning the C++ API. I can not get any sort of output to show up in Maya. I get no errors when building the .mll in Visual studio 2012 update 4 or 2017 and no errors in Maya 2016 or 2016.5 on Windows 7 and 10 same results. All I get is the affirmation that I called the function helloWorld; without error. Even the copy/pasted helloWorldCmd from the devKit gives me the same result. I followed every tutorial I could find on how to set up Visual Studio and it recognizes Maya commands outputs “Build: 1 succeeded.” I’ve looked through every forum I can on the topic and none of their solutions help. I run maya as administrator, redirect cout to cerr: cout.rdbuf(cerr.rdbuf()); use MStreamUtils etc. Here’s an example of trying various outputs to no avail:

#include <maya/MIOStream.h>
#include <maya/MSimple.h>
#include <maya/MGlobal.h>
#include <maya/MStreamUtils.h>

DeclareSimpleCommand(helloWorld, PLUGIN_COMPANY, "4.5");

MStatus helloWorld::doIt(const MArgList&)
{
	cout.rdbuf(cerr.rdbuf());

	MStreamUtils::stdOutStream().rdbuf();
	printf("printf");
	cout << "cout" << endl;
	std::cout << "std cout";
	cerr << "error";
	clog << "log";
	MStreamUtils::stdErrorStream() << "TEST1 " << "\n";
	MStreamUtils::stdOutStream() << "TEST2 " << "\n";
	return MS::kSuccess;
}

I’m out of options. Any help?

stdOutStream writes to the ostream, Check your Output window that opens along side Maya. If you want to write to the script editor MGlobal contains a bunch of displays for writing errors, warnings, info to the output in the script editor: http://download.autodesk.com/us/maya/2011help/api/class_m_global.html#c2d8d790da9da10225e842620673966e

1 Like

Wow, thank you so much! I just didn’t expect to see it there, that’s a huge relief!

Just as a further suggestion you can attach to the Maya process in VS to debug (hotkey is [ctrl+alt+P] to maya ‘Native code’) That way you can check any line breaks.

1 Like