-
Notifications
You must be signed in to change notification settings - Fork 747
Building FFMPEG JavaCPP preset on Ubuntu 16.04
In my attempt to learn and use JavaCPP-Presets (specifically for FFmpeg) and debugging the crashes in my project, I spent a lot of my time on building JavaCPP-Presets and FFmpeg. To ensure no one else faces the same fate as mine, I am preparing this document. It documents the following specific goals only:
- Building JavaCPP
- Building JavaCPP preset for FFMPEG
- Building it all on Ubuntu 16.04
- Supporting
linux-x86_64
platform only
I recommend setting up a private repository (Nexus or Artifactory) The benefits of having a private repository and the steps to setup one, are out of scope of this document, but you can easily find enough material on the web for the same.
On your Ubuntu 16.04 (x86_64) machine:
sudo apt-get update
sudo apt-get -y install --no-install-recommends \
git curl wget openjdk-8-jdk zip unzip \
build-essential pkg-config python automake make cmake \
nasm yasm libxcb1-dev maven
Open ~/.bash_profile
and add the following line
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
then execute
source ~/.bash_profile
This is a prerequisite for building JavaCPP-Presets.
cd ~
git clone https://github.com/bytedeco/javacpp.git --branch master
If you do not want to use
--branch master
, you can always use any of the tags. Just ensure that you checkout the same tag for JavaCPP-Presets too.
Before you start the build, if you have setup your private Maven repository, then edit the
javacpp/pom.xml
and update the snapshot and staging<url>
s under<distributionManagement>
tag, to point to your repository.
cd javacpp
mvn clean install
### or ###
mvn clean install deploy
It is mandatory that the tags of JavaCPP and JavaCPP-Presets match for a correct and stable build.
cd ~
git clone https://github.com/bytedeco/javacpp-presets.git --branch master
To be able to debug FFmpeg, we need to compile it with the following flags/options:
--disable-stripping --enable-debug=3 --extra-cflags="-gstabs+ -I../include/"
Open file ~/javacpp-presets/ffmpeg/cppbuild.sh
and search for the case linux-x86_64)
(since we are supporting linux-x86_64 platform only). Scroll further down and you'll find the line:
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-libxcb --cc="gcc -m64" --extra-cflags="-I../include/" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl"
Update it with the required flags/options as follows:
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-libxcb --cc="gcc -m64" --disable-stripping --enable-debug=3 --extra-cflags="-gstabs+ -I../include/" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl"
cd ~/javacpp-presets
./cppbuild.sh -platform linux-x86_64 install ffmpeg
Comment out the unnecessary modules from the parent POM. Open ~/javacpp-presets/pom.xml
, search for tag <modules>
and comment out all modules except <module>ffmpeg</module>
.
If you have the private Maven repository setup, you should update the
<url>
s under<distributionManagement>
and<repository>
accordingly.
cd ~/javacpp-presets
mvn clean install -Djavacpp.platform=linux-x86_64
### or ###
mvn clean install deploy -Djavacpp.platform=linux-x86_64
Edit ~/javacpp-presets/platform/pom.xml
.
Comment out all <modules>
except <module>../ffmpeg/platform</module>
.
Comment out all <dependencies>
barring
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>${project.version}</version>
</dependency>
and
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>ffmpeg-platform</artifactId>
<version>3.4-${project.version}</version>
</dependency>
Edit ~/javacpp-presets/ffmpeg/platform/pom.xml
Comment out all <dependencies>
barring
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
</dependency>
and
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.linux-x86_64}</classifier>
</dependency>
<Class-Path>${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64.jar</Class-Path>
This step is only required if you are deploying to a private repository.
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<configuration>
<classifier>platform</classifier>
<archive>
<manifestEntries>
<Class-Path>${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
cd ~/javacpp-presets/ffmpeg/platform
mvn install -Djavacpp.platform.host
### or ###
mvn install deploy -Djavacpp.platform.host