Difference between revisions of "MacOSCompile"

From VideoLAN Wiki
Jump to navigation Jump to search
m (cosmetics)
 
(190 intermediate revisions by 19 users not shown)
Line 1: Line 1:
== Prepare Mac OS X for build VLC ==
+
{{Lowercase}}
 +
This is an '''howto''' to compile {{VLC}} on '''macOS''' ''(formerly known as Mac OS X)'', focused on '''VLC 3.0''' and later.
  
Compiling {{VLC}} on Mac OS X is different from normal linux compiling and OS X compiling. We do not use Xcode, but a simple <code>./configure</code> and then <code>make</code> isn't enough either. The instructions below are always for the currently unstable, non-released code. If you compile from [[Git]] then please remember that this code can often be in an unstable state so ''don't put any of the non-released test binaries or git-compiles on software sites or on user-forums. We have had bad experiences with this before and we do not appreciate it.''
+
= Pre-requisites  =
  
* If you wish to develop or test please join the [http://www.videolan.org/developers/lists.html  vlc-devel mailinglist ].
+
=== Apple Software ===
* If you doesn't have installed '''Developer Tools from Apple''' do this now:  http://developer.apple.com/technology/xcode.html <br>
 
* If you doesn't have installed '''Git''' do this now: http://git-scm.com/
 
* Be sure to read the paragraph on Mac OS X Leopard before starting the compilation.
 
  
== Quick Steps on Mac OS X 10.5 ==
+
Those are the minimum build system requirements to compile VLC 4.0 (current development version). They are also highly recommended to compile VLC 3.0:
Configure the environment:
+
* At least '''macOS 10.13.4''', or any later version
 +
* At least '''Xcode 9.3''' from [https://developer.apple.com/xcode/ developer.apple.com/xcode]. (Note: Installing the developer tools package is not needed, and building with that package is not supported)
 +
* Use at least '''macOS SDK 10.13''' (this is included and the default in Xcode 9.3)
 +
* Install python3 (macOS pkg installer from python.org)
 +
* Java 8 JDK (needed to compile Java menu support for blurays)
  
  $ export CC=/Developer/usr/bin/llvm-gcc-4.2
+
==== Compiler test  ====
  $ export CXX=/Developer/usr/bin/llvm-g++-4.2
 
  $ export OBJC=/Developer/usr/bin/llvm-gcc-4.2
 
  
Download the sources from repository:
+
Ensure the compiler is found correctly by running
  
  $ git clone git://git.videolan.org/vlc.git
+
xcrun clang
  
Build needed additional libs:
+
in the Terminal, if this outputs anything else than <code>clang: error: no input files</code>, see the troubleshooting part of this document.
  
  $ cd vlc/extras/contrib
+
==== Developer directory test ====
  $ ./bootstrap
+
 
  $ make
+
The Xcode developer directory must be used, not the command line tools developer directory, as only Xcode includes all necessary tools.
 +
 
 +
Run the following command in Terminal:
 +
 
 +
xcode-select --print-path
 +
 
 +
It needs to print out the path to your Xcode installation, like this
 +
 
 +
/Applications/Xcode.app/Contents/Developer
 +
 
 +
If it prints out a path to the command line tools package, select the correct path using the xcode-select tool. See [https://wiki.videolan.org/OSXCompile/#Xcode_.27No_developer_directory.27_error here] for the correct command.
 +
 
 +
= [[GetTheSource|Get the source code]]  =
 +
 
 +
git clone git://git.videolan.org/vlc.git
 +
 
 +
= Build VLC with a single command  =
 +
This is the most simple way to build VLC, including all its necessary dependencies. This way is highly recommended to use, as it sets up everything automatically.
 +
 
 +
Setup a build folder:
 +
cd vlc && mkdir build && cd build
 +
 
 +
And run the build:
 +
../extras/package/macosx/build.sh -c
 +
 
 +
The command line switch -c rebuilds all dependencies (contribs) from source. If you want to use a prebuild contrib package, omit the -c option.
 +
 
 +
Wait and you have finished.
 +
 
 +
You can see more options for this script (change arch or sdk):
 +
../extras/package/macosx/build.sh -h
 +
 
 +
In case this fails, please try the step-by-step build guide below using a
 +
clean checkout.
 +
 
 +
== Making changes and compile again ==
 +
 
 +
Using build.sh is the recommended way to do a fresh VLC build. Now, if you did some changes to the VLC source code, you can try to compile the change by calling build.sh again. But sometimes this is a bit cubersome, as it might take longer, and sometimes its preferred to execute some build commands directly.
 +
 
 +
For that reason, a script called env.build.sh is included in VLC (starting with VLC 4.0 in vlc.git), which helps you setting the correct environment of your Terminal. The correct environment is needed, to make sure the right internal tools are used for the build process.
 +
 
 +
Before you compile again with make, just source this script into the current Terminal (pay attention to the dot at the front of the command):
 +
. ../extras/package/macosx/env.build.sh
 +
 
 +
You can also create a symlink to that script in a more convenient location, for instance into the main vlc checkout directory:
 +
# change directory to root git checkout
 +
ln -s $PWD/extras/package/macosx/env.build.sh
 +
cd build # go back to your build directory
 +
. ../env.build.sh
 +
 
 +
Afterwards, in the same terminal, you can recompile by using the usual commands like make:
 +
make
 +
./bin/vlc-osx-static -vv # To test compiled changes
 +
 
 +
= Build steps =
 +
Now, if you prefer, you can read the following detailed information on how the build internally works. This section describes all steps which are internally done in build.sh already. Likely, they are only relevant to you if you do not want to use build.sh and env.build.sh.
 +
 
 +
== Additional development tools  ==
 +
 
 +
You need a number of tools, notably all the autotools, to build VLC correctly.
 +
VLC has a way to build the specific versions of these tools required from source, here is how:
 
   
 
   
Build VLC:  
+
cd extras/tools
 +
./bootstrap && make
 +
cd ../..
 +
 
 +
'''Important''': Add the extras/tools build results to your PATH, before doing anything else:
 +
export PATH=$PWD/extras/tools/build/bin:$PATH
 +
 
 +
== Prepare [[Contrib Status|3rd party libraries]]  ==
 +
 
 +
To compile VLC, you need lots of other libraries, called 3rd party. VLC has the so-called “contribs” system to help building these libraries
 +
from source. Alternatively you can use a pre-built package of these libraries provided by VideoLAN.
 +
 
 +
<!--
 +
FIXME: Add guide how to use pre-built nightly contribs:
 +
 
 +
=== Using pre-built nightly contribs ===
 +
Together with the nightly builds, the build bot does each night a new build of all of the 3rd party libraries required for VLC.
 +
(Not all contribs are included in this pre-built package, as not all contribs are enabled on all OSes and required.)
 +
-->
 +
 
 +
First, set the correct '''SDK''' version for the 3rd party libraries, usually your current OS X Version:
 +
 
 +
export OSX_VERSION=10.11
 +
 
 +
Then, prepare the 3rd party library folder:
 +
 
 +
mkdir -p contrib/contrib-osx &amp;&amp; cd contrib/contrib-osx
 +
../bootstrap --build=x86_64-apple-darwin15
 +
 
 +
=== Prebuilt libraries (recommended) ===
 +
 
 +
If you want to download a prebuilt package of all the needed libraries.
 +
 
 +
make prebuilt
 +
 
 +
Now you can just skip to the [[OSXCompile#Update_PATH|Update PATH]] section.
  
  $ cd ../..
+
=== Build your own libraries (not for the faint-hearted) ===
  $ ./bootstrap
+
You need to install the [http://www.oracle.com/technetwork/pt/java/javase/downloads/index.html Java JDK], to support java code for libbluray.
  $ ./configure --enable-debug 
 
  $ make
 
  
If you want a distributable build of VLC:
+
If you want to build contribs from source, you first need to make gettext, which is needed for some other contrib libraries to build:  
  
  $ make VLC-release.app
+
  make -j4 .gettext
  
== Quick Steps on Mac OS X 10.6 ==
+
Now you need to update your path for the gettext tools to be usable later on, see the [[#Update_PATH|Update PATH]] section above.
Configure the environment:
 
  
  $ export CC=/Developer/usr/bin/llvm-gcc-4.2
+
Then fetch contrib sources:
  $ export CXX=/Developer/usr/bin/llvm-g++-4.2
 
  $ export OBJC=/Developer/usr/bin/llvm-gcc-4.2
 
  
Download the sources from repository:
+
make fetch
  
  $ git clone git://git.videolan.org/vlc.git
+
and build them with:
  
Build needed additional libs:
+
make
  
  $ cd vlc/extras/contrib
+
If you had no errors, the 3rd party libraries (contrib) are built correctly and you can proceed to the next step.
  $ ./bootstrap x86_64-apple-darwin10
+
 
  $ make
+
=== Update PATH ===
   
+
 
Build VLC:  
+
First we go back to the source directory:
  
  $ cd ../..
+
cd ../..
  $ ./bootstrap
 
  $ ./configure --enable-debug  --build=x86_64-apple-darwin10
 
  $ make
 
  
If you want a distributable build of VLC:
+
And now we still need to add the contribs to our path, so they can be found:
  
  $ make VLC-release.app
+
  export PATH=$PWD/contrib/x86_64-apple-darwin15/bin:$PATH
  
 +
== Bootstrap VLC  ==
  
== Steps ==
+
This will create the configure script:
  
Please follow these steps for compiling:
+
./bootstrap
  
=== Set the development environment ===
+
Check that there are no obvious errors at this stage, like missing gettext or an error at exit.
  
Install the Mac OS X Developer Tools or get them online.
+
== Configure the VLC build  ==
  
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.
+
Create a build folder:
  
Compiling with earlier releases of Mac OS X and/or Xcode will not work.
+
mkdir -p build &amp;&amp; cd build
  
Additionally, you may need to install Subversion (SVN) and more importantly Git on your Mac.
+
To list the different options of configure:
  
=== Get the source ===
+
../extras/package/macosx/configure.sh --help
Download the {{VLC}} [[GetTheSource|source code]] (using [[Git]]) as described on the [[GetTheSource| "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 ===
+
To build a binary with the previously installed x86_64-apple-darwin15 contrib:
  
We now need to build the [[Contrib_Status| 3rd party libs]]. For that, you will need to:
+
../extras/package/macosx/configure.sh --enable-debug --host=x86_64-apple-darwin15
* cd to the source directory with your Terminal application.
 
* If you have fink, then you will need to disable it. {{VLC}} 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}} requires.  
 
  
''To disable Fink comment the line: ''<code>#source /sw/bin/init.csh</code>'' in your .cshrc file or ''<code> . /sw/bin/init.csh</code>'' in your .bashrc file or ''<code> test -r /sw/bin/init.sh && . /sw/bin/init.sh</code>'' in your .profile file in your home-directory.''
+
By default it will not use the installed SDK, like Xcode does, but use System Root. This means that if you built contribs on your own, the configure script might behave unexpectedly, for example enabling functions which are not present in a given operating system version. To work around this and build against the latest installed SDK, you can use:
  
* First fetch the contribs. Those are external libraries needed by VLC.
+
--with-macosx-sdk=`xcrun --show-sdk-path`
  $ 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.
+
If you want to use a different SDK, you can list all installed SDKs with <code>xcodebuild -showsdks</code> and to get the path for it, you can use the following command <code>xcodebuild -version <SDK Flag from before> Path</code>.<br />
You will only have to do this once. (You can do it again if required libraries are added or updated by the team.)
+
For example: <code>xcodebuild -version -sdk macosx10.11 Path</code>
  
If you're trying to debug these libraries or want to create a new package, you need to execute <code>make src</code>
+
== Build VLC  ==
  
''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.''
+
Just do:
 +
make -j4
  
=== Prepare the VLC build ===
+
and wait...
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}} (snapshots and releases already include this).
+
== Run VLC ==
 +
After <code>make</code>, you can just run VLC like so:
  
=== Setup the correct compiler ===
+
./bin/vlc-osx-static
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
+
If you want a VLC app bundle, just do
  $ export CXX=/Developer/usr/bin/llvm-g++-4.2
+
  $ export OBJC=/Developer/usr/bin/llvm-gcc-4.2
+
make VLC.app
  
If you are using a C-Shell, you need to use the ''setenv'' command of course.
+
And use it like a normal .app bundle.
  
=== Configure the VLC build ===
+
== Package VLC Application for Mac  ==
The next step is to configure, in the top level VLC source directory.
 
  
In current revisions, you can simply run
+
If you want a disk-image:
  $ ./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 <code>--disable-macosx-defaults</code> to your custom set. Using <code>--disable-nls</code> 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:
+
make package-macosx
<code> ./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</code>
 
Have a look at configure.ac for our current default configuration.
 
  
You can add <code>--with-mozilla-sdk-path=./extras/contrib/gecko-sdk --enable-mozilla</code> to the configure-line to enable the compilation of VLC's Safari/Firefox plugin.
+
Note: If you want a more fancy disk image, you need the [https://bitbucket.org/al45tair/dmgbuild dmgbuild] tool, which can be installed using <code>pip install dmgbuild</code> if you have
 +
python installed using [https://brew.sh Homebrew].
  
=== Build VLC ===
+
== Sign VLC Application for Mac  ==
After configure is finished, we can finally build {{VLC}}. A simple <code>make</code> 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
+
If you want to sign your application with a certificate, for example for Gatekeeper, you need to run:
  $ make package-macosx
 
(respectively <code>make package-macosx-plugin</code> for the Safari/Mozilla plugin).
 
  
=== What's wrong, if I don't succeed? ===
+
extras/package/macosx/codesign.sh -i "certificate name"
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:
 
  
<code>usr, Headers, Private, SDKs, Tools, Makefiles</code>
+
= Troubleshooting  =
  
You can easily create these links by executing the following command for each folder (whereas theFolder is one of these six):
+
== 3rd party packagers and PATH  ==
  
<code>ln -s /full/path/to/Developer/theFolder /Developer/theFolder</code>
+
'''Pay careful attention to remove any reference to 3rd party package managers from 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.
  
'''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.'''
+
It shouldn't be necessary, but it can happen.  
  
== What about 64-bit? ==
+
'''git must still be accessible though!'''
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 ===
+
unset PKG_CONFIG_PATH
The asterix is either 9 or 10 depending on your Mac OS X version. Afterwards, just type make as usual.
+
unset PKG_CONFIG_LIBDIR
 +
export PATH=$PWD/build/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
  
=== Running configure on Mac OS X 10.5 aka Darwin 9 ===
+
== Xcode 'No developer directory' error ==
Do the following <code>./configure CFLAGS="-m64" CXXFLAGS="-m64" LDFLAGS="-m64" OBJCFLAGS="-m64" --host=x86_64-apple-darwin9</code> instead of the regular line. Replacing x86_64 with PPC64 here should work, but is untested.
+
When running <code>xcrun clang</code>, if you see
  
=== Running configure on Mac OS X 10.6 aka Darwin 10 ===
+
Error: No developer directory...
Just <code>./configure --build=x86_64-apple-darwin10</code>. Xcode 3.2.x creates 64bit builds by default.
 
  
== Snow Leopard ==
+
then use xcode-select to select the developer directory within the Xcode package, to point to your xcode developer directory.
A series of problem affect the build under Mac OS X 10.6 (Snow Leopard / darwin 10), these include:
 
  
=== 32-bit builds ===
+
something like:
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: <code>./configure --host=i386-apple-darwin10 CFLAGS="-arch i386" CXXFLAGS="-arch i386" LDFLAGS="-arch i386" OBJCFLAGS="-arch i386"</code>
 
  
=== Missing libiconv.la ===
+
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer 
The <code>/usr/lib/libiconv.la</code> 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 ===
+
== Xcode tooling tries to use SDK in CommandLineTools directory ==
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:
+
Occasionally it has been reported that Xcode tooling tries to compile with an SDK located under the .../Developer/CommandLineTools directory, even if Xcode.app is properly installed and a suitable SDK is available inside the app.
<code>./configure --enable-debug --build=x86_64-apple-darwin10 --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --enable-macosx</code>
 
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 ===
+
This problem might become visible with a similar error like this:
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 <code>--disable-sse --disable-mmx</code> or provide a patch to the LLVM project fixing their compiler.
+
error: SDK "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" cannot be located.
  
== History ==
+
The root cause of this issue is now known yet and likely lies inside the apple provided tooling. One known workaround is to delete or move away the CommandLineTools directory.  
Written by Jean-Alexis Montignies, [[User:Fkuehne|Felix Paul Kühne]] and [[User:The DJ|Derk-Jan Hartman]], for the VideoLAN Team.
 
Adapted to the Wiki by [[User:j-b|Jean-Baptiste Kempf]].
 
  
 
[[Category:Building]]
 
[[Category:Building]]
[[Category:Coding]]
+
[[Category:macOS]]

Latest revision as of 19:20, 17 June 2020

This is an howto to compile VLC media player on macOS (formerly known as Mac OS X), focused on VLC 3.0 and later.

Pre-requisites

Apple Software

Those are the minimum build system requirements to compile VLC 4.0 (current development version). They are also highly recommended to compile VLC 3.0:

  • At least macOS 10.13.4, or any later version
  • At least Xcode 9.3 from developer.apple.com/xcode. (Note: Installing the developer tools package is not needed, and building with that package is not supported)
  • Use at least macOS SDK 10.13 (this is included and the default in Xcode 9.3)
  • Install python3 (macOS pkg installer from python.org)
  • Java 8 JDK (needed to compile Java menu support for blurays)

Compiler test

Ensure the compiler is found correctly by running

xcrun clang

in the Terminal, if this outputs anything else than clang: error: no input files, see the troubleshooting part of this document.

Developer directory test

The Xcode developer directory must be used, not the command line tools developer directory, as only Xcode includes all necessary tools.

Run the following command in Terminal:

xcode-select --print-path

It needs to print out the path to your Xcode installation, like this

/Applications/Xcode.app/Contents/Developer

If it prints out a path to the command line tools package, select the correct path using the xcode-select tool. See here for the correct command.

Get the source code

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

Build VLC with a single command

This is the most simple way to build VLC, including all its necessary dependencies. This way is highly recommended to use, as it sets up everything automatically.

Setup a build folder:

cd vlc && mkdir build && cd build

And run the build:

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

The command line switch -c rebuilds all dependencies (contribs) from source. If you want to use a prebuild contrib package, omit the -c option.

Wait and you have finished.

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

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

In case this fails, please try the step-by-step build guide below using a clean checkout.

Making changes and compile again

Using build.sh is the recommended way to do a fresh VLC build. Now, if you did some changes to the VLC source code, you can try to compile the change by calling build.sh again. But sometimes this is a bit cubersome, as it might take longer, and sometimes its preferred to execute some build commands directly.

For that reason, a script called env.build.sh is included in VLC (starting with VLC 4.0 in vlc.git), which helps you setting the correct environment of your Terminal. The correct environment is needed, to make sure the right internal tools are used for the build process.

Before you compile again with make, just source this script into the current Terminal (pay attention to the dot at the front of the command):

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

You can also create a symlink to that script in a more convenient location, for instance into the main vlc checkout directory:

# change directory to root git checkout
ln -s $PWD/extras/package/macosx/env.build.sh
cd build # go back to your build directory
. ../env.build.sh

Afterwards, in the same terminal, you can recompile by using the usual commands like make:

make
./bin/vlc-osx-static -vv # To test compiled changes

Build steps

Now, if you prefer, you can read the following detailed information on how the build internally works. This section describes all steps which are internally done in build.sh already. Likely, they are only relevant to you if you do not want to use build.sh and env.build.sh.

Additional development tools

You need a number of tools, notably all the autotools, to build VLC correctly. VLC has a way to build the specific versions of these tools required from source, here is how:

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

Important: Add the extras/tools build results to your PATH, before doing anything else:

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

Prepare 3rd party libraries

To compile VLC, you need lots of other libraries, called 3rd party. VLC has the so-called “contribs” system to help building these libraries from source. Alternatively you can use a pre-built package of these libraries provided by VideoLAN.


First, set the correct SDK version for the 3rd party libraries, usually your current OS X Version:

export OSX_VERSION=10.11

Then, prepare the 3rd party library folder:

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

Prebuilt libraries (recommended)

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

make prebuilt

Now you can just skip to the Update PATH section.

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

You need to install the Java JDK, to support java code for libbluray.

If you want to build contribs from source, you first need to make gettext, which is needed for some other contrib libraries to build:

make -j4 .gettext

Now you need to update your path for the gettext tools to be usable later on, see the Update PATH section above.

Then fetch contrib sources:

make fetch

and build them with:

make

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

Update PATH

First we go back to the source directory:

cd ../..

And now we still need to add the contribs to our path, so they can be found:

export PATH=$PWD/contrib/x86_64-apple-darwin15/bin:$PATH

Bootstrap VLC

This will create the configure script:

./bootstrap

Check that there are no obvious errors at this stage, like missing gettext or an error at exit.

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-darwin15 contrib:

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

By default it will not use the installed SDK, like Xcode does, but use System Root. This means that if you built contribs on your own, the configure script might behave unexpectedly, for example enabling functions which are not present in a given operating system version. To work around this and build against the latest installed SDK, you can use:

--with-macosx-sdk=`xcrun --show-sdk-path`

If you want to use a different SDK, you can list all installed SDKs with xcodebuild -showsdks and to get the path for it, you can use the following command xcodebuild -version <SDK Flag from before> Path.
For example: xcodebuild -version -sdk macosx10.11 Path

Build VLC

Just do:

make -j4

and wait...

Run VLC

After make, you can just run VLC like so:

./bin/vlc-osx-static

If you want a VLC app bundle, just do

make VLC.app

And use it like a normal .app bundle.

Package VLC Application for Mac

If you want a disk-image:

make package-macosx

Note: If you want a more fancy disk image, you need the dmgbuild tool, which can be installed using pip install dmgbuild if you have python installed using Homebrew.

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"

Troubleshooting

3rd party packagers and PATH

Pay careful attention to remove any reference to 3rd party package managers from 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

Xcode 'No developer directory' error

When running xcrun clang, if you see

Error: No developer directory...

then use xcode-select to select the developer directory within the Xcode package, to point to your xcode developer directory.

something like:

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

Xcode tooling tries to use SDK in CommandLineTools directory

Occasionally it has been reported that Xcode tooling tries to compile with an SDK located under the .../Developer/CommandLineTools directory, even if Xcode.app is properly installed and a suitable SDK is available inside the app.

This problem might become visible with a similar error like this:

error: SDK "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" cannot be located.

The root cause of this issue is now known yet and likely lies inside the apple provided tooling. One known workaround is to delete or move away the CommandLineTools directory.