Install Allegro5 From GIT/OSX

本文档详细介绍了如何在MacOSX上通过Git获取Allegro5源代码,并使用Xcode或make工具进行静态库构建的过程。同时提供了安装所需依赖库的方法,包括使用MacPorts等包管理器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



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
内容概要:该研究通过在黑龙江省某示范村进行24小时实地测试,比较了燃煤炉具与自动/手动进料生物质炉具的污染物排放特征。结果显示,生物质炉具相比燃煤炉具显著降低了PM2.5、CO和SO2的排放(自动进料分别降低41.2%、54.3%、40.0%;手动进料降低35.3%、22.1%、20.0%),但NOx排放未降低甚至有所增加。研究还发现,经济性和便利性是影响生物质炉具推广的重要因素。该研究不仅提供了实际排放数据支持,还通过Python代码详细复现了排放特征比较、减排效果计算和结果可视化,进一步探讨了燃料性质、动态排放特征、碳平衡计算以及政策建议。 适合人群:从事环境科学研究的学者、政府环保部门工作人员、能源政策制定者、关注农村能源转型的社会人士。 使用场景及目标:①评估生物质炉具在农村地区的推广潜力;②为政策制定者提供科学依据,优化补贴政策;③帮助研究人员深入了解生物质炉具的排放特征和技术改进方向;④为企业研发更高效的生物质炉具提供参考。 其他说明:该研究通过大量数据分析和模拟,揭示了生物质炉具在实际应用中的优点和挑战,特别是NOx排放增加的问题。研究还提出了多项具体的技术改进方向和政策建议,如优化进料方式、提高热效率、建设本地颗粒厂等,为生物质炉具的广泛推广提供了可行路径。此外,研究还开发了一个智能政策建议生成系统,可以根据不同地区的特征定制化生成政策建议,为农村能源转型提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值