I am building a system to use OBS on Linux. It is a brand new install of Linux Mint V18.3 Mate 64Bit. The uname -a is : Linux Liberty01 4.10.0-38-generic #42~16.04.1-Ubuntu SMP Tue Oct 10 16:32:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux. I am trying to take advantage of the MSI GeForce GTX 1050 hardware.
I have followed a number of forum threads on how to accelerate FFMPEG by building a version to take advantage of NVENC. Many trial and errors with old info that required patching the code. As I understand it now, ffmpeg has everything it needs to use NVENC. You just need to configure it (--enable-nvenc) and then build it. I am using a minimal configuration to keep things simple. I will add more libraries later when I get this working. Here is what I did to build ffmpeg:
## First I installed the tools needed for everything.
sudo apt-get install yasm build-essential automake autoconf libtool pkg-config cmake git-core checkinstall
## I did install all the libraries called for by the various recipes but I probably won't use them right away.
sudo apt-get install libx11-dev libgl1-mesa-dev libvlc-dev libpulse-dev libxcomposite-dev \
libxinerama-dev libv4l-dev libudev-dev libfreetype6-dev \
libfontconfig-dev qtbase5-dev libqt5x11extras5-dev libx264-dev \
libxcb-xinerama0-dev libxcb-shm0-dev libjack-jackd2-dev libcurl4-openssl-dev
## I created a directory to put this project in.
mkdir Development
cd Development
## I cloned a copy of the FFMPEG source code.
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg/
## I didn't want the latest untested stuff so I specifically called for the latest release. I am not a git expert, so this step may have been unnecessary.
git checkout tags/n3.4.2
## I made a build directory, jumped in, and configured ffmpeg with what I figured was minimal.
mkdir ffmpeg_build
cd ffmpeg_build
../ffmpeg/configure --prefix=/usr --extra-version=2 --toolchain=hardened \
--libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu \
--enable-shared \
--enable-gpl \
--enable-nonfree \
--enable-nvenc
## I then built ffmpeg and installed it. Yeah, it is a little 4 core i5.
make -j 4
sudo checkinstall --pkgname=FFmpeg
## Everything worked great. I listed the encoders and Nvida was there.
## So I just used your OBS build recipe.
cd ..
git clone --recursive https://github.com/jp9000/obs-studio.git
cd obs-studio
mkdir build && cd build
cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
This is where everything keeps getting stuck.
[ 32%] Building C object libobs/CMakeFiles/libobs.dir/audio-monitoring/pulse/pulseaudio-output.c.o
[ 32%] Linking C shared library libobs.so
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libswscale.a(swscale.o): relocation R_X86_64_PC32 against symbol `ff_M24A' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
libobs/CMakeFiles/libobs.dir/build.make:2002: recipe for target 'libobs/libobs.so.0' failed
make[2]: *** [libobs/libobs.so.0] Error 1
CMakeFiles/Makefile2:451: recipe for target 'libobs/CMakeFiles/libobs.dir/all' failed
make[1]: *** [libobs/CMakeFiles/libobs.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
I did try and add --enable-pic to the ffmpeg build and -DCMAKE_C_FLAGS="-fPIC" to the OBS build and I still got the same error. It obviously looks like a linker error but where did it start? I was a good C\C++ coder back in the 80s-90s then switched to Java. Most of this would take a lot of digging for me. I was just hoping that this was a common error and someone would know what it was right away. Help??
I have followed a number of forum threads on how to accelerate FFMPEG by building a version to take advantage of NVENC. Many trial and errors with old info that required patching the code. As I understand it now, ffmpeg has everything it needs to use NVENC. You just need to configure it (--enable-nvenc) and then build it. I am using a minimal configuration to keep things simple. I will add more libraries later when I get this working. Here is what I did to build ffmpeg:
## First I installed the tools needed for everything.
sudo apt-get install yasm build-essential automake autoconf libtool pkg-config cmake git-core checkinstall
## I did install all the libraries called for by the various recipes but I probably won't use them right away.
sudo apt-get install libx11-dev libgl1-mesa-dev libvlc-dev libpulse-dev libxcomposite-dev \
libxinerama-dev libv4l-dev libudev-dev libfreetype6-dev \
libfontconfig-dev qtbase5-dev libqt5x11extras5-dev libx264-dev \
libxcb-xinerama0-dev libxcb-shm0-dev libjack-jackd2-dev libcurl4-openssl-dev
## I created a directory to put this project in.
mkdir Development
cd Development
## I cloned a copy of the FFMPEG source code.
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg/
## I didn't want the latest untested stuff so I specifically called for the latest release. I am not a git expert, so this step may have been unnecessary.
git checkout tags/n3.4.2
## I made a build directory, jumped in, and configured ffmpeg with what I figured was minimal.
mkdir ffmpeg_build
cd ffmpeg_build
../ffmpeg/configure --prefix=/usr --extra-version=2 --toolchain=hardened \
--libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu \
--enable-shared \
--enable-gpl \
--enable-nonfree \
--enable-nvenc
## I then built ffmpeg and installed it. Yeah, it is a little 4 core i5.
make -j 4
sudo checkinstall --pkgname=FFmpeg
## Everything worked great. I listed the encoders and Nvida was there.
## So I just used your OBS build recipe.
cd ..
git clone --recursive https://github.com/jp9000/obs-studio.git
cd obs-studio
mkdir build && cd build
cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
This is where everything keeps getting stuck.
[ 32%] Building C object libobs/CMakeFiles/libobs.dir/audio-monitoring/pulse/pulseaudio-output.c.o
[ 32%] Linking C shared library libobs.so
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libswscale.a(swscale.o): relocation R_X86_64_PC32 against symbol `ff_M24A' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
libobs/CMakeFiles/libobs.dir/build.make:2002: recipe for target 'libobs/libobs.so.0' failed
make[2]: *** [libobs/libobs.so.0] Error 1
CMakeFiles/Makefile2:451: recipe for target 'libobs/CMakeFiles/libobs.dir/all' failed
make[1]: *** [libobs/CMakeFiles/libobs.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
I did try and add --enable-pic to the ffmpeg build and -DCMAKE_C_FLAGS="-fPIC" to the OBS build and I still got the same error. It obviously looks like a linker error but where did it start? I was a good C\C++ coder back in the 80s-90s then switched to Java. Most of this would take a lot of digging for me. I was just hoping that this was a common error and someone would know what it was right away. Help??