Difference between revisions of "HowTo compile on Mac"

From AMule Project FAQ
Jump to: navigation, search
m (Compile wxMac: Updated wxMac)
m (Page update...)
Line 8: Line 8:
 
How to get and install [[aMule]] on [http://www.apple.com/macosx/ Apple Mac OS X].
 
How to get and install [[aMule]] on [http://www.apple.com/macosx/ Apple Mac OS X].
  
# You can simply download the finished application ('binary release') or
+
# You can simply download the finished application ('binary release');
# You compile it from a [[aMule SVN|SVN source snapshot]].
+
# 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 ==
Line 26: Line 26:
 
Compiling from source allows most current bug reports, because you can compile and test the [[aMule CVS|CVS 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://dl.amule.org aMule source].
+
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].
  
 
=== Get the sources and development tools ===
 
=== Get the sources and development tools ===
==== [http://developer.apple.com/tools/xcode Xcode] ====
+
==== 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.  
 
[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 will need at least version 2.1 of Xcode, a more recent version is preferable though. [http://developer.apple.com/tools/xcode Xcode] is included on the OS X 10.4 DVD, but early versions of 10.4 were shipped with Xcode 2.0, so you will need to check that the version on your DVD is at least 2.1.
+
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.
 
+
Alternatively, 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.
+
  
 
# 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]====
+
==== 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, you can also use [http://www.finkproject.org/ Fink] to install these tools or 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://www.finkproject.org/ 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 command =====
 +
Packages list can be downloaded/updated through
 +
 
 +
  $ sudo port selfupdate
 +
 
 +
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
 +
 
 +
==== 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
 
# flex
 
# flex
# gettext (only required if you want to use a language other than English in aMule)
+
# gettext
 
# libpng
 
# libpng
 
# libcryptopp
 
# libcryptopp
Line 58: Line 76:
 
# pkgconfig
 
# pkgconfig
  
====[http://www.cryptopp.com/ Crypto++]====
+
You can copy and paste this line:
'With the recent SVN builds, you will need the crypto++ library to compile with encryption. If not, you will get an error similar to the following,
+
checking for crypto++ version >= 5.1... configure: error:
+
        Could not find cryptopp header file "cryptlib.h".
+
        Please check if the path "/usr" is valid.
+
  
<b>MacPorts now includes Crypto v5.5.2. To install it issue the following command:</b>
+
  $ sudo port install automake flex gettext libpng libcryptopp libiconv gd2 jpeg kibgeoip libupnp pkgconfig
sudo port install libcryptopp
+
  
==== [[wxWidgets|wxMac]] ====
+
==== 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'.
 
[[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)
+
Get the source from: http://www.wxwidgets.org/downloads/ (Source Archives: wxMac) and extract the archive on your desktop.
# Extract the archive (just double-click it)
+
Now open a Terminal and type
 
+
==== [http://www.amule.org aMule itself] ====
+
# Get latest daily [[aMule CVS|CVS source snapshot]]: [http://www.hirnriss.net/?area=cvs aMule CVS]
+
# Extract the archive (just double-click it)
+
  
=== Compile the sources ===
+
$ cd
Put the ''amule'' folder, the ''wxMac'' folder and the "crypto552" 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 [[WxWidgets|wxMac]]).
+
  
==== Compile gdlib ====
+
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:
This step is only needed once, even if you later download and compile a newer version of the [[aMule CVS]] source. Assuming you have unzipped it on your desktop, do the following:
+
  
bash: cd ~/Desktop/gd-2.0.35/
+
  $ cd /Users/mirko/Desktop/wxMac-2.8.10/
bash: sudo ./configure
+
bash: sudo make install
+
  
Libraries have been installed in: /usr/local/lib
+
Press enter.
 +
Now configure and compile the package with the command:
  
==== Compile Crypto++ ====
+
  $ ./configure --disable-shared --enable-unicode --disable-debug --disable-debug_gdb --with-libiconv-prefix=/opt/local && make -j8
This step is only needed once, even if you later download and compile a newer version of the [[aMule CVS]] source. Assuming you have unzipped it on your desktop, do the following:
+
  
bash: cd ~/Desktop/cryptopp552/
+
'''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: make
+
bash: sudo make install PREFIX=/usr/local/cryptopp
+
  
==== Compile [[WxWidgets|wxMac]] ====
+
==== Step 5: Compile [[aMule]] ====
This step is only needed once, even if you later download and compile a newer version of the [[aMule CVS]] source.  
+
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:
  
The following assumes that you have placed the above packages on your Desktop.<br>
+
  $ cd
''cd'' into the ''wxMac'' folder, ''configure'' and ''make'':
+
  
bash: cd ~/Desktop/wxMac-2.8.10/build
+
then leave a space and drag and drop aMule uncompressed folder whose path will be printed on screen, for example:
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.
+
  $ cd /Users/mirko/Desktop/aMule-2.2.4
  
'''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 architecture only.
+
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:''' The above make command may take up to 50 minutes on a 1.33 GHz G4 processor, depending on the parameters you chose. A faster CPU will take shorter time.
+
  $ ./configure --disable-systray --disable-gtk --enable-embedded_crypto --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 --enable-debug_gdb
  
'''Note:''' The above make command if given with the option -j 8 (make -j 8) will take 5 minutes on an 2,4Ghz Intel iMac
+
You should pay attention to these elements:
  
==== Compile [[aMule]] ====
+
# The given example enables debug informations. To disable them change the options ''--enable-debug --enable-debug_gdb'' with ''--disable-debug --disable-debug_gdb --enable-optimize''.
Now ''cd'' into the ''amule'' folder, ''configure'' and ''make'':
+
# 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:''' You can copy and paste the 4 lines for ''./configure'' in one go.
+
Now it's time to make you packages with:
  
'''Note:''' This takes about 30 minutes on a 1.33 GHz G4.
+
  $ make -j8
  
bash: cd ~/Desktop/amule-cvs
+
and
bash: ./configure --with-wx-config=../wxMac-2.8.10/build/wx-config    \
+
            --enable-cas --enable-webserver --enable-amulecmd    \
+
            --enable-debug --disable-optimize --with-crypto-prefix=/usr/local/cryptopp
+
  
bash: make
+
  ./src/utils/scripts/mac_packager
bash: ./src/utils/scripts/mac_packager
+
  
'''Note:''' If you installed cryptopp with MacPorts use the last option "--with-crypto-prefix=/opt/local" because it has been installed there by default of MacPorts.
+
You should find the aMule package in the same source folder.
  
'''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.
+
=== APPENDIX: Universal Binary ===
  
'''Note:''' In order to compile aMule as a Universal Binary (see above) you will need to add the following parameters to the configure statement:
+
If no specific options are added, the system compile the packages for the native architecture (i.e. i386 if you are using a Mac Intel or ppc for PowerPcs).
            --disable-dependency-tracking \
+
If you plan to distribute your package or to use it on different platform you probably want to make a [http://en.wikipedia.org/wiki/Universal_binary universal binary].
            CFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk" \
+
            CXXFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
+
  
'''Note:''' Under Mac OS X 10.5 (Leopard) or higher version, you should change the parameters like this:
+
To get a UB package you should  
            --disable-dependency-tracking \
+
            CFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk" \
+
            CXXFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk"
+
  
==== Running [[aMule]] ====
+
# Install all the libraries and tools (Step 3) through MacPorts invoking the ''+universal'' variant.
Once the mac_packager script has finished, you can move the aMule application from the amule-cvs folder to anywhere on your hard drive.
+
# Attache the option "--enable-universal_binary" to the ''configure'' command of wxMac.
 +
# Add the following options to the aMule ''config'', if you are using Leopard:
 +
  --disable-dependency-tracking \
 +
  CFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk" \
 +
  CXXFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk"

Revision as of 00:02, 11 April 2009

English | Deutsch | Español | Français

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.

  1. Latest official binary release: aMule-2.1.3-Mac
  2. Check the Mac forum for a more 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 CVS 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 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 command

Packages list can be downloaded/updated through

 $ sudo port selfupdate

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

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. flex
  3. gettext
  4. libpng
  5. libcryptopp
  6. libiconv
  7. gd2
  8. jpeg
  9. libgeoip
  10. libupnp
  11. pkgconfig

You can copy and paste this line:

 $ sudo port install automake flex gettext libpng libcryptopp libiconv gd2 jpeg kibgeoip libupnp pkgconfig

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. Now open a Terminal and 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 /Users/mirko/Desktop/wxMac-2.8.10/

Press enter. Now configure and compile the package with the command:

 $ ./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.

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 /Users/mirko/Desktop/aMule-2.2.4

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 --disable-systray --disable-gtk --enable-embedded_crypto --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 --enable-debug_gdb

You should pay attention to these elements:

  1. The given example enables debug informations. To disable them change the options --enable-debug --enable-debug_gdb with --disable-debug --disable-debug_gdb --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.

APPENDIX: Universal Binary

If no specific options are added, the system compile the packages for the native architecture (i.e. i386 if you are using a Mac Intel or ppc for PowerPcs). If you plan to distribute your package or to use it on different platform you probably want to make a universal binary.

To get a UB package you should

  1. Install all the libraries and tools (Step 3) through MacPorts invoking the +universal variant.
  2. Attache the option "--enable-universal_binary" to the configure command of wxMac.
  3. Add the following options to the aMule config, if you are using Leopard:
 --disable-dependency-tracking \
 CFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk" \
 CXXFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk"