Difference between revisions of "Hugin Compiling OSX"

From PanoTools.org Wiki
Jump to navigation Jump to search
m
(→‎Porticus: Porticus is outdated)
 
(86 intermediate revisions by 12 users not shown)
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
OSX Users: This tutorial describes how to build hugin on OSX via [http://www.macports.org/ MacPorts]. [http://www.finkproject.org/ Fink] users should also be able to use it even though the commands and directory structure is different from MacPorts.
+
This tutorial describes how to build Hugin on OSX via [http://www.macports.org/ MacPorts]. [http://www.finkproject.org/ Fink] users should also be able to use it even though the commands and directory structure is different from MacPorts.
 
*Directory structure where everything is built and installed:
 
*Directory structure where everything is built and installed:
 
**MacPorts: /opt/local
 
**MacPorts: /opt/local
Line 7: Line 7:
 
**MacPorts: sudo port [install][update][uninstall][search]  <package1> <package2> <packagex>
 
**MacPorts: sudo port [install][update][uninstall][search]  <package1> <package2> <packagex>
 
**Fink: sudo apt-get [install][update][uninstall][search] <package1> <package2> <packagex>
 
**Fink: sudo apt-get [install][update][uninstall][search] <package1> <package2> <packagex>
'''Note:''' These are only the bare command options for both port and apt-get. See their respective websites [http://www.macports.org/ Macports.org] and [http://www.finkproject.org/ Finkproject.org] for documentation.
+
'''Note:''' These are only the most used command options for both port and apt-get. See their respective websites [http://www.macports.org/ Macports.org] and [http://www.finkproject.org/ Finkproject.org] for documentation.
  
 +
'''Note:''' This Howto does not describe how to build a portable universal application. You can use the [[Build_a_MacOSX_Universal_Hugin_bundle_with_Xcode | Build a MacOSX Universal Hugin bundle with Xcode]]
  
 +
'''Note:''' In case you encounter problems, report them on [http://groups.google.com/group/hugin-ptx the Hugin mailing list].
  
 
==Building environment==
 
==Building environment==
 
===Download and install XCode===
 
===Download and install XCode===
[http://developer.apple.com/tools/download/ Download] and install the XCode Tools version for your MacOSX version: Xcode 2.4.x for MacOSX 10.4.x or below and Xcode 3.x for 10.5.x (Leopard). You will not use the Xcode development environment itself, but the MacOSX system comes without the GNU compiler, builder, linker and so on. For those who are brave enough to ponder into the dark corners of the installed base: You will find a 4.x version and a 3.3 version of the GNU compiler and it's "companions". Do not remove either of them. The 4.x version is used for i386/X_64 builds and the 3.3 version is used for the "older"PPC builds.
+
[http://developer.apple.com/tools/download/ Download] and install the XCode Tools version for your MacOSX version: Xcode 2.5.x for MacOSX 10.4.x or below, Xcode 3.1.x for 10.5.x (Leopard) and Xcode 3.2.x for 10.6.x (Snow Leopard). You will not use the Xcode development environment itself, but the MacOSX system comes without the GNU compiler, builder, linker and so on.
===Install CMake===
+
 
Get and install the build system CMake, version 2.4.7 or later, from [http://www.cmake.org/HTML/Download.html CMake].
 
===Install Macports===
 
If you don't have it already, install MacPorts, which provides the <tt>port</tt> command, from [http://www.macports.org MacPorts], giving you compilable package access to thousands of pieces of open source software.  If you already have macports (formerly darwinports) installed, update it:  <blockquote><pre>$ sudo port selfupdate</pre>Make sure you have synced the latest port files:<pre>$ sudo port -d sync</pre></blockquote>
 
 
===Fink commander===
 
===Fink commander===
''Note: This tutorial describes how to build Hugin with MacPorts. This should more or less be the same for Fink. All references to <tt>/opt/local</tt> that are mentioned here for MacPorts shoudl be changed with <tt>/sw</tt> for Fink.''
+
''Note: This tutorial describes how to build Hugin with MacPorts. This should more or less be the same for Fink. All references to <tt>/opt/local</tt> that are mentioned here for MacPorts should be changed with <tt>/sw</tt> for Fink.''
 
You may find [http://finkcommander.sourceforge.net/ Fink Commander] helpful. Unfortunately it [http://sourceforge.net/forum/forum.php?forum_id=684829 seems] unsupported / unmaintained. The Fink [http://www.finkproject.org/faq/index.php?phpLang=en FAQ] may help. Can somebody please describe here how to install Fink and Fink Commander?
 
You may find [http://finkcommander.sourceforge.net/ Fink Commander] helpful. Unfortunately it [http://sourceforge.net/forum/forum.php?forum_id=684829 seems] unsupported / unmaintained. The Fink [http://www.finkproject.org/faq/index.php?phpLang=en FAQ] may help. Can somebody please describe here how to install Fink and Fink Commander?
===Porticus===
+
 
You may find [http://porticus.alittledrop.com/ Porticus] helpful with [http://www.macports.org/ MacPorts]
+
===Install Macports===
 +
If you don't have it already, install MacPorts, which provides the <tt>port</tt> command, from [http://www.macports.org MacPorts], giving you compilable package access to thousands of pieces of open source software.  If you already have macports (formerly darwinports) installed, update it to at least version 1.7.0:
 +
<blockquote>
 +
<pre>
 +
sudo port selfupdate
 +
</pre>
 +
Make sure you have synced the latest port files:
 +
<pre>
 +
sudo port -d sync
 +
</pre>
 +
</blockquote>
 +
 
 +
''Snow Leopard remarks:''
 +
- edit your "/opt/local/etc/macports/macports.conf" and set "universal_archs"  to "x86_64 i386" (off course without the double quotes).
 +
 
 +
===MacPortsGUI===
 +
The Cocoa GUI ''Porticus'' for the MacPorts package manager has been discontinued. Now ''Pallet'' is the official MacPorts GUI app for Mac OS X. See [https://trac.macports.org/wiki/MacPortsGUI MacPortsGUI] for requirements and download instructions.
 +
 
 +
===Install CMake===
 +
Install cmake from MacPorts:
 +
<pre>
 +
sudo port install cmake
 +
</pre>
 +
 
 +
Alternatively, you can download a prepackaged installer from [http://www.cmake.org/HTML/Download.html CMake].
 +
 
 +
===Mercurial (HG)===
 +
You need to get and install Mercurial from MacPorts as the Hugin development trunk is in a Mercurial repository.<br>
 +
''Note: Hugin used to be in an SVN repository but in mid May 2010 it was moved to Mercurial''
 +
 
 
===Subversion (SVN)===
 
===Subversion (SVN)===
Get and install Subversion
+
You need to get and install Subversion from MacPorts. If you fancy a nice GUI you can download the Open-Source [http://www.lachoseinteractive.net/en/community/subversion/svnx/features/?sid=b42441f308810ad0d36b779f90319391 SVNX]. You still need svn installed as it is only a graphical shell and I won't explain SVNX here (I only used it once, I still like the terminal).
 +
''Note: Subversion comes preinstalled in Leopard and Snow Leopard.  In Leopard, it is quite old, so you'll want to compile the newer version from MacPorts.  In Snow Leopard, the pre-installed version is the quite current 1.6.5, and should be fine.''
 +
 
 +
==Install necessary libraries==
 +
Use port to install the necessary libraries and commands for Hugin:
 +
<blockquote>
 +
<pre>
 +
sudo port install boost tiff jpeg libpng wxWidgets-2.8 subversion openexr exiv2 glew mercurial tclap
 +
</pre>
 +
</blockquote>
 +
 
 +
Wait as all of these source packages (and its dependencies) are downloaded and compiled, and installed into /opt/local.  Go get a frappe, walk the dog, and total the first 1000 prime numbers in binary.
  
  
  
==Install necessary libraries==
 
Use port to install the necessary libraries and commands for Hugin:<blockquote><pre>$ sudo port install boost tiff jpeg libpng wxWidgets subversion openexr exiv2</pre></blockquote>Wait as all of these source packages (and it's dependencies) are downloaded and compiled, and installed into /opt/local.  Go get a frappe, walk the dog, and total the first 1000 prime numbers in binary.  Rinse, lather, repeat as necessary. 
 
===Build libpano13===
 
Download and build libpano13 from [http://sourceforge.net/project/showfiles.php?group_id=96188&package_id=237430 SourceForge]. Alternatively, use SVN to checkout a fresh copy of libpano13 ([http://sourceforge.net/svn/?group_id=96188 Instructions]). 
 
====Build SVN libpano13====
 
To build and install the svn version '''(preferred)''' you first need to edit the bootstrap file and change <tt>LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}</tt> to <tt>LIBTOOLIZE=${LIBTOOLIZE:-glibtoolize}</tt>.
 
<blockquote><pre>$ ./bootstrap --with-jpeg=/opt/local/ --with-tiff=/opt/local/ --with-png=/opt/local/
 
$ ./configure
 
$ make
 
$ sudo make install</pre></blockquote>
 
By default it will go into <tt>/usr/local/lib</tt>).
 
===WxWidgets on Tiger (10.4.x)===
 
Fix a problem on Tiger (10.4.x): Tiger comes with WxWindows version 2.5. The Hugin cmake will search OS paths first and will find it's own version 2.5 instead of your freshly compiled 2.8. You need to get Tiger's 2.5 version out of the way as you won't be able to build hugin succesfully.
 
<blockquote><pre>$ sudo mv /usr/bin/wx-config /usr/bin/wx-config-2.5
 
$ sudo mv /usr/include/wx-2.5 /usr/include/wx-2.5-macTiger</pre></blockquote>
 
===Fix libboost===
 
Fix a (hopefully temporary) issue with Macport's threaded Boost library not providing generic link names for <tt>libboost_thread</tt>:
 
<blockquote><pre>$ cd /opt/local/lib
 
$ sudo ln -s libboost_thread-mt.a libboost_thread.a
 
$ sudo ln -s libboost_thread-mt.dylib libboost_thread.dylib
 
$ cd -
 
</pre></blockquote>
 
  
 +
===libpano13===
 +
You can either use the latest libpano13 version from MacPorts, which is currently 2.9.18, or build the latest version from Mercurial.
 +
 +
From MacPorts:
 +
<pre>
 +
sudo port install libpano13
 +
</pre>
 +
 +
====Build libpano13 from Mercurial ====
 +
You first need to download the source code:
 +
<pre>
 +
hg clone http://hg.code.sf.net/p/panotools/libpano13/ panotools
 +
</pre>
 +
 +
To build and install the SVN version you first need to edit the bootstrap file and change:
 +
 +
<tt>LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}</tt>
 +
 +
to
 +
 +
<tt>LIBTOOLIZE=${LIBTOOLIZE:-glibtoolize}</tt>
 +
 +
<pre>
 +
cd DirectoryWherePanotoolsIs/panotools/trunk/libpano
 +
nano bootstrap (or do it with your preferred editor)
 +
</pre>
 +
 +
Alternatively, this command-line should work just as well (untested):
 +
 +
  export LIBTOOLIZE=glibtoolize
 +
 +
Now you can build the library.
 +
 +
On Tiger and Leopard do:
 +
<pre>
 +
export CFLAGS="-I/opt/local/include -L/opt/local/lib"
 +
export CXXFLAGS="-I/opt/local/include -L/opt/local/lib"
 +
./bootstrap --without-java
 +
make
 +
sudo make install
 +
</pre>
 +
 +
On Snow Leopard do:
 +
<pre>
 +
export CFLAGS="-arch i386 -I/opt/local/include -L/opt/local/lib"
 +
export CXXFLAGS="-arch i386 -I/opt/local/include -L/opt/local/lib"
 +
./bootstrap --without-java
 +
</pre>
 +
Open the "libtool" file with an editor and change all occurrences of "-dynamiclib"  to "-dynamiclib -arch i386" (2 occurrences).<br>
 +
''Note:'' If you want to build universal on Snow Leopard for both i386 and x86_64, change the "-dynamiclib"  to "-dynamiclib -arch i386 -arch x86_64" (2 occurrences).
 +
<pre>
 +
make
 +
sudo make install
 +
</pre>
 +
 +
By default the library is installed into <tt>/usr/local/lib</tt>.
  
 +
====Build libpano13 from a release version tar.gz====
 +
To build libpano from a .tar.gz file, CD into the source directory of the unpacked .tar.gz. This will normally be "libpano13-2.9.xy" where "xy" is the version number. Note that the current Hugin version needs 2.9.18 or newer.
 +
Then do the following on Tiger and Leopard:
 +
<pre>
 +
export CFLAGS="-I/opt/local/include -L/opt/local/lib"
 +
export CXXFLAGS="-I/opt/local/include -L/opt/local/lib"
 +
./configure --without-java
 +
make
 +
sudo make install
 +
</pre>
 +
On Snow Leopard do the following:
 +
<pre>
 +
export CFLAGS="-arch i386 -I/opt/local/include -L/opt/local/lib"
 +
export CXXFLAGS="-arch i386 -I/opt/local/include -L/opt/local/lib"
 +
./configure --without-java
 +
</pre>
 +
Open the "libtool" file with an editor and change all occurrences of "-dynamiclib"  to "-dynamiclib -arch i386" (4 occurrences).<br>
 +
''Note:'' If you want to build universal on Snow Leopard for both i386 and x86_64, change the "-dynamiclib"  to "-dynamiclib -arch i386 -arch x86_64" (4 occurrences).
 +
<pre>
 +
make
 +
sudo make install
 +
</pre>
  
==Build Hugin==
+
By default the library is installed into <tt>/usr/local/lib</tt>.
===Get Hugin from SVN===
 
Check out the hugin sources from SVN, like:<blockquote><pre>$ svn co https://hugin.svn.sourceforge.net/svnroot/hugin/hugin/trunk hugin</pre></blockquote>
 
===Create hugin build directory===
 
Create another directory alongside the newly created <tt>hugin/</tt> for the build files (a cool feature of CMake: it doesn't need to pollute your source directory with build files!):<blockquote><pre>$ mkdir hugin_build; cd hugin_build</pre></blockquote>''Note: You can give this directory any name you want, but hugin_build is chosen for it's clarity.''
 
===Configure build===
 
Configure hugin using cmake from inside the build directory you created:<blockquote><pre>$ cmake ../hugin</pre></blockquote>
 
===Compile Hugin===
 
Compile Hugin and friends:<blockquote><pre>$ make
 
$ sudo make install</pre></blockquote>Watch the pretty colors go by.  Give the dog another quick spin around the block; you're finished.  Look for the new bundle <tt>Hugin.app</tt> in <tt>usr/local/Applications/</tt> or in <tt>usr/local/bin/</tt>.  Copy or link it to <tt>/Applications</tt>, or your preferred location, and commence testing.
 
  
'''Note: This is a new build configuration and you may encounter problems.  Report them on [http://groups.google.com/group/hugin-ptx the Hugin mailing list].'''
+
===WxWidgets===
 +
Hugin requires wxWidgets, which is called wxMac for MacOSX, the GUI toolkit currently employed by Hugin, to be at version >= 2.8.7. The current version of wxWidgets at MacPorts is 2.8.12.
 +
Note: Hugin can recently be configured to use WxWidgets 2.9. Note though that this is a development version and Mac OS X is always running a few steps behind.
  
 +
====Tiger (10.4.x) ====
 +
Fix a problem on Tiger (10.4.x): Tiger comes with WxWindows version 2.5. The Hugin cmake will search OS paths first and will find Tiger's own version 2.5 instead of your freshly compiled 2.8. You need to get Tiger's 2.5 version out of the way as you won't be able to build Hugin succesfully as long as it is in place.
 +
<blockquote>
 +
<pre>
 +
sudo mv /usr/bin/wx-config /usr/bin/wx-config-2.5
 +
sudo mv /usr/include/wx-2.5 /usr/include/wx-2.5-macTiger
 +
</pre>
 +
</blockquote>
  
 +
====Leopard (10.5.x)====
 +
Fix a problem on Leopard (10.5.x): Leopard comes with WxWindows version 2.8.4. The Hugin cmake will search OS paths first and will find Leopard's own version 2.8.4 instead of your freshly compiled 2.8.8 or above. You need to get Tiger's 2.8.4 version out of the way. Hugin will build succesfully with 2.8.4 and will run. However version 2.8.4 still contains some bugs that will cause "bleeding through" in the graphical CP windows. This means that when things change in wxwidgets objects, sometimes (most of the times) the CP window displays through your current GUI screen.
 +
<blockquote>
 +
<pre>
 +
sudo mv /usr/bin/wx-config /usr/bin/wx-config-2.8.4
 +
sudo mv /usr/include/wx-2.8 /usr/include/wx-2.8-macLeopard
 +
</pre>
 +
</blockquote>
  
== Important Note on the produced Bundle ==
+
====Snow Leopard (10.6.x)====
Since the produced Hugin.app bundle links dynamically to libraries outside of the bundle, it is not yet portable, i.e. cannot be copied or shared unless the other machine has the same collection of libraries available in the same places. This is to facilitate development and testing (re-compile external libraries and test without re-building). Building a fully portable universal binary version at the command line is planned.
+
Snow Leopard comes with WxWindows 2.8.8 so no changes are required. An alternative is to build WxWidgets from MacPorts (currently 2.8.12):
 +
<pre>sudo port install wxWidgets</pre>
  
 +
==Build Hugin==
 +
===Get Hugin from Mercurial===
 +
Check out the hugin sources from the Mercurial repository, like:
 +
<blockquote>
 +
<pre>
 +
hg clone http://hg.code.sf.net/p/hugin/hugin hugin
 +
</pre>
 +
</blockquote>
 +
If you are asked to accept the ssh key from the SourceForge server, do accept it permanently (p). Otherwise the configuring process using cmake will fail.
  
 +
On subsequent updates you simply cd into the hugin directory and issue the following two commands:
 +
<blockquote>
 +
<pre>
 +
hg pull
 +
hg update
 +
</pre>
 +
</blockquote>
  
== Notes on wxWidgets ==
+
===Create hugin build directory===
''Note: For testing purposes you might use wxWidgets 2.6.4, but the newer versions of the 0.7 version no longer fully support 2.6.''
+
Create another directory alongside the newly created <tt>hugin/</tt> for the build files (a cool feature of CMake: it doesn't need to pollute your source directory with build files!):
wxWidgets, the GUI toolkit currently employed by Hugin, is currently at version 2.8.4.  You can use either this version or try the older version 2.6.4.  Switching to the older version 2.6.4 is easy:<blockquote>$ sudo port deactivate wxWidgets; sudo port install wxWidgets26</blockquote> and recompile by typing <tt>cmake ../hugin; make</tt> in your build directory.  Switching back is as easy as:<blockquote>$ sudo port deactivate wxWidgets26; sudo port activate wxWidgets</blockquote>
+
<blockquote>
 +
<pre>
 +
mkdir hugin_build; cd hugin_build
 +
</pre>
 +
</blockquote>
 +
''Note: You can give this directory any name you want, but hugin_build is chosen for its clarity.''
 +
===Configure build===
 +
Before we configure hugin we need to set the build environment:
 +
<blockquote>
 +
<pre>
 +
export CFLAGS="-I/opt/local/include -L/opt/local/lib"
 +
export CXXFLAGS=$CFLAGS
 +
</pre>
 +
</blockquote>
  
[[User:Jdsmith|Jdsmith]] 23:47, 4 August 2007 (CEST)
+
''Snow Leopard:''
 +
If you are on Snow Leopard you need to use the following C/CXX FLAGS:  
 +
<blockquote>
 +
<pre>
 +
export CFLAGS="-arch i386 -I/opt/local/include -L/opt/local/lib"
 +
export CXXFLAGS=$CFLAGS
 +
</pre>
 +
</blockquote>
 +
''Note: On Snow Leopard, gcc builds for 64-bit architecture by default.  However, some libraries that Hugin depends upon are not yet compilable as 64-bit libraries (such as wxWindows-2.8).  Thus, the i386 flag is necessary to force a 32-bit build.''
  
 +
Configure hugin using cmake from inside the build directory you created:
 +
<blockquote>
 +
<pre>
 +
cmake ../hugin
 +
</pre>
 +
</blockquote>
 +
''Note: If you are rebuilding hugin after an svn upgrade or other (system) change, the savest way to proceed is to first remove the "CMakeCache.txt" from your build directory. It contains the build settings for your previous build.''
  
 +
===Compile Hugin===
 +
Compile Hugin and friends:
 +
<blockquote>
 +
<pre>
 +
make
 +
sudo make install
 +
</pre>
 +
</blockquote>
 +
Watch the pretty colors go by.  Give the dog another quick spin around the block; you're finished.  Look for the new bundle <tt>Hugin.app</tt> in <tt>usr/local/Applications/</tt> or in <tt>usr/local/bin/</tt>.  Copy or link it to <tt>/Applications</tt>, or your preferred location, and commence testing.
  
== Building Enblend (using Fink) ==
+
If your build fails on Snow Leopard with this error (might happen only after upgrade from Leopard):
follow these [[Enblend_Compiling_OSX|updated instructions]]
+
<blockquote>
 +
<pre>
 +
Linking CXX executable celeste_standalone
 +
ld: library not found for -lcrt1.10.6.o
 +
</pre>
 +
</blockquote>
 +
try this before <code>make</code>:
 +
<blockquote>
 +
<pre>
 +
export MACOSX_DEPLOYMENT_TARGET=10.5
 +
</pre>
 +
</blockquote>
  
 +
== Important Note on the produced Bundle ==
 +
Since the produced Hugin.app bundle links dynamically to libraries outside of the bundle, it is not yet portable, i.e. cannot be copied or shared unless the other machine has the same collection of libraries available in the same places.  This is to facilitate development and testing (re-compile external libraries and test without re-building).  Building a fully portable universal binary version at the command line is planned.
 +
You can use the [[Build_a_MacOSX_Universal_Hugin_bundle_with_Xcode | Build a MacOSX Universal Hugin bundle with Xcode]] to build a universal portable bundle.
  
 +
== Building Enblend (using Fink or MacPorts) ==
 +
follow these [[Enblend_Compiling_OSX|updated instructions]]
  
== Bulding Autopano-Sift-C ==
+
== Building Autopano-Sift-C ==
 
Follow [[autopano-sift-C_Compiling_OSX|these instructions]]
 
Follow [[autopano-sift-C_Compiling_OSX|these instructions]]
  
[[Category:Software:Hugin]] [[Category:Software:Platform:Mac OS X]]
+
[[Category:Software:Platform:Mac OS X]]
 +
[[Category:Software:Hugin]]
 +
[[Category:Software:Hugin:Compiling]]

Latest revision as of 20:09, 10 April 2016

Introduction

This tutorial describes how to build Hugin on OSX via MacPorts. Fink users should also be able to use it even though the commands and directory structure is different from MacPorts.

  • Directory structure where everything is built and installed:
    • MacPorts: /opt/local
    • Fink: /sw
  • Main commands to install/update/uninstall/deactivate packages:
    • MacPorts: sudo port [install][update][uninstall][search] <package1> <package2> <packagex>
    • Fink: sudo apt-get [install][update][uninstall][search] <package1> <package2> <packagex>

Note: These are only the most used command options for both port and apt-get. See their respective websites Macports.org and Finkproject.org for documentation.

Note: This Howto does not describe how to build a portable universal application. You can use the Build a MacOSX Universal Hugin bundle with Xcode

Note: In case you encounter problems, report them on the Hugin mailing list.

Building environment

Download and install XCode

Download and install the XCode Tools version for your MacOSX version: Xcode 2.5.x for MacOSX 10.4.x or below, Xcode 3.1.x for 10.5.x (Leopard) and Xcode 3.2.x for 10.6.x (Snow Leopard). You will not use the Xcode development environment itself, but the MacOSX system comes without the GNU compiler, builder, linker and so on.

Fink commander

Note: This tutorial describes how to build Hugin with MacPorts. This should more or less be the same for Fink. All references to /opt/local that are mentioned here for MacPorts should be changed with /sw for Fink. You may find Fink Commander helpful. Unfortunately it seems unsupported / unmaintained. The Fink FAQ may help. Can somebody please describe here how to install Fink and Fink Commander?

Install Macports

If you don't have it already, install MacPorts, which provides the port command, from MacPorts, giving you compilable package access to thousands of pieces of open source software. If you already have macports (formerly darwinports) installed, update it to at least version 1.7.0:

sudo port selfupdate

Make sure you have synced the latest port files:

sudo port -d sync

Snow Leopard remarks: - edit your "/opt/local/etc/macports/macports.conf" and set "universal_archs" to "x86_64 i386" (off course without the double quotes).

MacPortsGUI

The Cocoa GUI Porticus for the MacPorts package manager has been discontinued. Now Pallet is the official MacPorts GUI app for Mac OS X. See MacPortsGUI for requirements and download instructions.

Install CMake

Install cmake from MacPorts:

sudo port install cmake

Alternatively, you can download a prepackaged installer from CMake.

Mercurial (HG)

You need to get and install Mercurial from MacPorts as the Hugin development trunk is in a Mercurial repository.
Note: Hugin used to be in an SVN repository but in mid May 2010 it was moved to Mercurial

Subversion (SVN)

You need to get and install Subversion from MacPorts. If you fancy a nice GUI you can download the Open-Source SVNX. You still need svn installed as it is only a graphical shell and I won't explain SVNX here (I only used it once, I still like the terminal). Note: Subversion comes preinstalled in Leopard and Snow Leopard. In Leopard, it is quite old, so you'll want to compile the newer version from MacPorts. In Snow Leopard, the pre-installed version is the quite current 1.6.5, and should be fine.

Install necessary libraries

Use port to install the necessary libraries and commands for Hugin:

sudo port install boost tiff jpeg libpng wxWidgets-2.8 subversion openexr exiv2 glew mercurial tclap

Wait as all of these source packages (and its dependencies) are downloaded and compiled, and installed into /opt/local. Go get a frappe, walk the dog, and total the first 1000 prime numbers in binary.



libpano13

You can either use the latest libpano13 version from MacPorts, which is currently 2.9.18, or build the latest version from Mercurial.

From MacPorts:

sudo port install libpano13

Build libpano13 from Mercurial

You first need to download the source code:

hg clone http://hg.code.sf.net/p/panotools/libpano13/ panotools

To build and install the SVN version you first need to edit the bootstrap file and change:

LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}

to

LIBTOOLIZE=${LIBTOOLIZE:-glibtoolize}

cd DirectoryWherePanotoolsIs/panotools/trunk/libpano
nano bootstrap (or do it with your preferred editor)

Alternatively, this command-line should work just as well (untested):

 export LIBTOOLIZE=glibtoolize

Now you can build the library.

On Tiger and Leopard do:

export CFLAGS="-I/opt/local/include -L/opt/local/lib"
export CXXFLAGS="-I/opt/local/include -L/opt/local/lib"
./bootstrap --without-java
make
sudo make install

On Snow Leopard do:

export CFLAGS="-arch i386 -I/opt/local/include -L/opt/local/lib"
export CXXFLAGS="-arch i386 -I/opt/local/include -L/opt/local/lib"
./bootstrap --without-java

Open the "libtool" file with an editor and change all occurrences of "-dynamiclib" to "-dynamiclib -arch i386" (2 occurrences).
Note: If you want to build universal on Snow Leopard for both i386 and x86_64, change the "-dynamiclib" to "-dynamiclib -arch i386 -arch x86_64" (2 occurrences).

make
sudo make install

By default the library is installed into /usr/local/lib.

Build libpano13 from a release version tar.gz

To build libpano from a .tar.gz file, CD into the source directory of the unpacked .tar.gz. This will normally be "libpano13-2.9.xy" where "xy" is the version number. Note that the current Hugin version needs 2.9.18 or newer. Then do the following on Tiger and Leopard:

export CFLAGS="-I/opt/local/include -L/opt/local/lib"
export CXXFLAGS="-I/opt/local/include -L/opt/local/lib"
./configure --without-java
make
sudo make install

On Snow Leopard do the following:

export CFLAGS="-arch i386 -I/opt/local/include -L/opt/local/lib"
export CXXFLAGS="-arch i386 -I/opt/local/include -L/opt/local/lib"
./configure --without-java

Open the "libtool" file with an editor and change all occurrences of "-dynamiclib" to "-dynamiclib -arch i386" (4 occurrences).
Note: If you want to build universal on Snow Leopard for both i386 and x86_64, change the "-dynamiclib" to "-dynamiclib -arch i386 -arch x86_64" (4 occurrences).

make
sudo make install

By default the library is installed into /usr/local/lib.

WxWidgets

Hugin requires wxWidgets, which is called wxMac for MacOSX, the GUI toolkit currently employed by Hugin, to be at version >= 2.8.7. The current version of wxWidgets at MacPorts is 2.8.12. Note: Hugin can recently be configured to use WxWidgets 2.9. Note though that this is a development version and Mac OS X is always running a few steps behind.

Tiger (10.4.x)

Fix a problem on Tiger (10.4.x): Tiger comes with WxWindows version 2.5. The Hugin cmake will search OS paths first and will find Tiger's own version 2.5 instead of your freshly compiled 2.8. You need to get Tiger's 2.5 version out of the way as you won't be able to build Hugin succesfully as long as it is in place.

sudo mv /usr/bin/wx-config /usr/bin/wx-config-2.5
sudo mv /usr/include/wx-2.5 /usr/include/wx-2.5-macTiger

Leopard (10.5.x)

Fix a problem on Leopard (10.5.x): Leopard comes with WxWindows version 2.8.4. The Hugin cmake will search OS paths first and will find Leopard's own version 2.8.4 instead of your freshly compiled 2.8.8 or above. You need to get Tiger's 2.8.4 version out of the way. Hugin will build succesfully with 2.8.4 and will run. However version 2.8.4 still contains some bugs that will cause "bleeding through" in the graphical CP windows. This means that when things change in wxwidgets objects, sometimes (most of the times) the CP window displays through your current GUI screen.

sudo mv /usr/bin/wx-config /usr/bin/wx-config-2.8.4
sudo mv /usr/include/wx-2.8 /usr/include/wx-2.8-macLeopard

Snow Leopard (10.6.x)

Snow Leopard comes with WxWindows 2.8.8 so no changes are required. An alternative is to build WxWidgets from MacPorts (currently 2.8.12):

sudo port install wxWidgets

Build Hugin

Get Hugin from Mercurial

Check out the hugin sources from the Mercurial repository, like:

hg clone http://hg.code.sf.net/p/hugin/hugin hugin

If you are asked to accept the ssh key from the SourceForge server, do accept it permanently (p). Otherwise the configuring process using cmake will fail.

On subsequent updates you simply cd into the hugin directory and issue the following two commands:

hg pull
hg update

Create hugin build directory

Create another directory alongside the newly created hugin/ for the build files (a cool feature of CMake: it doesn't need to pollute your source directory with build files!):

mkdir hugin_build; cd hugin_build

Note: You can give this directory any name you want, but hugin_build is chosen for its clarity.

Configure build

Before we configure hugin we need to set the build environment:

export CFLAGS="-I/opt/local/include -L/opt/local/lib"
export CXXFLAGS=$CFLAGS

Snow Leopard: If you are on Snow Leopard you need to use the following C/CXX FLAGS:

export CFLAGS="-arch i386 -I/opt/local/include -L/opt/local/lib"
export CXXFLAGS=$CFLAGS

Note: On Snow Leopard, gcc builds for 64-bit architecture by default. However, some libraries that Hugin depends upon are not yet compilable as 64-bit libraries (such as wxWindows-2.8). Thus, the i386 flag is necessary to force a 32-bit build.

Configure hugin using cmake from inside the build directory you created:

cmake ../hugin

Note: If you are rebuilding hugin after an svn upgrade or other (system) change, the savest way to proceed is to first remove the "CMakeCache.txt" from your build directory. It contains the build settings for your previous build.

Compile Hugin

Compile Hugin and friends:

make
sudo make install

Watch the pretty colors go by. Give the dog another quick spin around the block; you're finished. Look for the new bundle Hugin.app in usr/local/Applications/ or in usr/local/bin/. Copy or link it to /Applications, or your preferred location, and commence testing.

If your build fails on Snow Leopard with this error (might happen only after upgrade from Leopard):

Linking CXX executable celeste_standalone
ld: library not found for -lcrt1.10.6.o

try this before make:

export MACOSX_DEPLOYMENT_TARGET=10.5

Important Note on the produced Bundle

Since the produced Hugin.app bundle links dynamically to libraries outside of the bundle, it is not yet portable, i.e. cannot be copied or shared unless the other machine has the same collection of libraries available in the same places. This is to facilitate development and testing (re-compile external libraries and test without re-building). Building a fully portable universal binary version at the command line is planned. You can use the Build a MacOSX Universal Hugin bundle with Xcode to build a universal portable bundle.

Building Enblend (using Fink or MacPorts)

follow these updated instructions

Building Autopano-Sift-C

Follow these instructions