0

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.

twid
  • 6,368
  • 4
  • 32
  • 50
Hakeem El Bakka-lee
  • 756
  • 1
  • 7
  • 23

2 Answers2

2

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:

  • --enable-pic

  • --enable-shared

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.

thehennyy
  • 4,020
  • 1
  • 22
  • 31
Justin
  • 663
  • 7
  • 19
0

You have a linkage error, not a compilation error. You haven't run into a bug, you have just attempted a linkage that cannot work.

You are trying to build a shared library libscy_av.so. All the object files that are linked in a shared library must consist of Position Independent Code. To generate such an object file with gcc, you compile with the option -fPIC.

The linker discovers that your shared libary requires the object file options.o, which is a member of the static library libswresample.a. It then discovers that this options.o is not PIC, and so cannot be linked in a shared library. The linkage fails and the linker advises you that options.o must be recompiled with the -fPIC compiler option.

To comply with that advice, you would have to rebuild the static library libswresample.a from source, with -fPIC added to the compiler flags.

You might do that, but it is unusual for object files in a static library to be PIC, and there is an easier option. Your mistake was in linking against the static version of libswresample (libswresample.a) rather than the shared version (libswresample.so), which will be PIC. Just correct that mistake. If you install libswresample.a from a dev package provided by your package manager, then it will also provide libswresample.so. If you have built libswresample from source, then the build system will also build both.

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182