API Guide > Setting up your build environment >

# Linux environments

Maya plug-ins

The Maya Development Kit product contains a number of example plug-ins located in /usr/autodesk/maya2013-x64/devkit/plug-ins. Before you can use these plug-ins, you need to build them. The first step is to define the MAYA_LOCATION environment variable to point to the directory where Maya is installed. If your command-line shell is sh, bash or ksh then the commands would be as follows:

    MAYA_LOCATION=/usr/autodesk/maya2013-x64
    export MAYA_LOCATION

If you don't want to have to reset MAYA_LOCATION each time you log in, then add those commands to your $HOME/.profile as well.

If your command-line shell is csh or tcsh then command would be:

    setenv MAYA_LOCATION /usr/autodesk/maya

and you can also add it to your $HOME/.cshrc to avoid having to reset it each time you log in.

Since you likely won't have write permissions on the directories where Maya's devkit is installed, you will have to create a local working directory and copy the plug-in sources into it:

    mkdir -p $HOME/devkit/
    cp -r /usr/autodesk/maya2013-x64/devkit/plug-ins .

Now you're ready to build the plug-ins:

    cd $HOME/devkit/plug-ins
    make Clean
    make

Maya relies on a number of different environment variables to find plug-ins and their associated files. These are:

- MAYA_PLUG_IN_PATH - directories to search for plug-ins
- MAYA_SCRIPT_PATH - directories to search for MEL and Python scripts
- XBMLANGPATH - directories to search for icons

These variables can be defined in a file called Maya.env. Using Maya.env makes it easy set up the same runtime environment on another system by simply copying the file. You can still set explicit values for these variables on the commmand line and they will prepended to the values given in Maya.env.

Each C++ plug-in resides in its own subdirectory within $HOME/devkit/plug-ins while all of the Python plug-ins reside in a common subdirectory named scripted. You must add to the aforementioned environment variables the directories for all of the plug-ins you wish to access from Maya. For example, if you want to access the circleNode and whatisCmd C++ plug-ins from within Maya, then your Maya.env file should contain the following:

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

If you now start Maya and open the Plug-in Manager window, you should see the circleNode and whatisCmd plug-ins each listed within its own section. This can get cumbersome if you want access to large number of plugins, in which case it makes sense to copy the various types of files into a set of common directories. For example, to access all of the devkit plug-ins from within Maya, you could do the following:

    mkdir plug-ins scripts icons
    cp */*.so plug-ins
    cp */*.mel */*.py scripts
    cp */*.png */*.xpm */*.cur */*.rgb icons

Then set your Maya.env file to use those common directories:

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

Now when you start up Maya and bring up the Plug-in Manager you'll see all of the devkit plug-ins, listed within a common section.

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 versioned subdirectory of either the directory pointed to by the MAYA_APP_DIR environment variable or $HOME/maya. For example, if you set MAYA_APP_DIR to be /usr/mydir, you can create a Maya.env file in the directory /usr/mydir/2013 that will only be used when the 2013 version of Maya is run. If you do not set MAYA_APP_DIR, you can put your 2013-specific Maya.env file in $HOME/maya/2013.

Maya API applications

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

    mkdir -p $HOME/devkit/applications
    cd $HOME/devkit/applications
    cp -r /usr/autodesk/maya2013-x64/devkit/applications/* .
    make Clean
    make

The shell script mayald is used to link Maya API applications. It is important that the MAYA_LOCATION be set to the correct version of Maya before running the command, otherwise the application may fail to execute properly.

When linking your own plug-ins, make sure to provide the mayald command with a 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" );