1. download the maya develop kit
https://apps.autodesk.com/MAYA/en/Detail/Index?id=6303159649350432165&appLang=en&os=Win64
then extract to C:\Program Files\Autodesk\Maya2016
2. set environmental variable:
MAYA_PATH = c:\Program Files\Autodesk\Maya2016
add c:\Program Files\Autodesk\Maya2016\bin; to Path
3.new a plain C++ Application project
4.overwrite the .pro file as follows:
TEMPLATE = lib
TARGET = Hello
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
QMAKE_EXTENSION_SHLIB = mll
QMAKE_LFLAGS = /export:initializePlugin /export:uninitializePlugin /SUBSYSTEM:WINDOWS
_CFLAGS = /FD /GS
QMAKE_CFLAGS += $${_CFLAGS}
QMAKE_CXXFLAGS += $${_CFLAGS}
SOURCES += \
main.cpp
DEFINES += WIN32 \
_WIN64 \
_WINDOWS \
_USRDLL \
NT_PLUGIN \
REQUIRE_IOSTREAM \
_BOOL
INCLUDEPATH += $$(MAYA_PATH)/include \
QMAKE_LIBDIR += $$(MAYA_PATH)/lib
LIBS += -lFoundation -lOpenMaya -lOpenMayaUI
#OBJECTS_DIR = ""
#include <maya/MSimple.h>
#include <maya/MIOStream.h>
#include <maya/MGlobal.h>
DeclareSimpleCommand( HelloMaya , "NCCA", "Maya 2016") //HelloMaya is the class name
MStatus HelloMaya::doIt( const MArgList& )
{
std::cout<<"This should come from the shell\n"<<std::endl;
MGlobal::displayInfo("Hello Maya in the maya command shell");
return MS::kSuccess;
}
6. Now we can copy the Hello.mll to C:\Program Files\Autodesk\Maya2016\bin\plug-ins
7.open maya, type and execute HelloMaya in maya command shell
note: the command HelloMaya is the class name not the plugin's name.