# compiling obs: libswscale.a recompile with -fPIC



## Abelardo Mendoza (Apr 30, 2016)

Hey guys,

I'm trying to compile obs-studio on Ubuntu 14.04 LTS and I'm getting this error when running make -j4:


```
/usr/bin/ld: /usr/local/sbin/../lib/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
```

I have manually compiled ffmpeg following this guide (https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) and I compiled all those libraries using --enabled-shared as suggested on this post: Help compiling OBS-Redux.

ffmpeg compiles without any issues using -fPIC --enable-shared and --enable-pic. This is the configure command that I use for ffmpeg:


```
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/cpp/ffmpeg_build/lib/pkgconfig" ./configure \
  --prefix="/usr/local" \
  --pkg-config-flags="--static" \
  --extra-cflags="-fPIC -m64 -I$HOME/cpp/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/cpp/ffmpeg_build/lib" \
  --bindir="$HOME/bin" \
  --enable-gpl \
  --enable-libass \
  --enable-libfdk-aac \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libtheora \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libx265 \
  --enable-nonfree \
  --enable-pic \
  --enable-shared \
  --extra-ldexeflags="-pie"
```

Following the ffmpeg docs I added these flags:

```
--extra-cflags="-fPIC -m64 -I$HOME/cpp/ffmpeg_build/include" \
--extra-ldexeflags="-pie"
--enable-shared
--enable-pic
```

But everytime I try to compile the obs-studio I get:


```
/usr/bin/ld: /usr/local/sbin/../lib/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
make[2]: *** [libobs/libobs.so.0] Error 1
make[1]: *** [libobs/CMakeFiles/libobs.dir/all] Error 2
make: *** [all] Error 2
```

I have attached a full log with the output I get when running make -j4.


----------



## vcorreia (Aug 31, 2017)

Anybody knows how to solve this problem? Using lubuntu/ubuntu and also compiled ffmpeg with --enable-shared and --enable-pic but still having the error:
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

Or at least can someone publish a guide to compile for linux that worked for them (the one on the wiki doesnt work for me)?

Thank you in advance.


----------



## RytoEX (Sep 9, 2017)

The existing compile guides for Linux worked for me on Ubuntu 16.04 and FreeBSD 10+.  Admittedly, I never did much more than testing patches, so I don't recall how much or how little I messed with FFmpeg stuff.


----------

