Install Allegro5 From GIT/OSX



Contents

  [hide]

Preliminaries

There are two ways to install Allegro on Mac OSX. You can either:

  • Build static libraries that will be installed to /usr/local/lib, with the headers in /usr/local/include.
  • Build frameworks. These can be put with the system frameworks, or kept with your project.

Both can be done either using the make or Xcode generators in CMake. Both can be done from the command-line.

Required software

You will need the following tools installed:

  • Xcode: You can install this from your Mac OS X install DVD, or download it from Apple's developer website [1], or from the AppStore.
    • Xcode 4.3 now installs properly an application in /Application so you should get it via the AppStore, then it can be patched (with much smaller downloads).
    • Earlier versions of Xcode are buggy. It is advised to get the latest version and keep updating the patches.
    • Xcode 4 drops support for PowerPC. Xcode 4.2 drops support for armv6.
  • CMake: You can download a .dmg installer from http://www.cmake.org/cmake/resources/software.html, or from MacPorts.
    • IMPORTANT: Note that in Xcode 4.3 Apple now install Xcode properly as an Application. However, this breaks the paths in cmake <= 2.8.7, as they have moved around. To generate projects for Xcode 4.3 you will need cmake 2.8.8 or better.
    • cmake 2.8.2 has bugs related to iOS so avoid this version.
  • GIT client. There are various options:
    • Install the command-line utilities from XCode

Allegro depends on a number of external libraries and you will need to have these installed to use certain functionality. There are again two ways to install these packages:

  • Use a package manager (either MacPorts or Fink). MacPorts is more up to date and sponsored by Apple. The examples below will use MacPorts.
  • You may be able to find a developer framework with an installer.

These dependencies are optional, but highly recommended because you will lose functionality without them.

  • libpng and zlib - for loading PNG images.
  • freetype2 - for loading and displaying TrueType fonts. You'll need a more-or-less recent version. If you get an error about "'FT_Size_RequestRec' undeclared (first use in this function)" you'll need to upgrade the version you have.
  • libjpeg - for loading JPEG images.
  • libogg and libvorbis - for loading sound files.
  • physfs - a library that allows Allegro to read various compressed archives.

Assuming you have MacPorts, you can install all of these via the command-line. For Snow Leopard and above these will be compiled by default as 64-bit. Prior to this the default was 32-bit. If you want to develop for iPhone and the simulator you'll need the 32-bit versions (i386). You can get these by adding "+universal". This just compiles all the variations of the libraries. If you only want 64-bit libraries because you are only targeting current OSX then you can remove the "+universal" flag.

sudo port install zlib freetype jpeg libogg physfs libpng flac libtheora +universal

If you already have some of these libraries installed and need an i386 version you can force Macports to recompile and maintain the variations using the following. Here we force libpng to be compiled as i386 and x86_64:

sudo port upgrade --enforce-variants libpng +universal

Allegro will also use OpenAL for sound output and OpenGL for graphics, but these will already be installed on your system.

Documentatiom': To build the documentation, you will need the pandoc program. This can be installed through DarwinPorts (port install pandoc), but at the moment (January 2010) this does not work in Mac OS X 10.6 (Snow Leopard) because the Haskell compiler ghc does not yet work properly. This means that at the moment you will not be able to install the documentation on Snow Leopard.

Getting the source

Open a Terminal. At the commandline type

$ git clone git://git.code.sf.net/p/alleg/allegro allegro

and finish by pressing return (don't type the $, that represents the command prompt).

Building static Allegro with XCode

Change to the directory where you installed Allegro, say allegro (as in the above example)

$ cd allegro

It is normally a good idea to place all of the build generated files in a subdirectory (a so-called out-of-source build) because this makes it easier to restart with a clean slate (just delete the directory):

$ mkdir build
$ cd build

Now it is time to configure Allegro:

$ cmake-gui ..

As generator, choose XCode. Then hit configure. Then hit generate, and exit cmake-gui again.

$ xcode-build -target ALL_BUILD

and relax while everything compiles. If everything goes well you can type

$ sudo xcode-build -target install

to install Allegro. If you're installing in your own directory, you don't need sudo (but it doesn't hurt).

Building static Allegro with make

Change to the directory where you installed Allegro, say allegro (as in the above example)

$ cd allegro

It is normally a good idea to place all of the build generated files in a subdirectory (a so-called out-of-source build) because this makes it easier to restart with a clean slate (just delete the directory):

$ mkdir build
$ cd build

Now it is time to configure Allegro:

$ cmake ..

If you want to change some of the options manually you may want to use ccmake rather than cmake in the above command. One of the things you may like to change is the location where Allegro is installed (you may want to use your personal directory rather than a system-wide location). When Allegro has been configured, type

$ make

and relax while everything compiles. If everything goes well you can type

$ sudo make install

to install Allegro. If you're installing in your own directory, you don't need sudo (but it doesn't hurt).

Building Allegro through Xcode

We will build Allegro from the command-line using xcodebuild. This comes as part of an Xcode installation.

To begin with, these steps are almost the same as in the previous listing. In a Terminal window, change to the directory where you installed Allegro, say allegro

$ cd allegro

It is normally a good idea to place all of the build generated files in a subdirectory (a so-called out-of-source build) because this makes it easier to restart with a clean slate (just delete the directory):

$ mkdir build
$ cd build

Now it is time to configure Allegro. We'll add a flag to turn frameworks on, although this is optional.

$ cmake -D WANT_FRAMEWORKS=1 -G Xcode ..

Cmake will now create an Xcode project file called ALLEGRO.xcodeproj. You can open this in Xcode to have a look or build from the command-line using:

$ xcodebuild -project ALLEGRO.xcodeproj -target ALL_BUILD -arch x86_64 -sdk macosx10.7 -configuration Release

This tells Xcode to build everything for 64-bit architecture using the Lion SDK. You can change the options according to what you have installed. You can find which SDKs you have installed using xcodebuild --showsdks.

If you have multiple versions of Xcode installed you may have to use xcode-select to choose the one you want to use. Xcode 4.3 has moved to the "/Applications" folder. Previously it was in "/Developer". If you also have Xcode 3 installed this may be in "/Developer-3.2.6" (or whatever version you have). To switch version you can do:

$ xcode-select -switch /Developer                                     # Default location < 4.3
$
$ xcode-select -switch /Application/Xcode.app/Contents/Developer/     # Choose >= 4.3

Contents

  [hide]

Preliminaries

There are two ways to install Allegro on Mac OSX. You can either:

  • Build static libraries that will be installed to /usr/local/lib, with the headers in /usr/local/include.
  • Build frameworks. These can be put with the system frameworks, or kept with your project.

Both can be done either using the make or Xcode generators in CMake. Both can be done from the command-line.

Required software

You will need the following tools installed:

  • Xcode: You can install this from your Mac OS X install DVD, or download it from Apple's developer website [1], or from the AppStore.
    • Xcode 4.3 now installs properly an application in /Application so you should get it via the AppStore, then it can be patched (with much smaller downloads).
    • Earlier versions of Xcode are buggy. It is advised to get the latest version and keep updating the patches.
    • Xcode 4 drops support for PowerPC. Xcode 4.2 drops support for armv6.
  • CMake: You can download a .dmg installer from http://www.cmake.org/cmake/resources/software.html, or from MacPorts.
    • IMPORTANT: Note that in Xcode 4.3 Apple now install Xcode properly as an Application. However, this breaks the paths in cmake <= 2.8.7, as they have moved around. To generate projects for Xcode 4.3 you will need cmake 2.8.8 or better.
    • cmake 2.8.2 has bugs related to iOS so avoid this version.
  • GIT client. There are various options:
    • Install the command-line utilities from XCode

Allegro depends on a number of external libraries and you will need to have these installed to use certain functionality. There are again two ways to install these packages:

  • Use a package manager (either MacPorts or Fink). MacPorts is more up to date and sponsored by Apple. The examples below will use MacPorts.
  • You may be able to find a developer framework with an installer.

These dependencies are optional, but highly recommended because you will lose functionality without them.

  • libpng and zlib - for loading PNG images.
  • freetype2 - for loading and displaying TrueType fonts. You'll need a more-or-less recent version. If you get an error about "'FT_Size_RequestRec' undeclared (first use in this function)" you'll need to upgrade the version you have.
  • libjpeg - for loading JPEG images.
  • libogg and libvorbis - for loading sound files.
  • physfs - a library that allows Allegro to read various compressed archives.

Assuming you have MacPorts, you can install all of these via the command-line. For Snow Leopard and above these will be compiled by default as 64-bit. Prior to this the default was 32-bit. If you want to develop for iPhone and the simulator you'll need the 32-bit versions (i386). You can get these by adding "+universal". This just compiles all the variations of the libraries. If you only want 64-bit libraries because you are only targeting current OSX then you can remove the "+universal" flag.

sudo port install zlib freetype jpeg libogg physfs libpng flac libtheora +universal

If you already have some of these libraries installed and need an i386 version you can force Macports to recompile and maintain the variations using the following. Here we force libpng to be compiled as i386 and x86_64:

sudo port upgrade --enforce-variants libpng +universal

Allegro will also use OpenAL for sound output and OpenGL for graphics, but these will already be installed on your system.

Documentatiom': To build the documentation, you will need the pandoc program. This can be installed through DarwinPorts (port install pandoc), but at the moment (January 2010) this does not work in Mac OS X 10.6 (Snow Leopard) because the Haskell compiler ghc does not yet work properly. This means that at the moment you will not be able to install the documentation on Snow Leopard.

Getting the source

Open a Terminal. At the commandline type

$ git clone git://git.code.sf.net/p/alleg/allegro allegro

and finish by pressing return (don't type the $, that represents the command prompt).

Building static Allegro with XCode

Change to the directory where you installed Allegro, say allegro (as in the above example)

$ cd allegro

It is normally a good idea to place all of the build generated files in a subdirectory (a so-called out-of-source build) because this makes it easier to restart with a clean slate (just delete the directory):

$ mkdir build
$ cd build

Now it is time to configure Allegro:

$ cmake-gui ..

As generator, choose XCode. Then hit configure. Then hit generate, and exit cmake-gui again.

$ xcode-build -target ALL_BUILD

and relax while everything compiles. If everything goes well you can type

$ sudo xcode-build -target install

to install Allegro. If you're installing in your own directory, you don't need sudo (but it doesn't hurt).

Building static Allegro with make

Change to the directory where you installed Allegro, say allegro (as in the above example)

$ cd allegro

It is normally a good idea to place all of the build generated files in a subdirectory (a so-called out-of-source build) because this makes it easier to restart with a clean slate (just delete the directory):

$ mkdir build
$ cd build

Now it is time to configure Allegro:

$ cmake ..

If you want to change some of the options manually you may want to use ccmake rather than cmake in the above command. One of the things you may like to change is the location where Allegro is installed (you may want to use your personal directory rather than a system-wide location). When Allegro has been configured, type

$ make

and relax while everything compiles. If everything goes well you can type

$ sudo make install

to install Allegro. If you're installing in your own directory, you don't need sudo (but it doesn't hurt).

Building Allegro through Xcode

We will build Allegro from the command-line using xcodebuild. This comes as part of an Xcode installation.

To begin with, these steps are almost the same as in the previous listing. In a Terminal window, change to the directory where you installed Allegro, say allegro

$ cd allegro

It is normally a good idea to place all of the build generated files in a subdirectory (a so-called out-of-source build) because this makes it easier to restart with a clean slate (just delete the directory):

$ mkdir build
$ cd build

Now it is time to configure Allegro. We'll add a flag to turn frameworks on, although this is optional.

$ cmake -D WANT_FRAMEWORKS=1 -G Xcode ..

Cmake will now create an Xcode project file called ALLEGRO.xcodeproj. You can open this in Xcode to have a look or build from the command-line using:

$ xcodebuild -project ALLEGRO.xcodeproj -target ALL_BUILD -arch x86_64 -sdk macosx10.7 -configuration Release

This tells Xcode to build everything for 64-bit architecture using the Lion SDK. You can change the options according to what you have installed. You can find which SDKs you have installed using xcodebuild --showsdks.

If you have multiple versions of Xcode installed you may have to use xcode-select to choose the one you want to use. Xcode 4.3 has moved to the "/Applications" folder. Previously it was in "/Developer". If you also have Xcode 3 installed this may be in "/Developer-3.2.6" (or whatever version you have). To switch version you can do:

$ xcode-select -switch /Developer                                     # Default location < 4.3
$
$ xcode-select -switch /Application/Xcode.app/Contents/Developer/     # Choose >= 4.3
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值