如何在 Mac OS X 上编译 librtmp

How to make librtmp compile on Mac OS X

我正在尝试在 mac 上构建 rtmpdump 和 librtmp,但是我终究无法弄清楚为什么它不起作用。我正在使用自己构建的 openssl:

$ openssl version
OpenSSL 1.1.0-pre3 (alpha) 15 Feb 2016

我已经正确设置了标志(我认为),但是当我尝试编译时我得到了这个:

$ make INC=-I/usr/local/include
gcc -Wall  -I/usr/local/include -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL  -O2 -fPIC   -c -o rtmp.o rtmp.c
In file included from rtmp.c:152:
./handshake.h:120:12: error: variable has incomplete type 'HMAC_CTX' (aka 'struct hmac_ctx_st')
  HMAC_CTX ctx;
           ^
/usr/local/include/openssl/ossl_typ.h:145:16: note: forward declaration of 'struct hmac_ctx_st'
typedef struct hmac_ctx_st HMAC_CTX;
               ^
In file included from rtmp.c:152:
./handshake.h:125:3: warning: implicit declaration of function 'HMAC_CTX_init' is invalid in C99 [-Wimplicit-function-declaration]
  HMAC_setup(ctx, secretKey, 128);
  ^
./handshake.h:72:35: note: expanded from macro 'HMAC_setup'
#define HMAC_setup(ctx, key, len)       HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, key, len, EVP_sha256(), 0)
                                        ^
./handshake.h:127:3: warning: implicit declaration of function 'HMAC_CTX_cleanup' is invalid in C99 [-Wimplicit-function-declaration]
  HMAC_finish(ctx, digest, digestLen);
  ^
./handshake.h:74:67: note: expanded from macro 'HMAC_finish'
#define HMAC_finish(ctx, dig, dlen)     HMAC_Final(&ctx, dig, &dlen); HMAC_CTX_cleanup(&ctx)
                                                                      ^
./handshake.h:269:12: error: variable has incomplete type 'HMAC_CTX' (aka 'struct hmac_ctx_st')
  HMAC_CTX ctx;
           ^
/usr/local/include/openssl/ossl_typ.h:145:16: note: forward declaration of 'struct hmac_ctx_st'
typedef struct hmac_ctx_st HMAC_CTX;
               ^
rtmp.c:192:13: warning: comparison of constant 18446744073709551597 with expression of type 'uint32_t' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
  if (nSize > SIZE_MAX - RTMP_MAX_HEADER_SIZE)
      ~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings and 2 errors generated.
make[1]: *** [rtmp.o] Error 1
make: *** [librtmp/librtmp.a] Error 2

看来这可能是我使用的 OpenSSL 版本的兼容性问题。有谁知道如何解决此类问题,或对 OpenSSL 进行任何更改可能造成的后果?

OpenSSL 1.1.0-pre3 (alpha) 15 Feb 2016...

Does anyone know how to fix this kind of issue, or any changes to OpenSSL that might be responsible?

从广义上讲,OpenSSL 1.1.x 中似乎有两个高级更改导致了大部分问题。首先是对构建系统的更改。其次是对私有 API 的更坚定态度。我认为您看到的是第二个工件,即私有 API。

总的来说,1.1.0-pre3 和 1.1.0-pre4 有很多问题,而且大多无法取得成功 make test。这些问题包括 32 位 OS X PowerMac、64 位 OS X PowerMac、32 位 OS X、64 位 OS X, 32 位 ARM, 64 位 ARM, OpenBSD 5.7, NetBSD 7.0 、Cygwin、CentOS 5、CentOS 7 和 i686。数量如此之多,以至于我已经提交了大约 25 个错误,为即将于 2016 年 3 月 14 日星期一发布的 Beta-1 做准备。

你现在应该避免使用 1.1.0-pre-N,因为它太不稳定了。在 x86_64 Linux 下你应该没问题,但目前其他任何事情都是废话。 Beta-2左右应该可以再捡起来。

从 2016 年 3 月 11 日星期五开始提交后,您可能会得到 Master 的提示。这大致是提交 0d4d5ab 和 4c1cf7e。您可以通过以下方式获取最新信息:

git clone git://git.openssl.org/openssl.git

或者,使用 1.0.2 稳定版。