Difference between revisions of "HowTo compile on Mac"

From AMule Project FAQ
Jump to: navigation, search
(Binary releases: pipe correct typography)
 
(139 intermediate revisions by 47 users not shown)
Line 1: Line 1:
The following steps will lead you to install [[aMule]] in your [http://www.apple.com/macosx MacOS X] box.
+
<center>
 +
'''English''' |
 +
[[HowTo_compile_on_Mac-de|Deutsch]] |
 +
[[HowTo_compile_on_Mac-es|Espa&ntilde;ol]] |
 +
[[HowTo_compile_on_Mac-fr|Fran&ccedil;ais]] |
 +
[[HowTo_compile_on_Mac-it|Italiano]]
 +
</center>
  
This HowTo is written to install [[aMule]] 2.0.0-rc7 but should work for any other version. Please note that you should always download the latest [[aMule]] version available.
+
How to get and install [[aMule]] on [http://www.apple.com/macosx/ Apple Mac OS X].
  
'''NOTE:''' This document explains how to download files using [http://curl.haxx.se curl]. However, [http://curl.haxx.se curl] might not be installed on your system: either install it (you can use [http://fink.sourceforge.net Fink] to instal it) or download the files with whatever application you want (maybe your web browser), but place then in the directory that's being used on each part of the guide, otherwise the commands that are shown here will not work.
+
# You can simply download the finished application ('binary release');
 +
# You compile it from a [[aMule SVN|SVN source snapshot]] or [http://www.amule.org/files/files.php?cat=42 stable release source].
  
# Install [http://developer.apple.com/tools/xcode Xcode Tools] from http://developer.apple.com/tools/download
+
== Binary releases ==
# "Getting ADC ID"->"Log In"->"Download Software"->"Developer Tools"->"Download Xcode Tools last release">"Install"
+
If you don't want to bother with installing and compiling all those tools and sources, then get one of the pre-compiled [[aMule]] applications. The official release is considered 'stable', but every now and then applications are built from the current source to allow more people to test new features or the like.  
# Install (or verify installation if already installed) [http://fink.sourceforge.net Fink], since [http://www.gnu.org/software/gettext gettext] and [[wxMac]] are installed along with [http://fink.sourceforge.net Fink], from http://fink.sourceforge.net/download
+
# Install [http://www.gnu.org/software/gettext gettext] and [[wxMac]] ([[wxMac]] is only available through [http://fink.sourceforge.net Fink] [http://fink.sourceforge.net/faq/usage-fink.php?phpLang=en#unstable unstable] on [http://www.apple.com/macosx MacOS] 10.3. If you are using [http://fink.sourceforge.net Fink] stable or [http://www.apple.com/macosx MacOS] 10.2 or earlier, either [http://fink.sourceforge.net/faq/usage-fink.php?phpLang=en#unstable upgrade Fink to unstable] and/or [http://www.apple.com/macosx MacOS] to 10.3, or check the  [[#Installing wxMac form sources|Installing wxMac form sources section]] of this document and then go on with this section) through [http://fink.sourceforge.net Fink]. Read [http://fink.sourceforge.net/download Fink's installation guide] to learn how to install applications through [http://fink.sourceforge.net Fink] (the [http://www.gnu.org/software/gettext gettext] package is ''gettext'' and the [[wxMac]] package is ''wxmac'' and ''wxmac-shlibs''),
+
# Read the documentation at http://fink.sourceforge.net/download to learn how to install [[wxMac]].
+
# Make ''amule'' dir in your home directory: ''mkdir ~/amule''
+
# Enter the ''amule'' directory you just created: ''cd ~/amule''
+
# Get [[aMule]]'s latest source code (aMule 2.0.0-rc7 sourcecode: [http://download.berlios.de/amule/aMule-2.0.0rc7.tar.bz2 http://download.berlios.de/amule/aMule-2.0.0rc7.tar.bz2]) and place it in your ''~/amule'' directory: curl -O http://download.berlios.de/amule/aMule-2.0.0rc7.tar.bz2
+
# Extract it: ''tar -xjf aMule-2.0.0rc7.tar.bz2''
+
# Enter [[aMule]]'s sources directory: ''cd aMule-2.0.0rc7''
+
# Prepare the compilation (thanks to '''one_2_one''' and '''Babboia''' for his test&fix): ''./configure --disable-systray --disable-gtk --with-wx-config=/sw/bin/wx-config''
+
# And compile it: ''make''
+
# '''Optional:''' You can reduce the size of [[aMule]] from 44MB to 3MB by doing the following (anyway, this will make the [[aMule]] binnary loose debug info, so you'll be unable to report problems to the [[aMule devs|aMule Team]] to make [[aMule]] a better program, which it is not recommended): ''strip src/amule''
+
# Get back to your ''amule'' directory: ''cd ~/amule''
+
# Download [http://download.berlios.de/amule/aMule-App-Container.tar.bz2 aMule's app-Container]: ''curl -O http://download.berlios.de/amule/aMule-App-Container.tar.bz2''
+
# Extract it: ''tar -xjf aMule-App-Container.tar.bz2''
+
# Copy the ''amule'' binnary to the app-Container directory: ''cp aMule-2.0.0rc7/src/amule amule.app/Contents/MacOS/''
+
# And move ''amule.app'' directory to your Applications folder: ''mv amule.app /Applications''
+
# If everything went ok, you can safely remove the downloaded packages:
+
## Remove [[aMule]]'s sources package: ''rm ~/amule/aMule-2.0.0rc7.tar.bz2''
+
## Remove the app-Container package: ''rm aMule-App-Container.tar.bz2''
+
## Optionally remove the extracted [[aMule]] sources (not recommended, since you might want to compile it again someday): ''rm -r ~/amule/aMule-2.0.0rc7''
+
## Optionally, if you if you decided to remove the extracted [[aMule]] sources, remove the ''~/amule'' directory (which should be empty by now): ''rmdir ~/amule''
+
  
== Installing [[wxMac]] form sources ==
+
Check the Mac forum for the most recent user posted binary: [http://forum.amule.org/index.php?board=49.0 aMule forum]
  
Only follow this part of the guide if [[wxMac]] is not available through your [http://fink.sourceforge.net Fink] installation or if you really know what you're doing. In any other case, just jump to the next section.
+
Now, to install the downloaded binary, just drag the aMule application to a folder of your choice (e.g., ''/Applications'').
  
# Create a directory where all the work will be done: ''mkdir ~/wxmac''
+
To start aMule, double-click the application icon.
# Enter that directory: ''cd ~/wxmac''
+
# Download [[wxMac]] sources: ''curl -O ftp://biolpc22.york.ac.uk/pub/2.5.3/wxMac-2.5.3.tar.gz''
+
# Extract the file: ''tar -xzf wxMac-2.5.3.tar.gz''
+
# Enter the extracted sources' directory: ''cd wxMac-2.5.3''
+
# Directory ''build'' should already be there. If not, create it with: ''mkdir build''
+
# Now enter ''build'' directory: ''cd build''
+
# Prepare the compilation: ''../configure''
+
# And compile: ''make''
+
# Now install [[wxMac]] compilation: ''sudo make install''
+
# Get back to your home directory, you're done: ''cd ~''
+
# If everything went ok, you can safely remove:
+
## [[wxMac]]'s sources package: ''rm wxMac-2.5.3.tar.gz''
+
## Optionally remove the extracted [[wxMac]] sources (not recommended, since you might want to compile it again someday): ''rm -r ~/wxmac
+
  
'''NOTE:''' Since you're installing [[wxMac]] from sources instead of through [http://fink.sourceforge.net Fink], use ''./configure --disable-systray --disable-gtk --with-wx-config=/usr/local/bin/wx-config'' as your configure command at [[aMule]]'s compilation instead of ''./configure --disable-systray --disable-gtk --with-wx-config=/sw/bin/wx-config''
+
'''Note:''' You might want to take a look at the [[Mac specific usage|Mac-specific usage]] article.
  
== Problems and solutions ==
+
== Compiling from source ==
 +
Compiling from source allows most current bug reports, because you can compile and test the [[aMule SVN|SVN snapshot]] of the very day.
  
*If [http://fink.sourceforge.net Fink] reports something like: ''After unpacking 11.2GB will be freed'', don't be afraid. [http://fink.sourceforge.net Fink] has evolved into a different way of managing packet's size and some old ("old": at least some months old) packages' sizes aren't handled correctly on the output. If this is your case, devide the number by 1024. So, what the above example really means is: ''After unpacking 11.2MB will be freed''.
+
To compile [[aMule]] from source you need some development tools, the [[wxWidgets]] library and the [http://www.amule.org/files/files.php?cat=42 aMule source].
  
*If the app-Container failed to extract try running this command instead of the app-Container extraction step: ''mkdir -p amule.app/Contents/MacOS''
+
=== Get the sources and development tools ===
 +
==== Step 1: Download and install [http://developer.apple.com/tools/xcode Xcode] ====
 +
[http://developer.apple.com/tools/xcode Xcode] is [http://www.apple.com Apple]'s development environment. We need it for the [http://gcc.gnu.org GCC] compiler.
  
*If you get an error like this: ''You cannot open the application "amule" because it may be damaged or incomplete'', right click on ''amule'', then click on ''Show Packages Contents'', go to "Contents">"MacOS"> and double click on ''amule''. Next time you start from ''amule.app'' it will run fine. If you still get the same error, move ''amule.app'' to the desktop and run it from there.
+
You will need at least version 2.1 of Xcode, a more recent version is preferable though. You can download the most recent version of Xcode from Apple, but you will need to sign up for a free-of-charge developer account first or log-in using your iTunes Store account.
 +
 
 +
# Get Xcode from http://developer.apple.com/tools/download
 +
# "Member Site"->"Log In"->"Download Software"->"Developer Tools"->"Download Xcode Tools last release">"Install"
 +
 
 +
==== Step 2: Install [http://www.macports.org MacPorts]====
 +
[http://www.macports.org MacPorts] is an open source installer for lots of open source tools ported to [http://macos.apple.com Mac OS X]. aMule needs a few of these tools to compile properly. Alternatively, <del>you can also use [http://www.finkproject.org/ Fink] to install these tools or</del> (Fink currently lacks many of the needed tools) you can install them manually .
 +
 
 +
# Download the most recent version of [http://www.macports.org MacPorts]
 +
# Read [http://guide.macports.org/ MacPorts' documentation] to learn how to install applications through [http://www.macports.org MacPorts].
 +
 
 +
===== Syntax of most important commands =====
 +
Packages list can be downloaded/updated through
 +
 
 +
  $ sudo port selfupdate
 +
 
 +
You can upgrade all the packages installed with
 +
 
 +
  $ sudo port upgrade installed
 +
 
 +
Packages can be installed through
 +
 
 +
  $ sudo port install ''package_name''
 +
 
 +
and removed with
 +
 
 +
  $ sudo port uninstall ''package_name''
 +
 
 +
Port variants can be invoked with the plus sign:
 +
 
 +
  $ sudo port install ''package_name'' +universal
 +
 
 +
You can list all available variants with:
 +
 
 +
  $ sudo port variants ''package_name''
 +
 
 +
===== Notes about Universal variant =====
 +
 
 +
As stated [http://guide.macports.org/chunked/internals.configuration-files.html here], MacPorts has different build_arch settings for ''universal'' variant. You can use this variant on Leopard to switch both ppc and i386 version on. Since Snow Leopard doesn't support ppc architecture anymore, the universal variant can be used to switch both i386 and x86_64 version on. Please note that default architecture on Snow Leopard is x86_64 if the CPU supports it, i386 otherwise.
 +
 
 +
'''WARNING''': ''binutils'' [https://svn.macports.org/ticket/21588 fails] building universal. So you should set ''build_arch'' to ''i386'' (about line 59) into ''/opt/local/etc/macports/macports.conf'' to be sure to build every port against i386 architecture (x86_64 is useless since 64-bit Carbon libraries does not exists and wxCocoa is not ready yet).
 +
 
 +
==== Step 3: Install libraries and tools ====
 +
 
 +
These are the package that provides (with dependancies) all needed libraries and tools to build [[wxWidgets]] and [[aMule]] with most of feature:
 +
 
 +
# automake
 +
# binutils
 +
# flex
 +
# gettext
 +
# libpng
 +
# libcryptopp
 +
# libiconv
 +
# gd2
 +
# jpeg
 +
# libgeoip
 +
# libupnp
 +
# pkgconfig
 +
 
 +
This should be enough:
 +
 
 +
  $ sudo port install automake binutils flex libpng libcryptopp gd2 libgeoip libupnp
 +
 
 +
==== Step 4: Compile [[wxWidgets|wxMac]] ====
 +
[[wxWidgets|wxMac]] is the port of the [[wxWidgets]] library for [http://www.apple.com/macosx Mac OS X]. This library is used to make [[aMule]] 'multi-platform'.
 +
 
 +
Get the source from: http://www.wxwidgets.org/downloads/ (Source Archives: wxMac) and extract the archive on your desktop.<br>
 +
Last stable version is 2.8.11 at now.
 +
Type
 +
 
 +
$ cd
 +
 
 +
leave a space after the command, than drag and drop the wxMac uncompressed folder into the Terminal window: the complete path of the folder will be printed on screen. For example:
 +
 
 +
$ cd ~/Desktop/wxMac-2.8.11/
 +
 
 +
Press enter.
 +
The basic command to configure and compile the package is the following:
 +
 
 +
$ ./configure --disable-shared --enable-unicode --disable-debug --disable-debug_gdb --with-libiconv-prefix=/opt/local && make -j8
 +
 
 +
'''Note:''' The above command doesn't enable debug information. Debug informations allows you to submit a helpful stacktrace if [[aMule]] crashes or a sample if it hangs to the [[aMule devs|aMule developers]]. If you want to compile a debug version then you can use "--enable-debug --enable-debug_gdb" instead.
 +
 
 +
===== Snow Leopard =====
 +
 
 +
Building on Snow Leopard is tricky. You must focus on architecture, compiler version, compatibility. This should be enough to have compatibility with i386 Leopard and above:
 +
 
 +
  CC="gcc-4.2 -arch i386" CXX="g++-4.2 -arch i386" \
 +
  ./configure CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" \
 +
  CXXFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" \
 +
  CPPFLAGS="-arch i386" LDFLAGS="-arch i386" OBJCFLAGS="-arch i386" OBJCXXFLAGS="-arch i386" \
 +
  --disable-shared --enable-unicode --disable-debug --disable-debug_gdb --with-libiconv-prefix=/opt/local
 +
 
 +
followed by:
 +
 
 +
  make -j8
 +
 
 +
==== Step 5: Compile [[aMule]] ====
 +
Download [http://www.amule.org/files/files.php?cat=42 aMule source] and extract archive into the same place of wxMac (i.e. your desktop if you are following out suggestion).
 +
Open a Terminal and type:
 +
 
 +
  $ cd
 +
 
 +
then leave a space and drag and drop aMule uncompressed folder whose path will be printed on screen, for example:
 +
 
 +
  $ cd ~/Desktop/aMule-2.2.
 +
 
 +
Press Enter. Now it's possible to configure the sources: there are several options that can be used to activate or deactivate feature during compiling. This is only an example, that provide a full feature aMule build:
 +
 
 +
  $ ./configure --with-wx-config=../wxMac-2.8.10/wx-config  --enable-optimize --with-crypto-prefix=/opt/local \
 +
  --with-gdlib-config=/opt/local/bin/gdlib-config  --with-libiconv-prefix=/opt/local --enable-cas --enable-webserver \
 +
  --enable-amulecmd --enable-amule-gui --enable-wxcas --enable-alc --enable-alcc --enable-amule-daemon --enable-geoip \
 +
  --with-geoip-lib=/opt/local/lib --with-geoip-headers=/opt/local/include --enable-geoip-static --enable-debug
 +
 
 +
Take a look to the [[configure]] page for a complete list of options.
 +
You should pay attention to these elements:
 +
 
 +
# The given example enables debug informations. To disable them exchange the option ''--enable-debug'' with ''--disable-debug --enable-optimize''.
 +
# The option ''--with-wx-config'' must point to the correct relative path of the compiled wxMac. The example assumes that aMule and wxMac folders are in the same directory (i.e. your desktop). You should also correct the wxMac folder's name according to its version (in the example is 2.8.10).
 +
# The option ''--with-crypto-prefix'' should point to /usr/local/cryptopp if you compiled Crypto++ starting from its source, out of MacPorts.
 +
# '''IMPORTANT!''' It seems that Mac OS version of ''ld'' tool is not able to make static library. So if you plan to run/install your compiled aMule on other Mac which doesn't have MacPorts installed you MUST remove the ''--enable-geoip-static'' option to avoid a crash when the program starts.
 +
 
 +
Now it's time to make you packages with:
 +
 
 +
  $ make -j8
 +
 
 +
and
 +
 
 +
  ./src/utils/scripts/mac_packager
 +
 
 +
You should find the aMule package in the same source folder.

Latest revision as of 06:09, 14 January 2012

English | Deutsch | Español | Français | Italiano

How to get and install aMule on Apple Mac OS X.

  1. You can simply download the finished application ('binary release');
  2. You compile it from a SVN source snapshot or stable release source.

Binary releases

If you don't want to bother with installing and compiling all those tools and sources, then get one of the pre-compiled aMule applications. The official release is considered 'stable', but every now and then applications are built from the current source to allow more people to test new features or the like.

Check the Mac forum for the most recent user posted binary: aMule forum

Now, to install the downloaded binary, just drag the aMule application to a folder of your choice (e.g., /Applications).

To start aMule, double-click the application icon.

Note: You might want to take a look at the Mac-specific usage article.

Compiling from source

Compiling from source allows most current bug reports, because you can compile and test the SVN snapshot of the very day.

To compile aMule from source you need some development tools, the wxWidgets library and the aMule source.

Get the sources and development tools

Step 1: Download and install Xcode

Xcode is Apple's development environment. We need it for the GCC compiler.

You will need at least version 2.1 of Xcode, a more recent version is preferable though. You can download the most recent version of Xcode from Apple, but you will need to sign up for a free-of-charge developer account first or log-in using your iTunes Store account.

  1. Get Xcode from http://developer.apple.com/tools/download
  2. "Member Site"->"Log In"->"Download Software"->"Developer Tools"->"Download Xcode Tools last release">"Install"

Step 2: Install MacPorts

MacPorts is an open source installer for lots of open source tools ported to Mac OS X. aMule needs a few of these tools to compile properly. Alternatively, you can also use Fink to install these tools or (Fink currently lacks many of the needed tools) you can install them manually .

  1. Download the most recent version of MacPorts
  2. Read MacPorts' documentation to learn how to install applications through MacPorts.
Syntax of most important commands

Packages list can be downloaded/updated through

 $ sudo port selfupdate

You can upgrade all the packages installed with

 $ sudo port upgrade installed

Packages can be installed through

 $ sudo port install package_name

and removed with

 $ sudo port uninstall package_name

Port variants can be invoked with the plus sign:

 $ sudo port install package_name +universal

You can list all available variants with:

 $ sudo port variants package_name
Notes about Universal variant

As stated here, MacPorts has different build_arch settings for universal variant. You can use this variant on Leopard to switch both ppc and i386 version on. Since Snow Leopard doesn't support ppc architecture anymore, the universal variant can be used to switch both i386 and x86_64 version on. Please note that default architecture on Snow Leopard is x86_64 if the CPU supports it, i386 otherwise.

WARNING: binutils fails building universal. So you should set build_arch to i386 (about line 59) into /opt/local/etc/macports/macports.conf to be sure to build every port against i386 architecture (x86_64 is useless since 64-bit Carbon libraries does not exists and wxCocoa is not ready yet).

Step 3: Install libraries and tools

These are the package that provides (with dependancies) all needed libraries and tools to build wxWidgets and aMule with most of feature:

  1. automake
  2. binutils
  3. flex
  4. gettext
  5. libpng
  6. libcryptopp
  7. libiconv
  8. gd2
  9. jpeg
  10. libgeoip
  11. libupnp
  12. pkgconfig

This should be enough:

 $ sudo port install automake binutils flex libpng libcryptopp gd2 libgeoip libupnp

Step 4: Compile wxMac

wxMac is the port of the wxWidgets library for Mac OS X. This library is used to make aMule 'multi-platform'.

Get the source from: http://www.wxwidgets.org/downloads/ (Source Archives: wxMac) and extract the archive on your desktop.
Last stable version is 2.8.11 at now. Type

$ cd

leave a space after the command, than drag and drop the wxMac uncompressed folder into the Terminal window: the complete path of the folder will be printed on screen. For example:

$ cd ~/Desktop/wxMac-2.8.11/

Press enter. The basic command to configure and compile the package is the following:

$ ./configure --disable-shared --enable-unicode --disable-debug --disable-debug_gdb --with-libiconv-prefix=/opt/local && make -j8

Note: The above command doesn't enable debug information. Debug informations allows you to submit a helpful stacktrace if aMule crashes or a sample if it hangs to the aMule developers. If you want to compile a debug version then you can use "--enable-debug --enable-debug_gdb" instead.

Snow Leopard

Building on Snow Leopard is tricky. You must focus on architecture, compiler version, compatibility. This should be enough to have compatibility with i386 Leopard and above:

 CC="gcc-4.2 -arch i386" CXX="g++-4.2 -arch i386" \
 ./configure CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" \
 CXXFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" \
 CPPFLAGS="-arch i386" LDFLAGS="-arch i386" OBJCFLAGS="-arch i386" OBJCXXFLAGS="-arch i386" \
 --disable-shared --enable-unicode --disable-debug --disable-debug_gdb --with-libiconv-prefix=/opt/local

followed by:

 make -j8

Step 5: Compile aMule

Download aMule source and extract archive into the same place of wxMac (i.e. your desktop if you are following out suggestion). Open a Terminal and type:

 $ cd

then leave a space and drag and drop aMule uncompressed folder whose path will be printed on screen, for example:

 $ cd ~/Desktop/aMule-2.2.

Press Enter. Now it's possible to configure the sources: there are several options that can be used to activate or deactivate feature during compiling. This is only an example, that provide a full feature aMule build:

 $ ./configure --with-wx-config=../wxMac-2.8.10/wx-config  --enable-optimize --with-crypto-prefix=/opt/local \
 --with-gdlib-config=/opt/local/bin/gdlib-config  --with-libiconv-prefix=/opt/local --enable-cas --enable-webserver \
 --enable-amulecmd --enable-amule-gui --enable-wxcas --enable-alc --enable-alcc --enable-amule-daemon --enable-geoip \
 --with-geoip-lib=/opt/local/lib --with-geoip-headers=/opt/local/include --enable-geoip-static --enable-debug

Take a look to the configure page for a complete list of options. You should pay attention to these elements:

  1. The given example enables debug informations. To disable them exchange the option --enable-debug with --disable-debug --enable-optimize.
  2. The option --with-wx-config must point to the correct relative path of the compiled wxMac. The example assumes that aMule and wxMac folders are in the same directory (i.e. your desktop). You should also correct the wxMac folder's name according to its version (in the example is 2.8.10).
  3. The option --with-crypto-prefix should point to /usr/local/cryptopp if you compiled Crypto++ starting from its source, out of MacPorts.
  4. IMPORTANT! It seems that Mac OS version of ld tool is not able to make static library. So if you plan to run/install your compiled aMule on other Mac which doesn't have MacPorts installed you MUST remove the --enable-geoip-static option to avoid a crash when the program starts.

Now it's time to make you packages with:

 $ make -j8

and

 ./src/utils/scripts/mac_packager

You should find the aMule package in the same source folder.