Plone 3.3 Site Administration
上QQ阅读APP看书,第一时间看更新

How to install a C compiler

Both Python and Zope 2 require a C compiler to build from source. So let us take a minute to explore the available options. Regardless of the packaging, each of the following software provides some version of the GNU Compiler Collection (GCC) and libraries (http://gcc.gnu.org/gcc-4.3/).

Installing a C compiler on Mac OS X

Before you can compile C code on Mac OS X, you must install XCode (http://developer.apple.com/technologies/tools/xcode.html).

Installing XCode

Check your Mac OS X installation DVD or Apple Developer Connection (http://developer.apple.com/) for the latest version.

Verify that GCC works

To verify that GCC works, open Finder | Applications | Utilities | Terminal and type:

$ gcc

You should see:

We have just finished explaining how to install and test a C compiler on Mac OS X.

Installing a C compiler on Windows

Before you can compile C code on Windows, you must install MinGW (or Microsoft's Visual Studio, but that approach is not covered in this book).

Downloading MinGW

To download MinGW with Internet Explorer:

  1. Browse to http://mingw.org.
  2. Click on Downloads | View all files | Automated MinGW Installer | MinGW-5.1.6.exe.
  3. Save the file.
  4. Run the installer.

Installing MinGW

Windows will present a series of dialogues you can answer based on the following suggestions:

  • Select the current package
  • Select g++ and check options in addition to the base tools
  • Select the default location

You should see:

Adding MinGW to the Environment Variable—Path

Now that a C compiler is installed, we would like to be able to easily run the gcc command from the Command Prompt. To accomplish this, perform the following steps:

  1. Select Start | Computer System Properties | Advanced system settings | Environment Variables.
  2. Under System variables, scroll down to Path.
  3. Select Edit.
  4. Add the following separated by a semicolon:
    • C:\MinGW\bin
  5. Click on Save.

You should see:

Verify that GCC works

To verify that your C compiler works, select Start | All Programs | Accessories | Command Prompt and type:

$ gcc

You should see:

We have just demonstrated how to install and test a C compiler on Windows.

Configuring Distutils

Later, when you try to compile Zope 2, your Buildout may fail with a Visual Studio error like this:

To avoid this error, you can configure Distribute to use MinGW's C compiler. Just create a file called C:\Python\Lib\Distutils\distutils.cfg, and include the following contents:

[build] 
compiler=mingw32

Visit http://plone.org/documentation/kb/using-buildout-on-windows/ for more information.

Installing a C compiler on Ubuntu Linux

Before you can compile C code on Ubuntu Linux, you must install the build-essential package (http://packages.ubuntu.com/lucid/build-essential):

$ sudo aptitude install build-essential

You should see:

Verify that GCC works

To verify that GCC works, type:

$ gcc  
gcc: no input files 

You should see:

We have just demonstrated how to install and test a C compiler on Ubuntu Linux.

Installing additional development libraries

Later on, when you are using Buildout to install Python, you may encounter this error:

To avoid this error, install the zlib1g-dev library:

$ sudo aptitude install zlib1g-dev