janus mac下编译记录

1、首先下载janue源代码:

git clone https://github.com/meetecho/janus-gateway

2、安装依赖项

brew  install  jansson libnice openssl srtp libusrsctp libmicrohttpd \
libwebsockets cmake rabbitmq-c sofia-sip opus libogg curl glib \
libconfig pkg-config gengetopt autoconf automake libtool

#建议安装后再升级下
brew  upgrade  jansson libnice openssl srtp libusrsctp libmicrohttpd \
libwebsockets cmake rabbitmq-c sofia-sip opus libogg curl glib \
libconfig pkg-config gengetopt autoconf automake libtool

3、生成configure文件

./autogen.sh

4、configure

#按照官方指导配置
./configure --prefix=/usr/local/janus \
PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig

但是发现失败:

checking pkg-config is at least version 0.9.0... yes
checking for
                    glib-2.0 >= 2.34
                    libconfig
                    nice
                    jansson >= 2.5
                    libssl >= 1.0.1
                    libcrypto
                  ... no
configure: error: Package requirements (
                    glib-2.0 >= 2.34
                    libconfig
                    nice
                    jansson >= 2.5
                    libssl >= 1.0.1
                    libcrypto
                  ) were not met:

Package 'libffi', required by 'gobject-2.0', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables JANUS_CFLAGS
and JANUS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

从错误提示来看,开始以为是第三方依赖版本不匹配,但是通过分析脚本发现,janus是通过pkg-config匹配依赖项,在执行pkg-config查找libnice路径时发现错误:

xzldeMacBook-Pro:janus-gateway xzl$ pkg-config  nice  --cflags
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libffi', required by 'gobject-2.0', not found

从错误提示看应该是libffi未安装,但是在 brew install 安装时发现已经存在,于是先卸载再安装:

xzldeMacBook-Pro:janus-gateway xzl$  brew uninstall --ignore-dependencies libffi
Uninstalling /usr/local/Cellar/libffi/3.2.1... (16 files, 296.8KB)

xzldeMacBook-Pro:janus-gateway xzl$ brew install libffi
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/libffi-3.2.1.mojave.bottle.tar.gz
Already downloaded: /Users/xzl/Library/Caches/Homebrew/downloads/89b4ef328be250153e7a2b39982ac446e0b3bbfe7f3e2708912ba1976862c302--libffi-3.2.1.mojave.bottle.tar.gz
==> Pouring libffi-3.2.1.mojave.bottle.tar.gz
==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because some formulae require a newer version of libffi.

For compilers to find libffi you may need to set:
  export LDFLAGS="-L/usr/local/opt/libffi/lib"

For pkg-config to find libffi you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/libffi/3.2.1: 16 files, 296.8KB

注意这句提示:

For pkg-config to find libffi you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

所以不难发现 pkg-config默认是找不到libffi的,而libnice依赖libffi,所以我们在查找libnice时应该这样:

export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
pkg-config  nice  --cflags 

所以我们在执行janus的configure脚本时改成这样:

./configure --prefix=/usr/local/janus \
PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig"

然后我们就能配置成功了:

xzldeMacBook-Pro:janus-gateway xzl$ ./configure --prefix=/usr/local/janus \
> PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig"
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking build system type... x86_64-apple-darwin18.0.0
checking host system type... x86_64-apple-darwin18.0.0
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking how to convert x86_64-apple-darwin18.0.0 file names to x86_64-apple-darwin18.0.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin18.0.0 file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin18.0.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for
                    glib-2.0 >= 2.34
                    libconfig
                    nice
                    jansson >= 2.5
                    libssl >= 1.0.1
                    libcrypto
                  ... yes
checking for library containing tls_config_set_ca_mem... no
checking for nice_agent_set_port_range in -lnice... yes
checking for nice_address_equal_no_port in -lnice... yes
checking for dlopen in -ldl... yes
checking for srtp_init in -lsrtp2... yes
checking srtp2/srtp.h usability... yes
checking srtp2/srtp.h presence... yes
checking for srtp2/srtp.h... yes
checking for srtp_crypto_policy_set_aes_gcm_256_16_auth in -lsrtp2... no
configure: libsrtp2 does not have support for AES-GCM profiles
checking for usrsctp_finish in -lusrsctp... yes
checking for libcurl... yes
checking for doxygen... no
checking for dot... no
checking for gengetopt... yes
checking for
                    glib-2.0 >= 2.34
                    jansson >= 2.5
                  ... yes
checking for libmicrohttpd... yes
checking for lws_create_vhost in -lwebsockets... yes
checking for lws_get_peer_simple in -lwebsockets... yes
checking for amqp_error_string2 in -lrabbitmq... yes
checking for MQTTAsync_create in -lpaho-mqtt3a... no
checking for nn_socket in -lnanomsg... no
checking for
                    glib-2.0 >= 2.34
                    jansson >= 2.5
                  ... yes
checking for sofia-sip-ua... yes
checking for libre >= 0.5.7... no
checking for libre... no
checking for opus... yes
checking for ogg... yes
checking for lua... no
checking for lua5.3... no
checking for
                    glib-2.0 >= 2.34
                    jansson >= 2.5
                  ... yes
checking for npm... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating html/Makefile
config.status: creating docs/Makefile
config.status: executing depfiles commands
config.status: executing libtool commands

Compiler:                  gcc
libsrtp version:           2.x
SSL/crypto library:        OpenSSL
DTLS set-timeout:          not available
Mutex implementation:      GMutex (native futex on Linux)
DataChannels support:      yes
Recordings post-processor: no
TURN REST API client:      yes
Doxygen documentation:     no
Transports:
    REST (HTTP/HTTPS):     yes
    WebSockets:            yes
    RabbitMQ:              yes
    MQTT:                  no
    Unix Sockets:          no
    Nanomsg:               no
Plugins:
    Echo Test:             yes
    Streaming:             yes
    Video Call:            yes
    SIP Gateway (Sofia):   yes
    SIP Gateway (libre):   no
    NoSIP (RTP Bridge):    yes
    Audio Bridge:          yes
    Video Room:            yes
    Voice Mail:            yes
    Record&Play:           yes
    Text Room:             yes
    Lua Interpreter:       no
    Duktape Interpreter:   no
Event handlers:
    Sample event handler:  yes
    RabbitMQ event handler:yes
    MQTT event handler:    no
JavaScript modules:        no

If this configuration is ok for you, do a 'make' to start building Janus. A 'make install' will install Janus and its plugins to the specified prefix. Finally, a 'make configs' will install some sample configuration files too (something you'll only want to do the first time, though).

5、编译

make -j4

但是链接openssl库发现链接失败:

Undefined symbols for architecture x86_64:
  "_CRYPTO_THREADID_set_callback", referenced from:
      _janus_dtls_srtp_init in janus-dtls.o
  "_CRYPTO_THREADID_set_pointer", referenced from:
      _janus_dtls_cb_openssl_threadid in janus-dtls.o
  "_CRYPTO_num_locks", referenced from:
      _janus_dtls_srtp_init in janus-dtls.o
  "_CRYPTO_set_locking_callback", referenced from:
      _janus_dtls_srtp_init in janus-dtls.o
  "_ERR_free_strings", referenced from:
      _main in janus-janus.o
  "_EVP_cleanup", referenced from:
      _main in janus-janus.o
  "_OPENSSL_add_all_algorithms_noconf", referenced from:
      _main in janus-janus.o
  "_SSL_library_init", referenced from:
      _main in janus-janus.o
  "_SSL_load_error_strings", referenced from:
      _main in janus-janus.o
  "_SSL_state", referenced from:
      _janus_dtls_srtp_incoming_msg in janus-dtls.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [janus] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

通过执行pkg-config查找openssl库目录:

xzldeMacBook-Pro:janus-gateway xzl$ pkg-config openssl --libs
-L/usr/local/lib -lssl -lcrypto

设置PKG_CONFIG_PATH环境变量后再执行:

xzldeMacBook-Pro:janus-gateway xzl$ export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
xzldeMacBook-Pro:janus-gateway xzl$ pkg-config openssl --libs
-L/usr/local/Cellar/openssl/1.0.2r/lib -lssl -lcrypto

可以发现指向的openssl库不一致,联想到笔者前不仅手动安装过openssl,所以系统默认路径下的openssl库应该是笔者之前手动安装的版本,所以在configure时不需要指定openssl的pkg-config配置文件路径,重新配置一遍再编译即可成功:

./configure --prefix=/usr/local/janus \
PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig" \
&& make -j4

测试是否编译成功:

xzldeMacBook-Pro:janus-gateway xzl$ ./janus --version
Janus commit: d0fecb0b4a4c4dc23b3e0a7038970ba382e66620
Compiled on:  2019? 5? 5? ??? 18?26?32? CST

janus 0.7.0
xzldeMacBook-Pro:janus-gateway xzl$ 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,530评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 86,403评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,120评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,770评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,758评论 5 367
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,649评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,021评论 3 398
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,675评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,931评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,659评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,751评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,410评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,004评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,969评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,203评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,042评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,493评论 2 343