Difference between revisions of "HowTo compile on Mac"

From AMule Project FAQ
Jump to: navigation, search
(Download XCode)
(Binary releases: pipe correct typography)
 
(96 intermediate revisions by 33 users not shown)
Line 1: Line 1:
How to get and install [[aMule]] on [http://www.apple.com/macosx/ Apple Mac OS X].
+
<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>
  
# You can simply download the finished application ('binary release') or
+
How to get and install [[aMule]] on [http://www.apple.com/macosx/ Apple Mac OS X].
# You compile it from a [[aMule CVS|CVS source snapshot]].
+
  
''The preceding version of this page covering [[aMule]] 2.0.0rc8 and earlier is archived [[HowTo_compile_on_Mac_v200rc8|here]].''
+
# 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].
  
 
== Binary releases ==
 
== 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.  
 
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.  
  
# Latest official binary release: [http://www.amule.org/files/files.php?cat=30 aMule-2.1.3-Mac]
+
Check the Mac forum for the most recent user posted binary: [http://forum.amule.org/index.php?board=49.0 aMule forum]
# Periodically compiled binary from cvs: [http://forum.amule.org/index.php?topic=5051.0 amule forum]
+
  
 
Now, to install the downloaded binary, just drag the aMule application to a folder of your choice (e.g., ''/Applications'').
 
Now, to install the downloaded binary, just drag the aMule application to a folder of your choice (e.g., ''/Applications'').
Line 17: Line 21:
 
To start aMule, double-click the application icon.
 
To start aMule, double-click the application icon.
  
'''Note:''' You might want to take a look at the [[Mac specific usage]] article.
+
'''Note:''' You might want to take a look at the [[Mac specific usage|Mac-specific usage]] article.
  
 
== Compiling from source ==
 
== 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.
  
Compiling from source allows most current bug reports, because you can compile and test the [[aMule CVS|CVS snapshot]] of the very day.
+
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].
 
+
To compile [[aMule]] from source you need some development tools, the [[wxWidgets]] library and the [http://dl.amule.org aMule source].
+
  
 
=== Get the sources and development tools ===
 
=== 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] ====
+
 
+
 
[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.  
 
[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.  
  
You may have [http://developer.apple.com/tools/xcode Xcode] on CD/DVD (it is on the [http://www.apple.com/macosx/ OS X] 10.4 DVD), but we strongly recommend that you download a more recent version from [http://www.apple.com Apple]. You will need to sign up for a free-of-charge developer account first, though.
+
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
+
# Get Xcode from http://developer.apple.com/tools/download
 
# "Member Site"->"Log In"->"Download Software"->"Developer Tools"->"Download Xcode Tools last release">"Install"
 
# "Member Site"->"Log In"->"Download Software"->"Developer Tools"->"Download Xcode Tools last release">"Install"
  
==== [http://www.macports.org MacPorts] (formerly known as DarwinPorts) ====
+
==== 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 .
[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, you can also use [http://fink.sourceforge.net Fink] to install these tools or you can install them manually.
+
  
 
# Download the most recent version of [http://www.macports.org MacPorts]
 
# Download the most recent version of [http://www.macports.org MacPorts]
# Read [http://trac.macosforge.org/projects/macports/wiki MacPorts' documentation] to learn how to install applications through [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:
  
The tools that you will need to install are:
 
 
# automake
 
# automake
 +
# binutils
 
# flex
 
# flex
# gettext (only required if you want to use a language other than English in aMule)
+
# gettext
 
# libpng
 
# libpng
 +
# libcryptopp
 +
# libiconv
 +
# gd2
 +
# jpeg
 +
# libgeoip
 +
# libupnp
 +
# pkgconfig
  
==== [[wxWidgets|wxMac]] ====
+
This should be enough:
  
[[wxWidgets|wxMac]] is the port of the [[wxWidgets]] library for [http://macos.apple.com Mac OS X]. This library is used to make [[aMule]] 'multi-platform'.
+
  $ sudo port install automake binutils flex libpng libcryptopp gd2 libgeoip libupnp
  
# Get the source from: http://www.wxwidgets.org/downloads/ (Source Archives: wxMac)
+
==== Step 4: Compile [[wxWidgets|wxMac]] ====
# Extract the archive (just double-click it)
+
[[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'.
  
Or get the current [[wx-cvs|CVS snapshot]]. Warning: the [[wxMac]] [[wx-cvs|CVS]] is frequently in a bad condition (e.g., currently you need to switch the vswprintf implementation that wx uses, see [http://forum.amule.org/index.php?topic=9915.msg58058#msg58058 here] for more details).
+
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
  
  bash: cd ~/Desktop
+
  $ cd
bash: cvs -d :pserver:anoncvs@cvs.wxwidgets.org:/pack/cvsroots/wxwidgets login
+
Note: password is 'anoncvs'
+
bash: cvs -d :pserver:anoncvs@cvs.wxwidgets.org:/pack/cvsroots/wxwidgets checkout wxMac
+
  
==== [http://www.amule.org aMule itself] ====
+
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:
  
# Get latest daily [[aMule CVS|CVS source snapshot]]: [http://www.hirnriss.net/?area=cvs aMule CVS]
+
$ cd ~/Desktop/wxMac-2.8.11/
# Extract the archive (just double-click it)
+
  
=== Compile the sources ===
+
Press enter.
 +
The basic command to configure and compile the package is the following:
  
Put the ''amule'' folder and the ''wxMac'' folder in the same place, e.g. on the desktop (if using another location, ensure that there are no spaces in the path as this can lead to file not found errors with [[wxMac]]).
+
$ ./configure --disable-shared --enable-unicode --disable-debug --disable-debug_gdb --with-libiconv-prefix=/opt/local && make -j8
  
'''Important:''' If you use [http://developer.apple.com/tools/xcode Xcode] 2.0 then the [http://gcc.gnu.org gcc] 4.0 that comes with it is somewhat broken and can't compile aMule. There are two solutions: upgrade to [http://developer.apple.com/tools/xcode Xcode] 2.1 by [[#Xcode|downloading]] it from [http://www.apple.com Apple] for free, or switch your system to use [http://gcc.gnu.org gcc] 3.3. If your prefer to switch to [http://gcc.gnu.org gcc] 3.3, first check the version of your current default [http://gcc.gnu.org gcc] with ''gcc --version'' and then switch to version 3.3 if required:
+
'''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.
  
bash: gcc --version
+
===== Snow Leopard =====
bash: sudo gcc_select 3.3
+
  
==== Compile [[wxMac]] ====
+
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:
  
This step is only needed once, even if you later download and compile a newer version of the [[aMule CVS]] source.  
+
  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
  
The following assumes that you have placed the above packages on your Desktop.<br>
+
followed by:
''cd'' into the ''wxMac'' folder, ''configure'' and ''make'':
+
  
bash: cd ~/Desktop/wxMac-2.8.4/build
+
  make -j8
bash: ../configure --disable-shared --enable-unicode --enable-debug --enable-debug_gdb
+
bash: make
+
  
'''Note:''' The second command above makes sure that wxMac is compiled with debug information. This information allows you to submit a helpful stacktrace if [[aMule]] crashes or a sample if it hangs to the [[aMule devs|aMule developers]]. If you do not want to compile a debug version then you can use "--disable-debug --disable-debug_gdb" instead.
+
==== 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:
  
'''Note:''' If you want to compile a [http://en.wikipedia.org/wiki/Universal_binary Universal Binary] of aMule (i.e., a version of aMule that runs on both PowerPC based and Intel based Macs) then you can add the "--enable-universal_binary" parameter at the end of the second command. If you don't include this parameter wxMac and aMule will be compiled for your native architechture only.
+
  $ cd
  
'''Note:''' The above make command may take up to 45 minutes, depending on the speed of your CPU(s) and the parameters you chose.
+
then leave a space and drag and drop aMule uncompressed folder whose path will be printed on screen, for example:
  
==== Compile [[aMule]] ====
+
  $ cd ~/Desktop/aMule-2.2.
  
Now ''cd'' into the ''amule'' folder, ''configure'' and ''make'':
+
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:
  
'''Note:''' You can copy and paste the 4 lines for ''./configure'' in one go.
+
  $ ./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
  
bash: cd ~/Desktop/amule-cvs
+
Take a look to the [[configure]] page for a complete list of options.
bash: ./configure --disable-systray --disable-gtk --enable-embedded_crypto    \
+
You should pay attention to these elements:
            --with-wx-config=../wxMac-2.8.4/build/wx-config    \
+
            --enable-cas --enable-webserver --enable-amulecmd    \
+
            --enable-debug --disable-optimize
+
  
bash: make
+
# The given example enables debug informations. To disable them exchange the option ''--enable-debug'' with ''--disable-debug --enable-optimize''.
bash: ./src/utils/scripts/mac_packager
+
# 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.
  
'''Note:''' If you don't want to compile aMule with debug information (see above) you can use "--disable-debug --enable-optimize" in the configure statement.
+
Now it's time to make you packages with:
  
'''Note:''' In order to compile aMule as a Universal Binary (see above) you will need to add the following parameters to the configure statement:
+
  $ make -j8
            --disable-dependency-tracking \
+
            CFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk" \
+
            CXXFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
+
  
==== Running [[aMule]] ====
+
and
Once the mac_packager script has finished, you can move the aMule application from the amule-cvs folder to anywhere on your hard drive.
+
  
'''Important:''' Because aMule CVS versions contain experimental code they need to be started via the Terminal to prevent users from accidentally running a potentially unstable application:
+
  ./src/utils/scripts/mac_packager
# Drag the aMule application onto a Terminal window. Terminal will insert the path to the application onto the command line. It will also add a space after the path.
+
# Now delete the space at the end of the path and paste "/Contents/MacOS/amule --even-if-lfroen-surreptitiously-removes-it-this-will-stay". Then hit return to start aMule.
+
  
If starting aMule this way annoys you, you can simply comment out the check for the above switch in amule.cpp before you compile aMule. If you do this, however, we strongly urge you to not pass along the resulting binary to anybody else.
+
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.