Difference between revisions of "MacOSCompile"

From VideoLAN Wiki
Jump to navigation Jump to search
(Updated.)
Line 1: Line 1:
This is an '''howto''' to compile {{VLC}} on ''Mac OS X'', focused on '''VLC 2.0''' and newer.  
+
This is an '''howto''' to compile {{VLC}} on ''Mac OS X'', focused on '''VLC 3.0''' and newer.  
  
 
= Pre-requisites  =
 
= Pre-requisites  =
Line 5: Line 5:
 
=== Apple Software ===
 
=== Apple Software ===
  
*You need at least MacOSX '''10.7''', '''Lion''' or later is strongly recommended, though.  
+
*You need at least MacOSX '''10.8'''. Any later version is strongly recommended, though.  
*'''Developer Tools from Apple''' from http://developer.apple.com/technology/xcode.html<br> You need at least ''Xcode4.3''. <br />Note: If using [https://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_4_3.html Xcode 4.3], the command line tools must be installed manually through preferences.
+
*'''Developer Tools from Apple''' from http://developer.apple.com/technology/xcode.html<br> You need at least ''Xcode 5''. <br />Note that we need the optional command line tools, which can be installed through the preferences dialog or through the OS X dialog offering their installation.
  
=== Xcode select on Xcode 4.3 ===
+
=== Xcode select  ===
  
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.
+
You might need to run xcode select to point to your xcode developer directory.
  
 
  xcrun clang
 
  xcrun clang
Line 22: Line 22:
 
=== Configure the environment ===
 
=== Configure the environment ===
  
On '''Mac OS X 10.7''' VLC needs to be compiled using Apple's clang 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):  
+
VLC needs to be compiled using Apple's clang 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="xcrun clang"
 
  export CC="xcrun clang"
Line 81: Line 81:
  
 
  make prebuilt
 
  make prebuilt
 
After:
 
 
You need to little change on "x265.pc" file:
 
 
vim ../x86_64-apple-darwin10/lib/pkgconfig/x265.pc
 
--Libs:  -L${libdir} -lx265  -lstdc++ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/'''4.2'''/lib/darwin/libclang_rt.osx.a
 
++Libs:  -L${libdir} -lx265  -lstdc++ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/'''[your version]'''/lib/darwin/libclang_rt.osx.a
 
 
Important thing is '''[your version]'''. Go to "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/" folder and find your version.
 
  
 
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 99: Line 89:
  
 
  make -j4 .gettext
 
  make -j4 .gettext
  export PATH=$PWD/../x86_64-apple-darwin10/bin:$PATH
+
  export PATH=$PWD/../x86_64-apple-darwin11/bin:$PATH
  
 
Then:  
 
Then:  
Line 129: Line 119:
 
  ../extras/package/macosx/configure.sh --help
 
  ../extras/package/macosx/configure.sh --help
  
To build a binary with the previously installed x86_64-apple-darwin10 contrib:  
+
To build a binary with the previously installed x86_64-apple-darwin11 contrib:  
  
  ../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-darwin11 --build=x86_64-apple-darwin11
  
 
== Build VLC  ==
 
== Build VLC  ==

Revision as of 18:57, 7 July 2015

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

Pre-requisites

Apple Software

  • You need at least MacOSX 10.8. Any later version is strongly recommended, though.
  • Developer Tools from Apple from http://developer.apple.com/technology/xcode.html
    You need at least Xcode 5.
    Note that we need the optional command line tools, which can be installed through the preferences dialog or through the OS X dialog offering their installation.

Xcode select

You might 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  

Configure the environment

VLC needs to be compiled using Apple's clang 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="xcrun clang"
export CXX="xcrun clang++"
export OBJC="xcrun clang"

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

Set the OSX_Version to your current OSX Version

export OSX_VERSION=10.7

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-darwin11 --build=x86_64-apple-darwin11

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-darwin11/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 binary with the previously installed x86_64-apple-darwin11 contrib:

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

Build VLC

Just do:

make -j4

and wait...

if you want to avoid recompiling VLC.app every time during development use

make VLC-dev.app

Package VLC Application for Mac

If you want a disk-image:

make package-macosx

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"

What's wrong: troubleshooting

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