Errors when compiling simple MPxDeformerNode test

maya

#1

Hey everybody,

I have some basic experience with c++ but almost no experience with the Maya C++ API. (I am familiar with the Python API though)
Despite being able to compile the DevKit samples from Autodesk, I’m unable to compile the code below.
I tried replacing the code in one of the DevKit samples with the code below and even that wouldn’t compile.
Would anybody be able to tell me why this simple test code is not compiling ?

The errors mention the “pluginMain.obj” but even when removing it and just trying to compile the “testDeformer.hpp” file, I still get a list of “LNK2019: unresolved external symbol” errors.

List of errors:

* error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl Autodesk::Maya::OpenMaya20190000::MPxDeformerNode::MPxDeformerNode(void)" ([email protected]@[email protected]@@[email protected]) referenced in function "public: __cdecl testDeformer::testDeformer(void)" ([email protected]@[email protected])

* error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl Autodesk::Maya::OpenMaya20190000::MPxDeformerNode::~MPxDeformerNode(void)" ([email protected]@[email protected]@@[email protected]) referenced in function "public: virtual __cdecl testDeformer::~testDeformer(void)" ([email protected]@[email protected])

* error LNK2001: unresolved external symbol "public: virtual class Autodesk::Maya::OpenMaya20190000::MObject & __cdecl Autodesk::Maya::OpenMaya20190000::MPxGeometryFilter::accessoryAttribute(void)const " ([email protected]@[email protected]@[email protected]@[email protected]@XZ)

* error LNK2001: unresolved external symbol "public: virtual class Autodesk::Maya::OpenMaya20190000::MStatus __cdecl Autodesk::Maya::OpenMaya20190000::MPxGeometryFilter::accessoryNodeSetup(class Autodesk::Maya::OpenMaya20190000::MDagModifier &)" ([email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z)

* error LNK2001: unresolved external symbol "public: virtual void __cdecl Autodesk::Maya::OpenMaya20190000::MPxGeometryFilter::setModifiedCallback(class Autodesk::Maya::OpenMaya20190000::MSelectionList &,bool)" ([email protected]@[email protected]@[email protected]@[email protected]@[email protected])

* error LNK2001: unresolved external symbol "public: virtual enum Autodesk::Maya::OpenMaya20190000::MPxNode::Type __cdecl Autodesk::Maya::OpenMaya20190000::MPxDeformerNode::type(void)const " ([email protected]@[email protected]@[email protected]@[email protected]@[email protected])

I added the visual studio settings below for all the configurations / all platforms and I’m building in x64.
Visual Studio Settings :

  • Additional Include directories : C:\ProgramFiles\Autodesk\Maya2019\include;(AdditionalIncludeDirectories)
  • Additional Library directories : C:\Program Files\Autodesk\Maya2019\lib;%(AdditionalLibraryDirectories)
  • Additional Dependencies :
    OpenMaya.lib
    OpenMayaRender.lib
    OpenMayaUI.lib
    Foundation.lib
    opengl32.lib%(AdditionalDependencies)

my test code: (I should mention that all my includes seem to work. Intellisense detects them)
My pluginMain.cpp file :

#pragma once
#include <maya/MFnPlugin.h>
#include "testDeformer.hpp"

MStatus initializePlugin(MObject pluginMob) {
	MFnPlugin plugin(pluginMob, "testUser", "1.0", "Any");
	MStatus status = plugin.registerNode("testNode", testDeformer::id, testDeformer::creator, testDeformer::initialize,
		MPxNode::kDependNode, nullptr);
	CHECK_MSTATUS_AND_RETURN_IT(status);
	return status;
}

MStatus uninitializePlugin(MObject pluginMob) {
	MFnPlugin plugin(pluginMob);
	MStatus status = plugin.deregisterNode(testDeformer::id);
	CHECK_MSTATUS_AND_RETURN_IT(status);
	return status;
}

My testdeformer.hpp file :

#pragma once
#include <maya/MGlobal.h>
#include <maya/MTypeId.h>
#include <maya/MItGeometry.h>
#include <maya/MMatrix.h>
#include <maya/MDataBlock.h>
#include <maya/MPxDeformerNode.h>

#include <maya/MObject.h>
#include <maya/MStatus.h>

class testDeformer : public MPxDeformerNode
{
public:

	testDeformer() {};
	virtual ~testDeformer() {};

	static void* creator();

	virtual MStatus deform(MDataBlock &data, MItGeometry& itGeo, const MMatrix& localToWorldMatrix, unsigned int geomIndex);

	static MStatus initialize();

	static MTypeId id;

	//inputs
	static MObject aTestAttribute;
};

MTypeId testDeformer::id(0x0000001);

void* testDeformer::creator()
{
	return new testDeformer();
};

MStatus testDeformer::initialize()
{
	MStatus status;
	return status;
	
}

MStatus testDeformer::deform(MDataBlock &data, MItGeometry& itGeo, 
	const MMatrix& localToWorldMatrix, unsigned int geomIndex)
{
	MStatus status;

	return status;
};

Would be great if anybody knows why this is happening since I have no clue right now.
Thanks !


#2

Ugh, finding errors in visual studio projects is a royal nightmare. Sorry that I can’t give you a quick “just change this” type answer (maybe someone else can?). The way I dealt with this stuff was to start using Cmake. Once the find module is written (see below), setting up simple projects is a breeze. Plus, it’s cross-platform.

Some links:
Chad Veronon’s blog on using Cmake to compile
http://www.chadvernon.com/blog/compiling-maya-plug-ins-with-cmake/

And his github page containing findMaya.cmake:

A project of mine that uses a very simple CMakeLists.txt and Chad’s findMaya.cmake:

And a gist with my build batch script for windows. All build files are created in a separate folder: