API Guide > Setting up your build environment >

# Mac OS X environment

The Maya Development Kit is located in the /Applications/Autodesk/maya2014/devkit/ directory in a standard install of Maya.

## Maya Plug-ins

There are two ways of building plug-ins on Mac OS X. You can either use Xcode or the Makefile that we supply with the devkit.

### Building with Makefiles

The Maya Development Kit product contains a number of example plug-ins located in /Applications/Autodesk/maya2014/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=/Applications/Autodesk/maya2014/Maya.app/Contents
    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 /Applications/Autodesk/maya2014/Maya.app/Contents

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/plug-ins
    cd $HOME/devkit/plug-ins
    cp -r /Applications/Autodesk/maya2014/devkit/plug-ins/* .

Now you're ready to build the 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 */*.bundle 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/Library/Preferences/Autodesk/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/Library/Preferences/Autodesk/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/2014 that will only be used when the 2014 version of Maya is run. If you do not set MAYA_APP_DIR, you can put your 2014-specific Maya.env file in $HOME/Library/Preferences/Autodesk/maya/2014.

As an alternative to setting environment variables to point to the plug-in's files, you can instead copy the files into directories which Maya automatically adds to the variables when it starts up. The easiest way to see what those directories are is to use the getenv command from within Maya's Script Editor. E.g:

    getenv MAYA_PLUG_IN_PATH

### Building with Xcode project files

To build one of the example plug-ins using Xcode, you must use the same version of Mac OS X that you'll be running Maya on and have the Xcode application installed. Then, do the following:

1. Browse to /Applications/Autodesk/maya2014/devkit/plug-ins.
2. Make a copy of the subdirectory containing the plug-in you wish to build. For example, if you wish to build the circleNode plug-in then make a copy of /Applications/Autodesk/maya2014/devkit/plug-ins/circleNode
3. Browse into the copy of the directory and double-click on the plug-in's Xcode project file, e.g. circleNode.xcodeproj
4. Select the Build option from the Build menu. The resulting plug-in will have an extension of .bundle and will be located in the build subdirectory, under the configuration you used for the build. For example, if in step 2 you copied the circleNode plug-in to $HOME/myCircleNode and then built it using the Debug configuration, then the plug-in will be in $HOME/myCircleNode/build/Debug/circleNode.bundle.

In order for Maya to find the plug-in you must set a number of environment variables to point to the directories containing its files. Continuing in our use of the circleNode plug-in as an example, you would put the following into your Maya.env file:

    MAYA_PLUG_IN_PATH = $HOME/myCircleNode/build/Debug
    MAYA_SCRIPT_PATH = $HOME/myCircleNode
    XBMLANGPATH = $HOME/myCircleNode/%B

See the section on using Makefiles above for more details on these environment variables and the Maya.env file.

## Maya API applications

For building API applications, we only provide a Makefile solution. To build the supplied stand-alone application examples, you need to do the following:

    setenv MAYA_LOCATION /Applications/Autodesk/maya2014/Maya.app/Contents
    mkdir $HOME/devkit/applications
    cd $HOME/devkit/applications
    cp MAYA_LOCATION/Applications/Autodesk/maya2014/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.

On Mac OS X, you must set the DYLD_LIBRARY_PATH environment variable before you try to execute one of these applications so the runtime linker can find the Maya shared libraries.

The recommended procedure for preparing to build and run stand-alone applications is to set the following environment variables:

    setenv MAYA_LOCATION /Applications/Autodesk/maya2014/Maya.app/Contents
    setenv DYLD_LIBRARY_PATH $MAYA_LOCATION/MacOS
    setenv DYLD_FRAMEWORK_PATH $MAYA_LOCATION/Frameworks