天天看點

MAC下build Janus

Janus核心是WebRTC的“gateway”,它是用C語言實作并且是在libsrtp和libnice之上開發的,通過添加各種插件,可以實作不同的功能或用例,例如SFU。官網:https://janus.conf.meetecho.com/

在Mac下安裝janus

按照

https://gist.github.com/anild...點選預覽

來安裝

安裝流程:

brew install jansson libnice openssl libusrsctp libmicrohttpd libwebsockets cmake rabbitmq-c sofia-sip opus libogg glib pkg-config gengetopt ffmpeg

curl https://codeload.github.com/cisco/libsrtp/tar.gz/v2.2.0 > libsrtp-2.2.0.tar.gz 
tar xvf libsrtp-2.2.0.tar.gz 
cd libsrtp-2.2.0
./configure --prefix=/usr/local --enable-openssl PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
make shared_library && sudo make install

git clone [email protected]:meetecho/janus-gateway.git
cd janus-gateway
sh autogen.sh
./configure --prefix=/usr/local/janus --enable-post-processing PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
make
sudo make install 
sudo make configs
           

在安裝編譯的時候,有以下幾個報錯,記錄以下:

1.sh autogen.sh的時候報錯

autogen.sh: line 8: autoreconf: command not found
           

查找原因,是因為沒有安裝某些工具,解決方法:

brew install autoconf
           

繼續執行sh autogen.sh,報錯

autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4 --output=aclocal.m4t
Can't exec "aclocal": No such file or directory at /usr/local/Cellar/autoconf/2.69/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory
           

這是需要install一個automake,執行指令:

brew install automake
           

安裝完automake以後,繼續執行autogen.sh,還是有報錯:

autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/local/Cellar/autoconf/2.69/bin/autoconf --force
configure.ac:6: error: possibly undefined macro: AC_ENABLE_SHARED
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:7: error: possibly undefined macro: AC_ENABLE_STATIC
autoreconf: /usr/local/Cellar/autoconf/2.69/bin/autoconf failed with exit status: 1
           

看報錯資訊,看樣子還需要安裝Libtool,那就安裝:

brew install Libtool
           

好了,繼續下一步:

./configure --prefix=/usr/local/janus --enable-post-processing PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
           

又有報錯:

configure: error: cannot find install-sh, install.sh, or shtool in . "."/.
           

google一下,有人已經提出了:

The problem won't go away by just installing automake/autoconf/libtool. One also needs to run 'autoreconf -i' before rerunning ./configure - it will install the missing files that ./configure is complaining about.

就是說安裝這些庫并不能解決這個問題,還要執行一次autoreconf -i

autoreconf -i
           

很順利,然後繼續執行

./configure --prefix=/usr/local/janus --enable-post-processing PKG_CONFIG_PATH=/usr/local/opt/openssl/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-darwin17.7.0
checking host system type... x86_64-apple-darwin17.7.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... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/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-darwin17.7.0 file names to x86_64-apple-darwin17.7.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin17.7.0 file names to toolchain format... func_convert_file_noop
checking for /Library/Developer/CommandLineTools/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 (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin17.7.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
                  ... no
configure: error: Package requirements (
                    glib-2.0 >= 2.34
                    libconfig
                    nice
                    jansson >= 2.5
                    libssl >= 1.0.1
                    libcrypto
                  ) were not met:

No package 'libconfig' 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.
           

發現還是有報錯的,看起來是沒安裝這些依賴,但是brew install的時候卻提示全都安裝過了,經過分析腳本發現:janus是通過pkg-config比對依賴項,在執行pkg-config查找libconfig路徑時發現錯誤,于是需要改變一下路徑:

./configure --prefix=/usr/local/janus --enable-post-processing PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig
           

接下來就很順利了,make以後,測試janus是否安裝成功

./janus --version
           

如果成功,就會出現:

Janus commit: eb703e1a53360a7f967e4d969dec957a7249e134
Compiled on:  2019? 9? 1? ??? 11?13?03? CST

janus 0.7.4