UnitTesting Maya C++ Plugins in Visual Studio



I was looking at a way to test my Maya plugins. About a week ago I stumbled upon MLibrary while studying the Maya API.
MLibrabry starts a standalone Maya in which you can run code in ( like python maya.standalone ).

This seemed like the perfect tool to use to integrate UnitTesting in my plugins ( possibly with Catch since it is my preferred framework ).
After some testing, I just can’t get MLibrary to run correctly, probably because of some stupid error on my part.

I have a project up in Visual Studio Community 2017. For now the only code is the main function:

#include <maya/MLibrary.h>
#include <maya/MGlobal.h>
#include <maya/MVector.h>

int main(int argc, char** argv) {
    MStatus status;
    status = MLibrary::initialize(true, argv[0], true);
    if (!status) {
	return (1);

    while (true) {

  return (0);


The first problem I run into was an OpenMaya.dll not found error. To resolve it I had to add the MAYA_LOCATION environment variable and modify the PATH environment variable.
So I added them to the property of the project:

MAYA_LOCATION=C:\Program Files\Autodesk\Maya2017;
PATH=C:\Program Files\Autodesk\Maya2017\bin;%PATH%;

After that, the compiled application started but threw a memory exception and crashed. It seemed to have something to do with Python. It looked like, to me, it was trying to initialize Maya with the wrong Python environment ( the default one on my system ).
As such, I added a PYTHONHOME environment variable to the project.
Here I completely stumbled as the new error I found was an import error since it couldn’t find the site module.
I can’t for the life of me understand why it can’t find it.
My PYTHONHOME is set to:

PYTHONHOME=C:\Program Files\Autodesk\Maya2017\Python

So, after a bit of fiddling, I tried to search the internet for help. I found someone who actually used MLibrary for testing ( HERE ).
Unfortunately, he is using CMAKE which I’m (currently) not acquainted with. Moreover, I’d really like to stay in the Visual Studio environment only for now.

So, has anyone else tried something like this? Does anyone else know what I may be doing wrong?
Or does anyone know of a better way to test C++ plugins?