Linux environments (64-bit)
 
 
 

Maya plug-ins

The Maya Development Kit product contains a number of example plug-ins located in /usr/autodesk/maya/devkit/plug-ins. On a 64-bit installation, the /usr/autodesk/maya directory will be, by default, a symbolic link to /usr/autodesk/maya2011-x64.

Before you can use these plug-ins, you need to build them. You must first create a working directory, recursively copy the directory, and run make. For example,

mkdir -p $HOME/devkit/
cd $HOME/devkit/
cp -r /usr/autodesk/maya/devkit/plug-ins .
make Clean
make

Also, to attach your plug-in development area to the rest of Maya, you need to set a number of variables. These are:

These variables can be defined in a file called Maya.env. Maya lets you define these variables in a file so that you can easily set up the same runtime environment on another system by simply copying the file. You can still use variables in the environment and they will either override the corresponding variable in the Maya.env file or be prepended to the variable for variables which represent search paths.

The environment variable, MAYA_APP_DIR, can be used to help find the Maya.env file. If this variable is not set, Maya looks in your $HOME/maya directory. In addition, if you have multiple versions of Maya installed on your system, you can put your Maya.env file in a subdirectory of either the directory pointed to by the MAYA_APP_DIR environment variable or $HOME/maya.

Name the subdirectory to be the version number of the Maya application that is executed. For example, if you set MAYA_APP_DIR to be /usr/mydir, you can create a version specific Maya.env file in the directory /usr/mydir/2011 that will be used when the 2011 version of Maya is run. If you do not set MAYA_APP_DIR, you can put your version 2011 tailored Maya.env file in $HOME/maya/2011.

The following assumes that Maya is installed in /usr/autodesk/maya and that you have set up your plug-in development area in $HOME/devkit/plug-ins. If your installation is different, you will have to modify the lines that set MAYA_LOCATION in the examples below.

Your Maya.env file should contain the following:

MAYA_SCRIPT_PATH = $HOME/devkit/plug-ins
MAYA_PLUG_IN_PATH = $HOME/devkit/plug-ins
XBMLANGPATH = $HOME/devkit/plug-ins/%B

Users of /bin/sh or /bin/ksh need to add the following lines to $HOME/.profile.

# Location of installed maya.
MAYA_LOCATION=/usr/autodesk/maya
export MAYA_LOCATION

Users of /bin/csh or /bin/tcsh need to add the following lines to $HOME/.cshrc.

# Location of installed maya
setenv MAYA_LOCATION /usr/autodesk/maya

If you now start Maya and open the Plug-in Manager window, you should see a list of all the pre-compiled plug-ins you copied to your $HOME/devkit/plug-ins directory.

Maya API applications

To build the supplied stand-alone application examples, you need to do the following:

mkdir $HOME/devkit/applications
cd $HOME/devkit/applications
cp /usr/autodesk/maya/devkit/applications/* .
make Clean
make

Important note

The shell script mayald is used to link these applications to isolate you from the exact set of Maya shared libraries necessary for the link.

On Linux, the variable you must set is LD_LIBRARY_PATH so that the shared libraries can be found at run time.

The recommended procedure to prepare for building and running stand-alone apps is to set the following environment variables:

Linux:

setenv MAYA_LOCATION /usr/autodesk/maya
setenv LD_LIBRARY_PATH $MAYA_LOCATION/lib

When linking your plug-in, make sure to list all of the OpenMaya libraries containing the API classes you have used. The reference pages for each class specify the particular OpenMaya library containing the class.

NoteIt is possible to build a standalone application that does not have the ability to read in some Maya models. Specifically, if you try to read a file with IK using the devkit “readAndWrite” app, you get an error about a failed connection and the ik fails in the scene. To counter this, you must force the IK subsystem to load before the file is loaded. After the MLibrary() call is made, add in some command that uses the IK subsystem before the call to MFileIO::open(). The following command works:

MGlobal::executeCommand( "ikSystemInfo -q qsh" );

Configuring Qt for use in Maya plug-ins

Maya uses Nokia's Qt toolkit, version 4.5, for its graphical user interface (GUI). In order to use Qt in Maya plug-ins, you will need the corresponding Qt run-time and development packages.

The Qt toolkit is available under both commercial and open source licences. If you are planning on using the open source version of Qt, then you may be able to install it from pre-built RPM packages. If you are planning on using the commercial version of Qt ,then you will have to build it from source. Both procedures are described below.

If you are uncertain as to which licensing best applies to your intended usage of Qt, please refer to the Qt licensing page.

Installing Qt from pre-built RPMs

The following Linux distributions provide pre-built RPMs for the correct version of Qt:

If your Linux distribution does not appear in the list above, check on the web or contact your Linux supplier to determine if pre-built packages for Qt 4.5 exist for your distribution. Otherwise, you will have to build Qt from source.

NoteSome Linux distributions may package Qt differently than as shown above. For example, they may have a single RPM containing all of Qt rather than having it spread across multiple packages. Regardless of how it is packaged, be sure that you get the core Qt components, the Qt GUI and the Qt development components.

Check if you have the necessary packages installed

Your system may already have the necessary packages installed. To check, issue the rpm -q command for each package. When specifying the package names, you only need to specify the portion before the version number, for example:

  • > rpm -q qt
  • > rpm -q qt-devel
  • > rpm -q qt-x11

For each package which is installed, you'll see something along the lines of:

qt-devel-4.5.3-9.fc11.x86_64

If the version number of the package begins with 4.5 then that is good enough for use with Maya 2011. The parts after that are not important.

If the version number does not begin with 4.5, or was not installed, then you must install or upgrade to the appropriate package. There are several ways of doing that. Most Linux distributions today provide a graphical package manager which can be used to perform installations. Alternatively, you can install the appropriate packages from the command line using the rpm -U command. You need superuser privilege to do that.

For example, do as follows:

  • > su
  • Password: ******
  • > rpm -U qt-4.5.3-9.fc12.x86_64.rpm qt-devel-4.5.3-9.fc12.x86_64.rpm qt-x11-4.5.3-9.fc12.x86_64.rpm

If you already have an older version of Qt installed, the rpm -U will try to upgrade it to the newer version. However, it may fail to do so because other applications in the system still require the old version.

If this occurs, use the rpm -i command instead:

> rpm -i qt-4.5.3-9.fc12.x86_64.rpm qt-devel-4.5.3-9.fc12.x86_64.rpm qt-x11-4.5.3-9.fc12.x86_64.rpm

That will attempt to install the new package alongside the old one, allowing both to exist on your system simultaneously.

Once Qt is installed, you can test it out by building the devkit Qt plug-ins.

Building Qt from source

If you have a commercial license for Qt, download this package:

  • qt-all-commercial-src-4.5.3.tar.gz

If you are using the open source LGPL license for Qt, download this package:

After downloading the package, build and install it using the following commands shown below. If you downloaded the commercial package, then replace each occurrence of opensource with commercial:

  • > tar xzf qt-all-opensource-src-4.5.3.tar.gz
  • > cd qt-all-opensource-src-4.5.3
  • > ./configure -platform linux-g++-64 -debug-and-release -no-phonon -no-phonon-backend -no-webkit
  • > make
  • > su
  • Password: ******
  • > make install
NoteThe ./configure command may take several minutes to run and the make command may take an hour or more to run. If either of those commands fails, it is likely due to other required packages being missing from your system. Finding and installing those packages is beyond the scope of this document. If you are not familiar with the process then please contact your system administrator for help.

When done, Qt will be installed in /usr/local/Trolltech/Qt-4.5.3.

You can test out your Qt installation by building the Qt plug-ins in Maya's devkit, as follows:

Building the devkit Qt plug-ins

  1. Open a fresh terminal session and copy Maya's devkit plug-ins directory to a directory where you have write privileges. For example,

    > cp -r /usr/autodesk/maya2011-x64/devkit/plug-ins ~/myPlugins

  2. Move into that directory:

    > cd ~/myPlugins

  3. Execute the following command:

    > make -f Makefile.qt

    NoteIf a message 'Qt not found. Qt-based plug-ins will not be built.' appears, then the directory containing qmake is not in your path and you must add it. If you built Qt from source, then qmake resides in /usr/local/Trolltech/Qt-4.5.3/bin. If you installed Qt from an RPM, then it likely resides in one of the following directories: /usr/lib64/qt4/bin, /usr/bin or /usr/local/bin.

The .so files for the plug-ins will end up in the current directory.

Cleaning up after a build

To clean up after a build, use the following command:

> make -f Makefile.qt clean