Compile C++ Plugin in Maya 2014

475 views
Skip to first unread message

Jeremy YeoKhoo

unread,
Sep 19, 2014, 3:28:20 AM9/19/14
to python_in...@googlegroups.com
Hey guys,

I know it's a python thread, but do any of you have any experience of compiling a C++ plugin? I am about to download a trial version of Visual Studio, but was wandering if I could use an older version like 2010 and a Studio Express. Seems like a huge program just to compile something. I am on a Windows 7, 64-bit machine and on Maya 2014.

I found a step by step link here:

But its for Visual Studio 2005.


-J

Marcus Ottosson

unread,
Sep 19, 2014, 4:03:59 AM9/19/14
to python_in...@googlegroups.com
Hi Jeremy,

I'm no expert, but I think you'll need a version of Visual Studio that corresponds to the version Autodesk used when compiling Maya itself, and they differ depending on which version you are compiling your plug-in for. But yes, if you've never compiled anything before, compiling is generally a big task when getting set up for the first time. 

Autodesk supplies "presets" for VS that is meant to help you get this set up, but I'm not very well vested in how well it actually accomplishes that.

Best,
Marcus

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0647340e-4892-4955-adc7-aa1c925594ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Marcin Majewski

unread,
Sep 19, 2014, 4:35:06 AM9/19/14
to python_in...@googlegroups.com

Hi Jeremy,

You need Visual Studio Express 2010 with 64 bit compiler. In order to get 64 bit compiler (Visual Studio Express comes with 32 bit compiler) you need Windows 7.1 SDK - http://www.microsoft.com/en-us/download/details.aspx?id=8279. I compile mostly on Linux, so when I’ve to do this on Windows I use console too, but you can use Visual IDE to do this (using Autodesk Plugin Wizard).

Here’s an example using Windows console (use Windows 7.1 SDK Command Prompt console or initialize :

Compiler

cl /c /EHsc /DNT_APP /D_CONSOLE /D_BOOL /DREQUIRE_IOSTREAM /DAW_NEW_IOSTREAMS -I"C:\Program Files\Autodesk\Maya2014\include" -I"C:\Program Files\Microsoft SDKs\Windows\v7.1\Include" -I"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include" -I"C:\path\to\include\"  /Fo"C:\path\to\objectfile.obj" C:\path\to\source\file.cpp

Linker

link /DLL /LIBPATH:"C:\Program Files\Autodesk\Maya2014\lib" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64" /LIBPATH:"C:\Program Files\Autodesk\Maya2014" /LIBPATH:"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64" /LIBPATH:"C:\path\to\lib" /export:initializePlugin /export:uninitializePlugin Foundation.lib OpenMaya.lib OpenMayaUI.lib OpenMayaRender.lib OpenMayaFX.lib libcmt.lib odbccp32.lib odbc32.lib OpenMayaAnim.lib C:\path\to\objectfile.obj /OUT:"mayaPlugin.mll"

You can use CMake or other software to automate compilation or make VC solution file.


--

Jeremy YeoKhoo

unread,
Sep 19, 2014, 8:06:09 PM9/19/14
to python_in...@googlegroups.com
Thanks for the info guys :) Really appreciate it. 

@Marcus, surely it cant be that daunting? Alas, I am going to give it a shot!

@Marcin, I tried that yesterday, found on the interwebs about the SDK but had trouble downloading it. Initially took off the .NET option which removed  off 300MB, but added all the download options this morning and am still having issues. I've installed VS 2010 Express (which is free) on my machine. Maybe there is something that I missed? 




Update: I've just found that MS has downloads for their SDK as an .iso, downloading that now, will update how I go.



-Jeremy

Jeremy YeoKhoo

unread,
Sep 20, 2014, 1:17:22 AM9/20/14
to python_in...@googlegroups.com
Ok, So I got Visual Studio 2010 working.  But the build did not work, and I googled some more and read that maya2014 uses Visual Studio 2013 Express for Windows Desktop. So I used that. 

Hey Marcin, Are you compiling plugins for earlier versions than maya2014? I didn't use the command line, but I've used the UI of Studio Express 2013 to help me get there. Just easier for me to debug things. I am getting this error, which leads me to believe that I am close to getting this thing to work.


IntelliSense: namespace "std" has no member "ostream" c:\Program Files\Autodesk\Maya2014\include\maya\MFloatVectorArray.h 107 55

Basically I am getting a repeated namespace "std" has no member "ostream" for every #include maya/M* in my .h and .cpp files. I have just a helloWorld command.  

And this error as well
IntelliSense: cannot open source file "winsock2.h" c:\Program Files\Autodesk\Maya2014\include\maya\MTypes.h 137 1 maya2014_hWorld




But anyway, Ive included the details of my project settings below:

General---Target Extension:
.mll

General---Configuration Type:
Dynamic Library .dll
----------------------------------------­---------
VC++Directories---Include Directories:

C:\Program Files\Autodesk\Maya2014\include

VC++Directories---Library Directories:

C:\Program Files\Autodesk\Maya2014\lib
----------------------------------------­---------

C/C++---General---Aditional Include Directories:
;C:\Program Files\Autodesk\Maya2014\include

C/C++---Preprocessor---Preprocessor Definitions:
;WIN32;NDEBUG;_WINDOWS;NT_PLUGIN;REQUIRE­_IOSTREAM

C/C++---Runtime Library---Code Generation:
Multi-threaded Debug DLL /MDd
----------------------------------------­---------
Linker---General---Aditional Library Directories:
;C:\Program Files\Autodesk\Maya2014\lib

Linker---Input---Additional Dependencies:
;Foundation.lib;OpenMaya.lib;OpenMayaUI.­lib;OpenMayaanim.lib;OpenMayaFX.lib;Open­MayaRender.lib;Image.lib

Linker---Additional Options---Command Line;
/export:initializePlugin /export:uninitializePlugin


By the way, that was grabbed from this youtube link...

Which was similar to this link for Studio Express 2010, except this version isn't using the Windows 7.1 SDK toolset. I am currently using the default Platform Toolset: "Visual Studio 2013 (v120)"




On Friday, 19 September 2014 17:28:20 UTC+10, Jeremy YeoKhoo wrote:

Jeremy YeoKhoo

unread,
Sep 21, 2014, 1:52:47 AM9/21/14
to python_in...@googlegroups.com
Ok I got it to build. Had a silly syntax error  BUT.....

I now get this error maya:
// Error: file: C:/Program Files/Autodesk/Maya2014/scripts/others/pluginWin.mel line 658: initializePlugin function could not be found in plug-in (HelloWorld)
Which is weird because I have function clearly defined in my cpp file.

This is my main body.
#include "HelloWorld.h"
          
#include <maya/MFnPlugin.h>

MTypeId HelloWorld::id(0x00337);


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

MStatus HelloWorld::doIt(const MArgList& argList) {
MGlobal::displayInfo("Hello There!!!");
return MS::kSuccess;
}
        
MStatus initializePlugin(MObject obj) {
MFnPlugin plugin(obj, "", "0.1", "Any");
MStatus status = plugin.registerCommand("helloWorld", HelloWorld::creator);
CHECK_MSTATUS_AND_RETURN_IT(status);
return status;
}


And my header:
#ifndef HELLOWORLD_H
#define HELLOWORLD_H

#include <maya/MArgList.h>
#include <maya/MObject.h>
#include <maya/MGlobal.h>
#include <maya/MPxCommand.h>
#include <maya/MTypeId.h>

class HelloWorld : public MPxCommand {
public:
HelloWorld() {};
virtual MStatus doIt(const MArgList&);
static void* creator();
static MTypeId id;
};
#endif




On Friday, 19 September 2014 17:28:20 UTC+10, Jeremy YeoKhoo wrote:

Justin Israel

unread,
Sep 21, 2014, 2:03:57 AM9/21/14
to python_in...@googlegroups.com
Wow, interesting formatting

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Marcus Ottosson

unread,
Sep 21, 2014, 3:06:27 AM9/21/14
to python_in...@googlegroups.com
My world suddenly got turned up side down.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3o-TY%2BY1J0RfheoV-vk5R9yY1nonBq7%3DKGpYpxEu%3DOOA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


--
Marcus Ottosson
konstr...@gmail.com


Jeremy YeoKhoo

unread,
Sep 22, 2014, 1:30:42 AM9/22/14
to python_in...@googlegroups.com
Lol, sorry to get you guys crossed eyed! Again sorry for posting this in Python forum, does anyone use CGtalk nowadays?

Found it out, turns out it doesn't matter the version of Studio Express. The libraries and includes are compatible with Studio Express 2013. Anyway, found some more useful links after many attempts at re-installing and trying out different versions of Studio. And yep, Studio Express is free. Awesome.

Here is the link that help me with fix:


Bloody chuffed. Going to play with C++ now, and convert some python. (well, time permitting)

-J


On Friday, 19 September 2014 17:28:20 UTC+10, Jeremy YeoKhoo wrote:
Reply all
Reply to author
Forward
0 new messages