shared-librarieswebrtcfpiclibsourcey

Libsourcey missing -fPIC compilation error


I'am trying to run the LibSourcey to use the Webrtc Streaming Server.

The thing is that i can't seem to make it work. I struggled to cmake the project on my Ubuntu 16.04(Regexp in cmake files) but now its fixed . The problem that i actually got is a shared object bug at compiling time :

usr/bin/ld: /home/kimmie/ffmpeg_build/lib/libswresample.a(options.o): 
relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; 
recompile with -fPIC

/home/kimmie/ffmpeg_build/lib/libswresample.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

av/CMakeFiles/av.dir/build.make:783: recipe for target 'av/libscy_av.so.1.0.2' failed

Any help would be very much appreciated as i don't know what to do now.


Solution

  • I hit this same error on Ubuntu 16.04.

    I ended up recompiling FFmpeg with flags to build the shared libraries. Following the code example boxes in the FFmpeg Compilation Guide, I added the following two flags to the ./configure lines where applicable:

    I removed the --disable-shared flags as well.

    I added --enable-pic and --enable-shared to every component and removed the flag if it returned a message that it was unrecognized for that component. At least libx264, libfdk-acc, and libmp3lame needed --enable-shared. And then for the final FFmpeg (copy and pasted from FFmpeg guide linked to above):

    PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
     --prefix="$HOME/ffmpeg_build" \
     --pkg-config-flags="--static" \
     --extra-cflags="-I$HOME/ffmpeg_build/include" \
     --extra-ldflags="-L$HOME/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
    

    Note the last two lines in my example are different than the FFmpeg guide.

    After you do all of that, it's probably best to delete the Libsourcey source and build folder and start over with that.

    It took me about 4-5 days off and on to finally compile and successfully build Libsourcey with FFmpeg and WebRTC dependencies. I hit some other snags as well, so be sure to tag me if you have other questions. Note: I am noob at Linux building and not solid on all of the concepts; this is just what worked for me and perhaps it will work for you.