0

我正在尝试运行 LibSourcey 以使用 Webrtc 流服务器。

问题是我似乎无法让它工作。我努力在我的 Ubuntu 16.04(cmake 文件中的正则表达式)上 cmake 项目,但现在它已修复。我实际遇到的问题是编译时的共享对象错误:

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

任何帮助将不胜感激,因为我现在不知道该怎么做。

4

2 回答 2

2

我遇到了同样的错误Ubuntu 16.04

我最终使用标志重新编译 FFmpeg 来构建共​​享库。在FFmpeg Compilation Guide中的代码示例框之后,我在适用的 ./configure 行中添加了以下两个标志:

  • --启用图片

  • --启用共享

我也删除了--disable-shared标志。

我在每个组件中添加了--enable-picand--enable-shared并删除了该标志,如果它返回一条无法识别该组件的消息。至少需要 libx264、libfdk-acc 和 libmp3lame --enable-shared。然后是最终的 FFmpeg(从上面链接的 FFmpeg 指南复制并粘贴):

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

请注意,我示例中的最后两行与 FFmpeg 指南不同。

完成所有这些之后,最好删除 Libsourcey 源和构建文件夹并重新开始。

我花了大约 4-5 天的时间才最终编译并成功构建了具有 FFmpeg 和 WebRTC 依赖项的 Libsourcey。我也遇到了一些其他问题,所以如果您有其他问题,请务必标记我。注意:我是 Linux 构建的菜鸟,对所有概念都不是很了解;这正是对我有用的方法,也许它对你有用。

于 2017-08-09T05:00:35.430 回答
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.

于 2017-07-18T18:51:34.310 回答