由于缺少库arc4random而导致的构建错误

Ome*_*001 9 c++ cygwin ffmpeg shared-libraries static-libraries

我目前正在研究Streaming框架,并决定使用ffmpeg对我的视频和/或音频进行编码和解码.

所以我通过https://ffmpeg.org点击了api文件,并下载了静态链接版本,但发现它实际上包含了一个.exe(我在开发中使用Windows,但计划在生产中使用Linux)而不是一个或更多dll和标题信息.

因为我不认为我可以使用'exe'替代dll,我克隆了git源代码,并尝试自己编译它.

然后,在编译时遇到此错误:

CC  libavutil/random_seed.o
libavutil/random_seed.c: In function 'av_get_random_seed':
libavutil/random_seed.c:130:12: error: implicit declaration of function 'arc4random' [-Werror=implicit-function-declaration]
     return arc4random();
            ^
cc1: some warnings being treated as errors
common.mak:60: recipe for target 'libavutil/random_seed.o' failed
make: *** [libavutil/random_seed.o] Error 1
Run Code Online (Sandbox Code Playgroud)

据我所知,这意味着我错过了库arc4random,所以我开始搜索这个库,并且发现绝对没有任何东西,除了这个库与Apple有关的事实......,但没有dll和东西或者我自己编译的来源.

我使用cygwin及其GCC在64位Windows 7机器上编译.

任何人都可以提示我到某个地方我可以得到这个丢失的库,或者其他一些可能将ffmpeg作为库进入我的项目吗?(我更喜欢静态链接的东西,因为这个项目本身就是一个lib)

也许有一种方法我可以利用ffmpeg下载的exe,因为我可以从我从Git克隆的源中借用它的头文件?

任何提示都表示赞赏.

最好的祝福,

简尼克亚当

Mat*_*hew 7

这似乎是由于#if错误地报告系统具有此功能而引起的.我能够通过编辑几个文件来绕过它.

打开libavutil/random_seed.c并查找#if HAVE_ARC4RANDOM,应该在第129行附近,并删除该三行的块:

129 #if HAVE_ARC4RANDOM
130     return arc4random();
131 #endif
Run Code Online (Sandbox Code Playgroud)

当你再次运行make时,你可能会在time.c中获得另一个类似的失败,因为gettimeofday(),所以打开libavutil/time.c并查找#if HAVE_GETTIMEOFDAY哪个应该在第41行附近并删除那里的第一个块,如下所示:

更改前:

41 #if HAVE_GETTIMEOFDAY
42     struct timeval tv;
43     gettimeofday(&tv, NULL);
44     return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
45 #elif HAVE_GETSYSTEMTIMEASFILETIME
Run Code Online (Sandbox Code Playgroud)

更改后:

41 #if HAVE_GETSYSTEMTIMEASFILETIME
Run Code Online (Sandbox Code Playgroud)

在这两个更改之后,编译得到了更多,但在ffserver.c上失败了:

ffserver.c: In function ‘main’:
ffserver.c:4000:5: error: implicit declaration of function ‘sigaction’ [-Werror=implicit-function-declaration]
     sigaction(SIGCHLD, &sigact, 0);
Run Code Online (Sandbox Code Playgroud)

为了解决这个错误,我打开了config.mak并添加-D_XOPEN_SOURCE=700到CFLAGS的末尾,如下所示:

42 CFLAGS=   -std=c99 -fomit-frame-pointer -pthread  -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -O3 -fno-math-errno -fno-signed-zeros -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -fdiagnostics-color=auto -Wno-maybe-uninitialized -D_XOPEN_SOURCE=700
Run Code Online (Sandbox Code Playgroud)

这篇文章解释了为什么有-D_XOPEN_SOURCE=700帮助.

然后我又跑make了,终于成功了.运行后make install所有的二进制文件都已到位,我能够成功使用它!