Difference between revisions of "MacOSCompile"
(Add test instructions to check that the correct developer directory is selected)
|Line 30:||Line 30:|
If it prints out a path to the command line tools package,
If it prints out a path to the command line tools package, the [https://wiki.videolan.org/OSXCompile/#Xcode_.27No_developer_directory.27_error here] .
= [[GetTheSource|Get the source code]] =
= [[GetTheSource|Get the source code]] =
Revision as of 18:54, 31 May 2018
This is an howto to compile VLC media player on macOS (also known as Mac OS X), focused on VLC 3.0 and later.
- 1 Pre-requisites
- 2 Get the source code
- 3 Build VLC with a single command
- 4 Build steps
- 4.1 Additional development tools
- 4.2 Prepare 3rd party libraries
- 4.3 Bootstrap VLC
- 4.4 Configure the VLC build
- 4.5 Build VLC
- 4.6 Run VLC
- 4.7 Package VLC Application for Mac
- 4.8 Sign VLC Application for Mac
- 5 Troubleshooting
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 officially)
- Use at least macOS SDK 10.13 (this is included and the default in Xcode 9.3)
Ensure the compiler is found correctly by running
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:
It needs to print out the path to your Xcode installation, like this
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.
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:
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):
In case this fails, please try the step-by-step build guide below using a clean checkout.
Now, if you prefer, you can read the following detailed information on how the build internally works:
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:
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:
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.
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:
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.
First we go back to the source directory:
And now we still need to add the contribs to our path, so they can be found:
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:
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:
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.
xcodebuild -version -sdk macosx10.11 Path
make, you can just run VLC like so:
If you want a VLC app bundle, just do
And use it like a normal .app bundle.
Package VLC Application for Mac
If you want a disk-image:
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"
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
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.
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer