Title pretty much says it. What do I need to do to be able to compile maya plugins using KDevelop?
Setting up KDevelop project for a Maya plugin
Iāve used KDevelop for this in the past, set it up as a Qt project, and then edited the Qt project file to set it up properly for maya plugins. Last time I used it was for a Maya 7.0 project but Iād assume that the principles still hold. Iāll have a look to see if I can dig up an example maya qmake project file for you if you want?
Note that Iām sure there are other ways of setting kdevelop up for it, but as iāve used qmake files before that was what came easiest to me.
Thanks for the tip. Looks like there something else I need to sort out first as I canāt even compile (manually) the simple hello world example in the docs in my fairly freshly installed FC6, which Iām starting to dislike. So far FC6 has given me the most headaches of all the fedoras iāve triedā¦
Hmmm, how often I see āFedora Coreā and āheadachesā in the same sentence.
Itās probably not your problem though. What you need to look into for such a project is what compiler options you need, what linker options you need and so on. For example, if youāre programming a plugin, I would have thought that would be created as a shared object so the best thing to do would be to create a project for that and make sure the linker includes all the requisite libs.
Yes. I already tried quite a few ways (Iām not a complete noob with linux and c++). My gut feeling is that there is some incompatibilities with Maya API and the current gcc version I got or something similar.
Anyway, this can wait. Itās nothing important. Just wanted to quickly try out an idea I had but itās an obsolete one by now (solved another way) 
Iāll have another look when the need arises again 
Eheh⦠and 15 mins later after installing compatibility versions (3.4) of gnu c and c++ compilers⦠drumroll⦠it compiled 
And finally after noodling around I was able to get everything to work through KDevelop as well. Iāll write the details some other time. Need to first recap what exactly I did as it wasnāt so straight forward (to me at least)⦠Used (vaguely) this as my guide:
Another reason to use the recommended versions as much as possible so far as Iām concerned, and another example of how Linux is just not ready. Shame really seeing as I love using it all the time myself but itās such a headache unless you know your way around it quite well (keeps further eye on Haiku).
Although to be fair, itās more of an inherent problems with having compilers and libraries of different versions. For example, I wouldnāt recommend anyone try to compile plugins for Maya for windows using a different version of MSVC than was used to build Maya. One problem is that MSVC changes the iostream implementation and other libc stuff every single version, making the objects binary incompatible. There can also be problems with doing inheritance and having different vtable pointers for the same object type, but Maya avoids all of those issues through MObjects and function sets.
I think in general programming tools are very poor, considering how many programmers use them.
Hereās (hopefully) what you need to do in order to compile maya plugins with KDevelop under FC6.
In addition to the standard development stuff you need few compatibility packages. These can be installed by running (as root) the following command:
yum install compat-gcc-34 compat-gcc-34-c++ compat-libstdc+±33
Launch KDevelop. This is where it gets a bit hairy as the settings seem to be scattered around in many places.
Create a new project (C++ / Simple Hello world program). Iāll call mine āmayaPluginTestā. As weāre not really interested in compiling a binary executable we can ignore the auto-generated āmayaplugintest.cppā and everything in it. Just leave them there for now.
First thing to do is to go into Project->Project Options->Configure Options. Under the tab labeled āCā, in the āCompiler command (CC)ā field, type āgcc34ā. Next go to the āC++ā tab and type āg++34ā in the āCompiler command (CXX)ā field. Hit OK (you can skip the Re-run configure).
Next go to the AutoMake Manager (one of the tabs on the right). Right-click where it says āsrcā in the upper part of the panel and choose āAdd Subprojectā. Enter the name of your plugin and hit OK. Iāll call mine āmyPluginā. Find the āmyPluginā sub-project under the āsrcā in the upper part of the panel. Right-click on it and choose āAdd Targetā. Set āPrimaryā to āProgramā and āPrefixā to ānoinstā. Enter the file name of your plugin (e.g. āmyPlugin.soā) and hit OK.
Right-click on the āmyPluginā sub-project under the āsrcā in the upper part of the window again and choose āOptionsā. In the field in the middle (CXXFLAGS) type in your compiler flags (e.g. -O3 -pthread -pipe -D_BOOL -DLINUX -DREQUIRE_IOSTREAM -mcpu=pentium4 -Wno-deprecated -fno-gnu-keywords). Go to the āIncludesā tab and use the āAddā¦ā button to add all your include directories outside the project. You will want to retain the ā-Iā in the beginning of the path (thatās capital I as in Iffy ;)). You definately need to have ā-I/usr/aw/maya/includeā and probably ā-I/usr/X11R6/includeā in the list. Hit OK.
In the lower panel of the Automake Manager, right-click on the myPlugin.so and choose āMake Target Activeā. Right click on it again and choose Options. Under the āFlagsā tab, in the āOtherā field, type in your linker flags (e.g. -L/usr/aw/maya7.0/lib -shared -O3 -pthread -pipe -D_BOOL -DLINUX -DREQUIRE_IOSTREAM -mcpu=pentium4 -Wno-deprecated -fno-gnu-keywords -Wl,-Bsymbolic). I couldnāt find a more suitable place to put in the maya library path so I put it here. Go to the āLibrariesā tab and using the the āAddā¦ā button add the actual libraries you want to link against. Again you want to retain the ā-lā in the beginning of the name (that lower case l as in lost ;)). I added -lFoundation and -lOpenMaya. Hit OK.
Right-click on the myPlugin.so again and choose āCreate New Fileā. Enter the file name (e.g. āmyPlugin.cppā) and hit OK. Double-click on the myPlugin.cpp and youāre ready to start coding.
Hereās the sample hello world from the docs:
#include <maya/MSimple.h>
#include <maya/MIOStream.h>
DeclareSimpleCommand( helloWorld, "Alias", "7.0");
MStatus helloWorld::doIt( const MArgList& )
{
cout << "Hello World
";
return MS::kSuccess;
}
Build->Build Active Target should compile and link your shiny new plugin (be sure to run the configure first).
Thatās it. Easy and straight forward, huh? 
While your first statement is correct, your second one is FUD. Windows suffers from much worse problems with its official compiler and libraries, having broken binary compatability on each and every major version (v6, v7 and v8). Worse, they even broke binary compatability of STL between v6 and v7 in a big way, as v6 was shipping with a broken STL with no namespaces.
Version 8 of the microsoft suite is probably one of the worst things now, as Microsoft has now added the nightmare that is āmanifestsā ā a completely unneeded feature, and it is now also pushing to depreciate some standard C functions that have been available for years (printf, etc) and most POSIX functions, without much justification. And thatās what you get for a paid (and costly) product.
In comparison, the gcc team has broken its ABI only once in a similar time frame: from 3.2 to 3.3/4. gcc4.0+ remains backwards compatible with stuff compiled with 3.4. While the STL has changed on linux on each new version of the compiler, it has remained binary compatible, as it has always shipped with namespaces. And to top if all off, you get it all for free and open sourced.
Crikey! To be perfectly truthful with you I havenāt used Visual Studio products in some time as I aim for cross platform capability and, while unfinished, Dev-C++ 4.9.9.2 does a solid enough job for me. I suppose I expected, what with Windows itself being such an unchanging base platform in terms of backwards compatibility, that it would somehow be better in this respect.
At least when GCC breaks old code, itās most often because this old code broke certain programming rules that GCC no longer allows it to break for various reasons including security issues, limitation of memory leaks and generally the kind of programming that leads to stuff breaking in execution. Itās also good to see that there are compatibility RPMs that sort any problems out but really it would be nice if they were more obviously accessible.
I donāt see how you can say that Linux isnāt āreadyā because a particular compiler version is recommended when compiling a project. While updates are released very frequently, āolderā versions still remain readily available on most distributions. If old versions magically sort of disappeared you would have a point, but as they are still there and available, and can coexist with other versions quite harmonically, I donāt understand how it poses a problem.
Mainly it was in reference to the lack of backwards compatibility that is often found in Linux distros. Now, while this is being worked on, itās not finished yet and itās still not entirely unusual to find you canāt have two different programmes on one installation because they demand different versions of the same libraries.
This is particularly a problem when trying to run certain older python scripts under blender as a seperate version of Python has to be compiled in a seperate place and a shellscript setup so as not to interfere with systemwide settings that other, often essential, software depends on. Itās good to see, as I was unaware, some backwards compatability in GCC versions with Fedora Core 6 but it is more the exception than the rule and until ādependency hellā is dealt with in a more widespread manner, I donāt consider Linux to be truly ready.
Maybe at some point when I have the time and the energy. Might take some screenshots as well. Iām super busy at work at the moment so if anyone else wants to do it, I wouldnāt mind ;).
The same is certainly true for Ubuntu (and I believe SUSE as well) and not only with regards to GCC but many many other compilers/libraries Iāve had to use. I doubt other distributions havenāt caught onto it as wellā¦
Righto, was worth a try
Might do it myself if I have a chance in the next few weeks. Thanks for taking the time to write up a tutorial in the first place! Might have a quick check and see how it compares to whatās needed in Ubuntu.
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
