Difference between revisions of "MacOSCompile"

From VideoLAN Wiki
Jump to navigation Jump to search
(remove $ in command lines to allow copy/pasting)
Line 12: Line 12:
 
If you are on Xcode 4.3 with no previous Xcode installation , you probably need to run xcode select to point to your xcode developer directory.
 
If you are on Xcode 4.3 with no previous Xcode installation , you probably need to run xcode select to point to your xcode developer directory.
  
$ xcrun clang
+
xcrun clang
  
 
If this outputs 'Error: No developer directory...', then use xcode-select to select the developer directory within the Xcode package.
 
If this outputs 'Error: No developer directory...', then use xcode-select to select the developer directory within the Xcode package.
Line 18: Line 18:
 
something like:
 
something like:
  
$ sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer   
+
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer   
  
 
=== Git  ===
 
=== Git  ===
Line 25: Line 25:
 
You just need to point your Terminal to it:
 
You just need to point your Terminal to it:
  
  $ export PATH=/Developer/usr/bin:$PATH
+
  export PATH=/Developer/usr/bin:$PATH
  
 
If you have Xcode 3, [http://git-scm.com/ get Git from their website].
 
If you have Xcode 3, [http://git-scm.com/ get Git from their website].
Line 33: Line 33:
 
On '''Mac OS X 10.6''' VLC needs to be compiled using Apple's llvm-gcc-4.2 compiler in its latest version. 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):  
 
On '''Mac OS X 10.6''' VLC needs to be compiled using Apple's llvm-gcc-4.2 compiler in its latest version. 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 CC=/Developer/usr/bin/llvm-gcc-4.2
  $ export CXX=/Developer/usr/bin/llvm-g++-4.2
+
  export CXX=/Developer/usr/bin/llvm-g++-4.2
  $ export OBJC=/Developer/usr/bin/llvm-gcc-4.2
+
  export OBJC=/Developer/usr/bin/llvm-gcc-4.2
  
 
On '''Mac OSX 10.8.2''' use the following  
 
On '''Mac OSX 10.8.2''' use the following  
  
  $ export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
+
  export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
  $ export CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
+
  export CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
  $ export OBJC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc  
+
  export OBJC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc  
  
 
If you are using a C-Shell, you need to use the setenv command of course.
 
If you are using a C-Shell, you need to use the setenv command of course.
Line 47: Line 47:
 
= [[GetTheSource|Get the source code]]  =
 
= [[GetTheSource|Get the source code]]  =
  
   $ git clone git://git.videolan.org/vlc.git
+
   git clone git://git.videolan.org/vlc.git
  
 
= Build VLC with a single command  =
 
= Build VLC with a single command  =
  
 
Setup a build folder:
 
Setup a build folder:
  $ cd vlc && mkdir build && cd build
+
cd vlc && mkdir build && cd build
  
 
And run the build:
 
And run the build:
  $ ../extras/package/macosx/build.sh
+
../extras/package/macosx/build.sh
  
 
Wait and you are finished
 
Wait and you are finished
  
 
You can see more options for this build (change arch or sdk):
 
You can see more options for this build (change arch or sdk):
  $ ../extras/package/macosx/build.sh -h
+
../extras/package/macosx/build.sh -h
  
 
= Build steps =
 
= Build steps =
Line 70: Line 70:
 
   
 
   
 
Here is how:
 
Here is how:
  $ cd vlc/extras/tools
+
  cd vlc/extras/tools
  $ ./bootstrap && make
+
  ./bootstrap && make
  $ cd ../..
+
  cd ../..
  
 
'''Important''': set the new PATH.
 
'''Important''': set the new PATH.
  $ export PATH=$PWD/extras/tools/build/bin:$PATH
+
  export PATH=$PWD/extras/tools/build/bin:$PATH
  
 
== SDK selection and 32/64 bits  ==
 
== SDK selection and 32/64 bits  ==
Line 83: Line 83:
 
If you want to use the 10.6 SDK (your VLC will only run on 10.6 and more recent computers):  
 
If you want to use the 10.6 SDK (your VLC will only run on 10.6 and more recent computers):  
  
  $ export OSX_VERSION=10.6
+
  export OSX_VERSION=10.6
  
 
You can do the same for '''10.5''', but please check that you have ''MacOSX10.5.sdk'' installed in ''/Developer/SDKs/'' . If you are using Xcode 4.2, you can [http://stackoverflow.com/a/6293605 install the 10.5 sdk] with the .dmg from Xcode3.  
 
You can do the same for '''10.5''', but please check that you have ''MacOSX10.5.sdk'' installed in ''/Developer/SDKs/'' . If you are using Xcode 4.2, you can [http://stackoverflow.com/a/6293605 install the 10.5 sdk] with the .dmg from Xcode3.  
Line 110: Line 110:
 
Before compiling VLC, you need lots of other libraries. Here is how to get them:  
 
Before compiling VLC, you need lots of other libraries. Here is how to get them:  
  
  $ cd contrib
+
cd contrib
  $ mkdir -p osx && cd osx
+
mkdir -p osx && cd osx
  $ ../bootstrap --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10
+
../bootstrap --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10
  
 
=== Prebuilt libraries (recommended) ===
 
=== Prebuilt libraries (recommended) ===
Line 118: Line 118:
 
If you want to download a prebuilt package of all the needed libraries.  
 
If you want to download a prebuilt package of all the needed libraries.  
  
  $ make prebuilt
+
make prebuilt
  
 
And then skip to [[OSXCompile#Bootstrap_VLC|bootstrap section of this page]].
 
And then skip to [[OSXCompile#Bootstrap_VLC|bootstrap section of this page]].
Line 126: Line 126:
 
If you want to build from source a package in the contribs:  
 
If you want to build from source a package in the contribs:  
  
  $ make -j4 .gettext
+
make -j4 .gettext
  $ export PATH=$PWD/../x86_64-apple-darwin10/bin:$PATH
+
export PATH=$PWD/../x86_64-apple-darwin10/bin:$PATH
  
 
Then:  
 
Then:  
  
  $ make -j4
+
make -j4
  
 
If you had no errors, the 3rd party libraries (contrib) are built correctly and you can proceed to the next step.
 
If you had no errors, the 3rd party libraries (contrib) are built correctly and you can proceed to the next step.
Line 139: Line 139:
 
Go back to the VLC source directory:  
 
Go back to the VLC source directory:  
  
  $ cd ../..
+
cd ../..
  
 
== Bootstrap VLC  ==
 
== Bootstrap VLC  ==
Line 145: Line 145:
 
This will create the configure script:  
 
This will create the configure script:  
  
  $ ./bootstrap
+
./bootstrap
  
 
== Configure the VLC build  ==
 
== Configure the VLC build  ==
Line 151: Line 151:
 
Create a build folder:  
 
Create a build folder:  
  
  $ mkdir -p build && cd build
+
mkdir -p build && cd build
  
 
To list the different options of configure:  
 
To list the different options of configure:  
  
  $ ../extras/package/macosx/configure.sh --help
+
../extras/package/macosx/configure.sh --help
  
 
To build a 64 bits binary:  
 
To build a 64 bits binary:  
  
  $ ../extras/package/macosx/configure.sh --enable-debug --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10
+
../extras/package/macosx/configure.sh --enable-debug --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10
  
 
== Build VLC  ==
 
== Build VLC  ==
  
 
Just do:
 
Just do:
  $ make -j4
+
make -j4
  
 
and wait...
 
and wait...
Line 172: Line 172:
 
If you want to share the application with another user or another computer:  
 
If you want to share the application with another user or another computer:  
  
  $ make VLC.app
+
make VLC.app
  
 
If you want a disk-image:  
 
If you want a disk-image:  
  
  $ make package-macosx
+
make package-macosx
  
 
Respectively <code>make package-macosx-plugin</code> for the Safari/Mozilla plugin.
 
Respectively <code>make package-macosx-plugin</code> for the Safari/Mozilla plugin.
Line 184: Line 184:
 
If you want to sign your application with a certificate, for example for Gatekeeper, you need to run:
 
If you want to sign your application with a certificate, for example for Gatekeeper, you need to run:
  
  $ extras/package/macosx/codesign.sh -i "certificate name"
+
extras/package/macosx/codesign.sh -i "certificate name"
  
 
If you want to support OS X Snow Leopard and Leopard with your signature, you need to enable the "-g" option. Note that you need to replace the signature leaf hash "75GAHG3SZQ" with your own inside the codesign script prior to doing so, since otherwise your certificate will mix with VideoLAN's and your binary will be rejected by the OS.
 
If you want to support OS X Snow Leopard and Leopard with your signature, you need to enable the "-g" option. Note that you need to replace the signature leaf hash "75GAHG3SZQ" with your own inside the codesign script prior to doing so, since otherwise your certificate will mix with VideoLAN's and your binary will be rejected by the OS.
Line 212: Line 212:
 
'''git must still be accessible though!'''  
 
'''git must still be accessible though!'''  
  
  $ unset PKG_CONFIG_PATH
+
  unset PKG_CONFIG_PATH
  $ unset PKG_CONFIG_LIBDIR
+
  unset PKG_CONFIG_LIBDIR
  $ export PATH=$PWD/build/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
+
  export PATH=$PWD/build/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
  
 
=== QTsound compilation on X.5  ===
 
=== QTsound compilation on X.5  ===

Revision as of 23:53, 7 January 2013

This is an howto to compile VLC media player on Mac OS X, focused on VLC 2.0 and newer.

Pre-requisites

Apple Software

Xcode select on Xcode 4.3

If you are on Xcode 4.3 with no previous Xcode installation , you probably need to run xcode select to point to your xcode developer directory.

xcrun clang

If this outputs 'Error: No developer directory...', then use xcode-select to select the developer directory within the Xcode package.

something like:

sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer  

Git

If you have XCode 4, Git is already installed You just need to point your Terminal to it:

export PATH=/Developer/usr/bin:$PATH

If you have Xcode 3, get Git from their website.

Configure the environment

On Mac OS X 10.6 VLC needs to be compiled using Apple's llvm-gcc-4.2 compiler in its latest version. 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

On Mac OSX 10.8.2 use the following

export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
export CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
export OBJC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc 

If you are using a C-Shell, you need to use the setenv command of course.

Get the source code

 git clone git://git.videolan.org/vlc.git

Build VLC with a single command

Setup a build folder:

cd vlc && mkdir build && cd build

And run the build:

../extras/package/macosx/build.sh

Wait and you are finished

You can see more options for this build (change arch or sdk):

../extras/package/macosx/build.sh -h

Build steps

Now, if you prefer, you can read the following detailed information on how the build internally works:

Additional development tools

You need development tools, notably all the autotools, to build VLC correctly.

Here is how:

cd vlc/extras/tools
./bootstrap && make
cd ../..

Important: set the new PATH.

export PATH=$PWD/extras/tools/build/bin:$PATH

SDK selection and 32/64 bits

SDK selection

If you want to use the 10.6 SDK (your VLC will only run on 10.6 and more recent computers):

export OSX_VERSION=10.6

You can do the same for 10.5, but please check that you have MacOSX10.5.sdk installed in /Developer/SDKs/ . If you are using Xcode 4.2, you can install the 10.5 sdk with the .dmg from Xcode3.

32/64bits selection

The instructions below will build a 64 bits binary using 10.6 (Snow Leopard) SDK. This is reflected by using host and build variables x86_64-apple-darwin10.

This "triplet" is ARCHITECTURE-apple-SYSTEM.

ARCHITECTURE

  • x86_64 represents Intel 64bits.
  • i686 represents Intel 32bits.
  • powerpc represents PowerPC 32bits.

SDK SYSTEM

  • darwin9 represents MacOSX 10.5.
  • darwin10 represents MacOSX 10.6.

So to make a PowerPC build, you would use powerpc-apple-darwin9. So to make a intel32 build for 10.5+, you would use i686-apple-darwin9. So to make a intel64 build for 10.6+, you would use x86_64-apple-darwin10.

Prepare 3rd party libraries

Before compiling VLC, you need lots of other libraries. Here is how to get them:

cd contrib
mkdir -p osx && cd osx
../bootstrap --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10

Prebuilt libraries (recommended)

If you want to download a prebuilt package of all the needed libraries.

make prebuilt

And then skip to bootstrap section of this page.

Build your own libraries (not for the faint-hearted)

If you want to build from source a package in the contribs:

make -j4 .gettext
export PATH=$PWD/../x86_64-apple-darwin10/bin:$PATH

Then:

make -j4

If you had no errors, the 3rd party libraries (contrib) are built correctly and you can proceed to the next step.

Go Back

Go back to the VLC source directory:

cd ../..

Bootstrap VLC

This will create the configure script:

./bootstrap

Configure the VLC build

Create a build folder:

mkdir -p build && cd build

To list the different options of configure:

../extras/package/macosx/configure.sh --help

To build a 64 bits binary:

../extras/package/macosx/configure.sh --enable-debug --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10

Build VLC

Just do:

make -j4

and wait...

Package VLC Application for Mac

If you want to share the application with another user or another computer:

make VLC.app

If you want a disk-image:

make package-macosx

Respectively make package-macosx-plugin for the Safari/Mozilla plugin.

Sign VLC Application for Mac

If you want to sign your application with a certificate, for example for Gatekeeper, you need to run:

extras/package/macosx/codesign.sh -i "certificate name"

If you want to support OS X Snow Leopard and Leopard with your signature, you need to enable the "-g" option. Note that you need to replace the signature leaf hash "75GAHG3SZQ" with your own inside the codesign script prior to doing so, since otherwise your certificate will mix with VideoLAN's and your binary will be rejected by the OS.

What's wrong: troubleshooting

Xcode path

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

Xcode version

Please make sure that you are using the latest Xcode3 or the latest version of Xcode4 to compile VLC

3rd party packagers and PATH

Pay careful attention to remove any reference to 3rd party package managersfrom your environment. This is important to avoid conflicts between your package manager (homebrew, fink, macports...) and the contrib package manager we use to build our contrib.

It shouldn't be necessary, but it can happen.

git must still be accessible though!

unset PKG_CONFIG_PATH
unset PKG_CONFIG_LIBDIR
export PATH=$PWD/build/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

QTsound compilation on X.5

MacOS X.5.SDK is broken - 2 options exist:

Option 1:

  • Download the MacOS10.6.sdk and get QTCaptureDecompressedAudioOutput.h from /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/QTKit.framework/Headers/ and move it to /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/QTKit.framework/Headers/
  • Edit /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/QTKit.framework/Headers/QTKit.h and add the
#import <QTKit/QTCaptureDecompressedAudioOutput.h> where needed.

Option 2:

  • Configure the VLC build to explicitly use the MacOS10.6.sdk by adding the following flag:
--with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk

Cross-Compilation to PPC from X.6 intel

If you want to compile VLC for PPC, based on a X.6 intel, you need to tweak a few things since Apple broke it.

This is VERY advanced stuff!

Pre-requisites

Be sure to:

  • have X.6.8
  • Xcode 4.2 installed in the normal /Developers location
  • Xcode 3 installed in /Xcode3 location
  • MacOS X.6 and X.5 SDK installed in /Developers/SDKs/ , as explained above (SDK selection).

GNU AS

Using this out of the box will not work because AS for ppc is broken on the default setup. Here is how to fix it:

cd /usr/libexec/as
sudo mkdir ppc
cd ppc
sudo ln -sf /Xcode3/usr/bin/as as