Difference between revisions of "MacOSCompile"

From VideoLAN Wiki
Jump to navigation Jump to search
Line 50: Line 50:
  cd ../..
  cd ../..
'''Important''': set the new PATH.
'''Important''': set the new PATH, before doing anything else.
  export PATH=$PWD/extras/tools/build/bin:$PATH
  export PATH=$PWD/extras/tools/build/bin:$PATH

Revision as of 12:48, 21 December 2016

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


Apple Software

  • You need at least macOS 10.10. Any later version is strongly recommended, though.
  • Developer Tools from Apple from developer.apple.com/xcode
    You need at least Xcode 7.2.
    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.

Compiler test

You need to check that all is working well.

xcrun clang

If this outputs anything else than 'clang: error: no input files', see the troubleshooting part of this document.

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:


Wait and you have finished.

You can see more options for this build (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.

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 extras/tools
./bootstrap && make
cd ../..

Important: set the new PATH, before doing anything else.

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

Prepare 3rd party libraries

Before compiling VLC, you need lots of other libraries.

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)

Note: In order to build the libraries you need to use an OS X SDK Version lower than 10.12, the 10.12 SDK causes problems making it impossible to use the resulting libraries (and VLC build) on any macOS version lower than 10.12! You can set the SDK Version (if it's installed) using export OSX_VERSION=10.11.

You need to install the Java JDK.

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:


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-darwin11/bin:$PATH

Bootstrap VLC

This will create the configure script:


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...


If you just want to use your own VLC, just do

make VLC.app

And use it like a normal .app bundle.

If you want to develop VLC and avoid recompiling VLC.app all the time during development use

make VLC-dev.app

and run it with

./VLC-dev.app/Contents/MacOS/VLC -vvv

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!

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

Xcode xcrun 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  

Configure the environment

If you have compiling errors, notably if you are not using the latest Xcode (Xcode 8 at the time of the writing of the document), adjust the following part.

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.