Difference between revisions of "MacOSCompile"
Line 1: | Line 1: | ||
== Prepare Mac OS X for build VLC == | == Prepare Mac OS X for build VLC == | ||
− | Compiling {{VLC}} on Mac OS X is just a bit more complex than other projects | + | Compiling {{VLC}} on Mac OS X is just a bit more complex than other projects, because we do not use Xcode to configure, but a simple <code>./configure</code> and then <code>make</code> isn't enough either. You need both. |
− | |||
− | |||
The instructions below are always for the currently unstable, non-released code. | The instructions below are always for the currently unstable, non-released code. |
Revision as of 14:55, 2 November 2011
Contents
Prepare Mac OS X for build VLC
Compiling VLC media player on Mac OS X is just a bit more complex than other projects, because we do not use Xcode to configure, but a simple ./configure
and then make
isn't enough either. You need both.
The instructions below are always for the currently unstable, non-released code.
Please install:
- Developer Tools from Apple do this now: http://developer.apple.com/technology/xcode.html
- Git from http://git-scm.com/ and pkg-config
- You can use homebrew to do this:
brew install git pkg-config
Nota Bene:
- Be sure to read the paragraph on Mac OS X "Leopard and Lion" before starting the compilation, if you are on those OSes.
- If you wish to develop or test please join the vlc-devel mailinglist .
Quick Steps on Mac OS X 10.5
Configure the environment:
$ export CC=/Developer/usr/bin/llvm-gcc-4.2 $ export CXX=/Developer/usr/bin/llvm-g++-4.2 $ export OBJC=/Developer/usr/bin/llvm-gcc-4.2
Download the sources from repository:
$ git clone git://git.videolan.org/vlc.git
Build needed additional libs:
$ cd vlc/extras/contrib $ ./bootstrap $ make
Build VLC:
$ cd ../.. $ ./bootstrap $ ./configure --enable-debug --disable-nls $ make
If you want a distributable build of VLC:
$ make VLC-release.app
Quick Steps on Mac OS X 10.6
Configure the environment:
$ export CC=/Developer/usr/bin/llvm-gcc-4.2 $ export CXX=/Developer/usr/bin/llvm-g++-4.2 $ export OBJC=/Developer/usr/bin/llvm-gcc-4.2
Download the sources from repository:
$ git clone git://git.videolan.org/vlc.git
Build needed additional libs:
$ cd vlc/extras/contrib $ ./bootstrap x86_64-apple-darwin10 $ make
Build VLC:
$ cd ../.. $ ./bootstrap $ ./configure --enable-debug --disable-nls --build=x86_64-apple-darwin10 $ make
If you want a distributable build of VLC:
$ make VLC-release.app
Steps
Please follow these steps for compiling:
Set the development environment
Install the Mac OS X Developer Tools or get them online.
You need at least Mac OS X 10.5 and Xcode 3.1.4 for compilation. Mac OS X 10.6 and its 3.2.x Xcode releases are also supported. Make sure that the LLVM GCC 4.2 compiler is installed.
Compiling with earlier releases of Mac OS X and/or Xcode will not work.
Additionally, you may need to install Subversion (SVN) and more importantly Git on your Mac.
Get the source
Download the VLC media player source code (using Git) as described on the "Get the source" page or get a recent source tarball. Note that the 3rd party libraries will probably break a few months after the release's publication.
Build external libs
We now need to build the 3rd party libs. For that, you will need to:
- cd to the source directory with your Terminal application.
- If you have fink, then you will need to disable it. VLC media player has it's own form of Fink (in the extras/contrib subdir) and it can conflict with Fink. We use this system to generate a reliable, consistent and known amount of packages that VLC media player requires.
To disable Fink comment the line: #source /sw/bin/init.csh
in your .cshrc file or . /sw/bin/init.csh
in your .bashrc file or test -r /sw/bin/init.sh && . /sw/bin/init.sh
in your .profile file in your home-directory.
- First fetch the contribs. Those are external libraries needed by VLC.
$ cd extras/contrib $ ./bootstrap $ make
The last command will download prebuilt binary contrib you can happily use to build VLC wth -- only if you're using git master branch or the bugfix branch for 0.9 / 1.0. You will only have to do this once. (You can do it again if required libraries are added or updated by the team.)
If you're trying to debug these libraries or want to create a new package, you need to execute make src
Note that the 10.5 SDK is used by default. If you encounter problems, make sure that the script correctly used Apple's GCC-4.2 compiler (no LLVM-GCC here!) and your Xcode installation is up-to-date.
Prepare the VLC build
Now we return to VLC itself. Go back to the top level VLC source directory.
$ cd ../.. $ ./bootstrap
This will create configure and Makefiles for VLC media player (snapshots and releases already include this).
Setup the correct compiler
Current revisions of VLC need to be compiled using Apple's llvm-gcc-4.2 compiler in its latest version. In case of failures, make sure that the latest version of Xcode is installed. To use this compiler, you need to export the respective variables. In a Bourne Shell, type this (if Xcode is installed to its default location; bash is the default shell on OS X):
$ export CC=/Developer/usr/bin/llvm-gcc-4.2 $ export CXX=/Developer/usr/bin/llvm-g++-4.2 $ export OBJC=/Developer/usr/bin/llvm-gcc-4.2
If you are using a C-Shell, you need to use the setenv command of course.
Configure the VLC build
The next step is to configure, in the top level VLC source directory.
In current revisions, you can simply run
$ ./configure --enable-debug
to get VLC in its default configuration. If do not want to use VLC's default configuration for Mac, be sure to add --disable-macosx-defaults
to your custom set. Using --disable-nls
will save you a lot of time, if you don't care about localised interfaces.
When compiling earlier revisions or the 0.8.6 branch, you need to give a wide variety of configure flags to achieve a useful build. We used to use this set:
./configure --enable-debug --disable-x11 --disable-xvideo --disable-glx --enable-sdl --enable-mad --enable-libdvbpsi --enable-a52 --disable-dvdplay --enable-dvdnav --enable-dvdread --enable-ffmpeg --enable-faad --enable-flac --enable-vorbis --enable-speex --enable-theora --enable-ogg --enable-shout --enable-cddb --disable-cddax --enable-vcdx --disable-skins --disable-skins2 --disable-wxwidgets --enable-freetype --enable-fribidi --enable-caca --enable-live555 --enable-dca --enable-goom --enable-modplug --enable-gnutls --enable-daap --enable-ncurses --enable-libtwolame --enable-x264 --enable-png --enable-realrtsp --enable-lua --disable-libtool
Have a look at configure.ac for our current default configuration.
You can add --with-mozilla-sdk-path=./extras/contrib/gecko-sdk --enable-mozilla
to the configure-line to enable the compilation of VLC's Safari/Firefox plugin.
Build VLC
After configure is finished, we can finally build VLC media player. A simple make
will do the trick. If you want to use the resulting application package on a different Mac or a different account on the same Mac, run
$ make $ make VLC-release.app
afterwards. Use the resulting VLC-release.app for these purposes.
If you want a disk-image, type
$ make package-macosx
(respectively make package-macosx-plugin
for the Safari/Mozilla plugin).
What's wrong, if I don't succeed?
Starting with Leopard, Xcode may be installed to a custom location on the administrator's choice. While this is non-problematic for ordinary Xcode projects, VLC needs a little help. You have to place extra symbolic links in /Developer pointing to your custom location for these folders:
usr, Headers, Private, SDKs, Tools, Makefiles
You can easily create these links by executing the following command for each folder (whereas theFolder is one of these six):
ln -s /full/path/to/Developer/theFolder /Developer/theFolder
Additionally, make always sure that you are using the latest version of Xcode. Otherwise, VLC's compilation or behaviour at runtime won't be the way you want it to be.
What about 64-bit?
The master branch can be compiled in 64-bit mode on OS X. This is also possible with the 1.0-branch, but neither recommended nor supported. 64bit execution is only tested for x86_64, but PPC64 should probably also work. Precompiled contribs are usually available for x86_64. To see how to compile VLC this way, check the documentation of your GCC vendor, as there are known differences within the supported versions of Mac OS X, but you may try:
bootstrap in extras/contrib with with "x86_64-apple-darwin*" argument
The asterix is either 9 or 10 depending on your Mac OS X version. Afterwards, just type make as usual.
Running configure on Mac OS X 10.5 aka Darwin 9
Do the following ./configure CFLAGS="-m64" CXXFLAGS="-m64" LDFLAGS="-m64" OBJCFLAGS="-m64" --host=x86_64-apple-darwin9
instead of the regular line. Replacing x86_64 with PPC64 here should work, but is untested.
Running configure on Mac OS X 10.6 aka Darwin 10
Just ./configure --build=x86_64-apple-darwin10
. Xcode 3.2.x creates 64bit builds by default.
Snow Leopard and Lion
A series of problem affect the build under Mac OS X 10.6 (Snow Leopard / darwin 10), these include:
32-bit builds
The compiler now tries to build for the x86_64 arch by default, if you want to make a 32-bit build of VLC, you have to change the configure, similarly to what shown above: ./configure --host=i386-apple-darwin10 CFLAGS="-arch i386" CXXFLAGS="-arch i386" LDFLAGS="-arch i386" OBJCFLAGS="-arch i386"
Missing libiconv.la
The /usr/lib/libiconv.la
file has been removed, but the other .la files in contrib still reference it. By default, the Makefile in extras/contrib will fix this automatically, as it changes all references to this file lib/*.la to lib/libiconv.la, which is provided by VLC's contrib package.
Please note that removing all libtool libraries (*.la) is not recommended, as this will lead to errors when configuring VLC.
Xcode 4
This version of Xcode isn't supported by default yet. If you still like to use it, set the compiler environment variables as desired (note that Clang 2.0 can't fully compile VLC yet because of missing ASM features) and use the following configure line:
./configure --enable-debug --build=x86_64-apple-darwin10 --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --enable-macosx
This line is needed because VLC will try to use the 10.5 SDK by default, which isn't available to Xcode 4 users. If you don't want the Mac OS X interface (for VLCKit or Lunettes users), remove the last option.
Clang
You can also use clang / clang++ to compile VLC if you set the respective $CC, ... variables. However, note that clang doesn't include full support for inline assembler as of yet, which is why you need to configure VLC with --disable-sse --disable-mmx
or provide a patch to the LLVM project fixing their compiler.
History
Written by Jean-Alexis Montignies, Felix Paul Kühne and Derk-Jan Hartman, for the VideoLAN Team. Adapted to the Wiki by Jean-Baptiste Kempf.