I wanted to compile my sePushPullConstraint plugin for Linux so I have all the operating systems covered and for future development. According to the Maya 2015 API documentation, the compiler requirements for Linux is to use gcc version 4.1.2. I am running Fedora 20 which has a much newer version packaged in, version 4.8.3. The version of gcc I need was released back in 2007 and it is not easy finding that version that installed properly. So I had no choice but to download the source code and build the compiler myself. As with anything Linux related, this is not a simple or fool proof process. I spent many hours of rebuilding and searching for answers to the errors I was getting. This drove me to post this in hopes it will help others.

Just a word of advice, if you get an error during your build, it’s often better to clear out the build directory and start clean rather than have it build where it left off. I found that if I didn’t do this, I would get new errors that went away after I deleted all of the build files and started over. Ok so let’s get started and I’ll walk you through all the steps.

Step 1: Getting required libraries and tools

This is the most important part of getting the build to work. Again, I am using Fedora, so other Linux distributions will be a little different. There are many packages you will need on your system, some may already be install. Make sure you update them before you begin just to be safe. There are a couple that really stumped me until I discovered they are required. So in a terminal:

There may be others, so if you see an error about a missing package, check that you have it installed. There is also some information about requirements here: https://gcc.gnu.org/install/prerequisites.html

Step 2: Download GCC 4.1.2

Go to https://www.gnu.org/software/gcc/gcc-4.1/ and choose your preferred way of downloading the source code.

Step 3: Unpack the gcc source

In a terminal go to a directory where you will build the compiler. We are going to create a directory to contain both our source and our build called gcc412. Then inside that directory, make a gcc-build directory and extract the downloaded source code into gcc412 directory. This should make a new directory called gcc-4.1.2 beside the gcc-build directory.

Step 4: Patch source code files

There are some bugs in the source code that needs to be fixed otherwise it will fail to build. To make it easier, I have a download that you can use to simply replace these files instead of modifying them yourself.

  1. Copy linux-unwind.h to […]/gcc412/gcc-4.1.2/gcc/config/i386/
  2. Copy prims.cc to […]/gcc412/gcc-4.1.2/libjava/

If you are really interested, about these bugs:

linux-unwind.h – http://forge.ispras.ru/issues/4295
prims.cc – https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50888

Step 5:  Configure the compiler

In a terminal, go into the gcc-build directory that you created, which should be empty. Now we are going to run the compiler configuration. You can change the location of where gcc will be installed by changing the –prefix option as well as the –program-suffix. This is to avoid overwriting your current installation.

If you do get errors, remember to delete all files from this build directory before trying again. It’s always good to start fresh until you get a successful configuration.

Step 6: Build the compiler

Still inside the build directory still, we will now make the compiler using this command. This will take a while so just be patient:

Step 7: Install the compiler

Now install the compiler in the location we set in the configuration: /opt/gcc412

Create a symbolic link to the compiler

Not required but it may be useful to create a symbolic link to the compiler so you can easily call it in your Makefiles for your plugins using gcc412 and g++412.

If/When you encounter an error

  • It may be that you are missing an required library. Do a search for what the error is related to and see if you are missing any libraries.
  • It is often better to start rebuilding from scratch if you need to run the configure command again. Do this by running a “make clean” in the gcc-build directory. It may take longer but it will make sure everything is built correctly.

I hope in the future releases Autodesk can agree to use a newer version of a compiler to not only make it easier to setup and support, but also to use modern processor features and libraries that may not be compatible with old compilers. You can attempt to use a newer version of gcc but there may be issues or errors using your plugin. So it’s difficult to know for sure what will work which is why it may be safer to use the version Autodesk recommends.