I need to install the gcc3.3 on my OS X 10.5.8 to try something. For that purpose, I need to install it into a custom directory, such as /usr/loca/gcc-3.3

By default, the gcc3.3.pkg installs itself directly into /usr/bin To change that default directory, I've tried this command line:

sudo installer -pkg ~/Downloads/gcc3.3.pkg -target /usr/local/gcc-3.3

but that didn't work and the installer installed it into /usr/bin

So how can I install a .pkg into a custom directory?

  • gcc.gnu.org/install Try building from source where install prefix is easy to set & directory can be removed too.
    – anki
    Jul 25, 2020 at 17:07
  • That would require too much time and the resulting binaries possibly would not be as good as the ones inside the gcc3.3.pkg
    – Terry
    Jul 25, 2020 at 17:51

4 Answers 4


Try unpkg. It has worked flawlessly for me for several years.

unpkg solves the problem of installing a .pkg outside its intended location. You still have to figure out how to run gcc from that location. I assume it's a matter of setting the correct environment variables or setting symbolic links in /usr/local .


You cannot redirect the target on this package. Per the installer manpage the target is a device node entry such as /dev/disk*, disk ID disk1s9, a volume mount point /Volumes/Untitled, or a volume UUID. When I tried to change the target it wouldn't allow it to be changed.

The gcc3.3.pkg is a standard Apple Pkg format so right-click and Show Package Contents. Then all you have to do is "tar zxvf Archive.pax.gz" somewhere and Bob's Your Uncle. There are the files you want.

You could then repackage it how you wish for future use or you can just copy the files where you want them and try that.

  • On finder, the Show Package Contents doesn't appear on right-click. Actually I had tried it before I send the post. By the way, the gcc3.3.pkg is available within the XCode-3.2.x
    – Terry
    Jul 25, 2020 at 21:20
  • Copy the gcc3.3.pkg to a newer Mac. If you were trying it on Leopard. Jul 25, 2020 at 21:31
  • Yep, I'm trying it on Leopard. I've tried it now on Lion and no luck, the Show Package Contents option didn't appear. But just right now, the unpkg method worked out perfectly.
    – Terry
    Jul 25, 2020 at 21:42
  • In Terminal does the gcc3.3.pkg appear as a directory? Like the packages in /Applications? gcc3.3.pkg/Contents/Archive.pax.gz is what I see. Unzip that file and you'll have Archive/usr/bin etc. I grabbed XCode-3.2.1 and it was a PowerPC binary, FYI. Jul 25, 2020 at 21:51
  • You aren't doing this on a Developer Tools CD/DVD? If so, copy the file to a folder on disk. Then try again. Jul 25, 2020 at 21:52

I checked the man page ( run man installer) and -target can only specify volume, like the examples given on the man page. It doesn't accept a custom install directory.

So you may make a new volume or a dmg with double or triple the size of .pkg & install gcc there. Use Disk Utility to achieve this, or if you have a writable DMG, then use that. Don't make a partition, "Create Volume" instead. Use either of the following afterwards.

installer -pkg InstallMe.pkg -target /dev/disk2
installer -pkg InstallMe.pkg -target /Volumes/my_gcc_vol

Where /dev/disk2 is what you can find by running diskutil list.

  • That's quite informative and helpful. I will try it if I get no results using the unpkg method which was suggested by another user.
    – Terry
    Jul 25, 2020 at 21:25

Several of the scripts for things like compiling and running GCC assumes the GCC app being in the /usr/bin directory and installing it elsewhere may require other scripts being rewritten or being run manually and/or your path being updated. Unless you have a compelling reason to put it in a custom directory I'd install it wherever it wants.

  • I will use those gcc3.3binaries to compile an old package. And it's easy to set it, i.e. GCC=/usr/local/gcc-3.3/bin/gcc before configuring. After I compile the package I'd like to be able to delete the gcc3.3 without messing with the present versions of the gcc which are (AFAICR) 4.0.1and 4.2.0 That's why I'd like to install it into a custom directory.
    – Terry
    Jul 25, 2020 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .