【问题标题】:How do I install Asterisk on Mavericks?如何在 Mavericks 上安装 Asterisk?
【发布时间】:2014-02-08 04:54:24
【问题描述】:

我正在尝试在运行 Mavericks 的 Macbook Pro(英特尔酷睿 i5)上安装 Asterisk。理想情况下,我想安装 1.8 版,因为这是在服务器上运行的,但 11.7 也可以。

在谷歌搜索之后,我尝试了许多配置标志的排列,但这种策略并没有让我得到任何结果。

我有 Xcode 5.0.2。并安装了命令行工具,以及通过 Homebrew 安装的 gcc-4.8:

brew tap homebrew/versions
brew install homebrew/versions/gcc48

根据我在this homebrew formula 中看到的内容,我尝试将OPTIMIZE=-O6 替换为OPTIMIZE=-Os。这似乎和CFLAGS=-mtune=generic的效果一样,即防止这个错误:

Generating embedded module rules ...
  [CC] chan_agent.c -> chan_agent.o
   error: invalid value '6' in '-O6'

我使用的另一个选项是--without-netsnmp,正如建议的here,因为该模块在制作过程中也抛出了错误。

我也尝试使用选项--host=x86_64-darwin。我尝试使用默认编译器和CC=gcc-4.8

按照here 的建议,我尝试了makemake -j 4

两个输出示例(使用 11.7 版):

./configure --host=x86_64-darwin CC=gcc-4.8 CFLAGS=-mtune=generic
make -j 4
...
[CC] enum.c -> enum.o
enum.c: In function 'blr_txt':
enum.c:225:41: error: 'C_IN' undeclared (first use in this function)
ret = ast_search_dns(&context, domain, C_IN, T_TXT, txt_callback);

使用 Os 代替 O6

./configure  --without-netsnmp
make
...
duplicate symbol _ast_tech_to_upper in:
chan_iax2.o
iax2-provision.o
duplicate symbol _ast_rq_is_int in:
chan_iax2.o
iax2-provision.o
ld: 90 duplicate symbols for architecture x86_64

我要么需要真正了解发生了什么,要么需要一个“神奇”的解决方案。

【问题讨论】:

  • 为什么在 maveric 上需要它?这是高度实验性且不受支持的设置。如果您需要在笔记本电脑上运行虚拟化,请使用虚拟化(但无论如何在笔记本电脑上运行 voip 服务器是个坏主意)。
  • @arheops 用于开发目的。我宁愿避免增加虚拟机的复杂性,但这可能是最好的解决方案。

标签: gcc clang homebrew asterisk osx-mavericks


【解决方案1】:

Asterisk 开发者社区和 Digium 的许多开发者都使用 Mac 进行开发。其中一位 David Lee 将他的一些 Homebrew 公式放在了 GitHub 上。它们可能有助于解决您遇到的各种问题。

https://github.com/leedm777/homebrew-asterisk

【讨论】:

  • 这很棒。我能够以这种方式安装 Asterisk 版本 12。现在我只需要弄清楚安装后如何正确运行它。
【解决方案2】:

我在 OS X(10.9,Mavericks)上编译并运行了 asterisk 1.8。

完成以下步骤:

首先根据llvm documentation使源码兼容clang。 如果您有兴趣,请查看“C99 内联函数”部分。

“事物”是 clang 期望内联函数定义的方式。

打开文件:

包括/星号/inline_api.h

找到以下块:

#if !defined(AST_API_MODULE)
#define AST_INLINE_API(hdr, body) hdr; extern inline hdr body
#else
#define AST_INLINE_API(hdr, body) hdr; hdr body
#endif

比改变这一行

#define AST_INLINE_API(hdr, body) hdr; extern inline HDR body

#define AST_INLINE_API(hdr, body) static inline hdr; static inline HDR body

然后打开主 Makefile 并更改以下行

  SOLINK=-bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace

  SOLINK=-bundle -Xlinker -macosx_version_min -Xlinker 10.9 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace

在 main/Makefile 中做同样的事情并改变

  ASTLINK=-Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace

  ASTLINK=-Xlinker -macosx_version_min -Xlinker 10.9 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace

如果让 asterisk 使用 macosx_version_min=10.4 编译,编译后的二进制文件将无法启动并抛出“非法指令 4”

终于运行了

make

如果你激活了 SNMP 模块,你会在编译时得到另一个错误:

snmp/agent.c:841:43:错误:使用未声明的标识符“RONLY”

这是因为 OS X 需要“现代”SNMP API,因此 /usr/include/net-snmp/library/snmp_impl.h 中的这个块永远不会被编译:

#ifndef NETSNMP_NO_LEGACY_DEFINITIONS
#define RONLY           NETSNMP_OLDAPI_RONLY
#define RWRITE          NETSNMP_OLDAPI_RWRITE
#define NOACCESS        NETSNMP_OLDAPI_NOACCESS
#endif

我刚刚通过编辑 res/snmp/agent.c 解决了这个问题

我只是把 RONLY 的定义放在 SNMP 的后面:

#include <net-snmp/net-snmp-includes.h>
#define RONLY           NETSNMP_OLDAPI_RONLY

然后再次运行make。那应该做的工作。

【讨论】:

  • 顺便说一句,只需安装 Xcode 和命令行工具即可完全工作。不需要第三方的东西。
【解决方案3】:

我可以通过 Homebrew 构建并启动 Asterisk 15 w/g729 编解码器

  • 星号 15.1.5 + bcg729
  • Mac OS X High Sierra v10.13.4
  • Mac mini(2012 年末)2.5GHz Intel Core i5 16GB DDR3

以下是 Asterisk 15 w/bcg729 在 Mac OS X High Sierra v10.13.4 上的安装步骤

  1. brew 期间 asterisk.rb 和 pjsip-asterisk.rb 中的小问题
  2. 更改 brew 建议的“

-

#Homebrew
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"    

#git, mercurial
brew install git mercurial

#asterisk
brew tap leedm777/homebrew-asterisk
brew install asterisk

#bcg729
/usr/local/bin/git clone git://git.linphone.org/bcg729.git
cd bcg729
git checkout 1.0.2
LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include CPPFLAGS=-I/usr/local/include ./configure --prefix=/usr/local
make
make install

#asterisk-g729
/usr/local/bin/hg clone http://bitbucket.org/arkadi/asterisk-g72x
cd asterisk-g72x
./autogen.sh 
LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include CPPFLAGS=-I/usr/local/include ./configure --prefix=/usr/local --with-bcg729 --with-asterisk150
make
make install

#start asterisk
brew services start leedm777/asterisk/asterisk

以下是 Mac OS X Yosemite v10.10.3 上的 Asterisk 13.4.0

通过 macports 安装 GCC4.8 并选择它。这个星号构建应该有其他依赖项。我可以在 macport 中为他们找到所有内容

sudo port install gcc48
sudo port select gcc mp-gcc48

下载当前的星号版本 13,配置和制作

tar zxf asterisk-13-current.tar.gz 
cd asterisk-13.4.0/
LDFLAGS=-L/opt/local/lib CFLAGS=-I/opt/local/include CPPFLAGS=-I/opt/local/include ./configure --without-netsnmp --without-gtk2 --prefix=/opt/local
make
sudo make install
sudo make samples

下面是G.729 codec support for Asterisk 使用bcg729

tar zxf bcg729-1.0.0.tar.gz 
cd bcg729-1.0.0
LDFLAGS=-L/opt/local/lib CFLAGS=-I/opt/local/include CPPFLAGS=-I/opt/local/include ./configure --prefix=/opt/local
make
sudo make install

tar jxf asterisk-g72x-1.3.tar.bz2 
cd asterisk-g72x-1.3
./autogen.sh
LDFLAGS=-L/opt/local/lib CFLAGS=-I/opt/local/include CPPFLAGS=-I/opt/local/include ./configure --prefix=/opt/local --enable-core2 --with-bcg729 --with-asterisk130
make
sudo make install

要运行星号,只需键入

sudo asterisk

通过创建文件添加到 LaunchDaemon “/Library/LaunchDaemons/org.asterisk.asterisk.plist” 在启动时自动启动星号

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version='1.0'>
<dict>
<key>Label</key><string>org.asterisk.asterisk.plist</string>
<key>ProgramArguments</key>
<array>
    <string>/opt/local/sbin/asterisk</string>
</array>
<key>Debug</key><false/>
<key>Disabled</key><true/>
<key>KeepAlive</key><true/>
</dict>
</plist>

并通过创建文件添加到 LaunchDaemon “/库/LaunchDaemons/limit.maxfiles.plist” 确保 maxfiles 设置正确

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
    <string>limit.maxfiles</string>
  <key>ProgramArguments</key>
    <array>
      <string>launchctl</string>
      <string>limit</string>
      <string>maxfiles</string>
      <string>65536</string>
      <string>65536</string>
    </array>
  <key>RunAtLoad</key>
    <true/>
  <key>ServiceIPC</key>
    <false/>
</dict>
</plist>

并通过创建文件添加到 LaunchDaemon “/库/LaunchDaemons/limit.maxproc.plist” 确保 maxprco 设置正确

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
    <string>limit.maxproc</string>
  <key>ProgramArguments</key>
    <array>
      <string>launchctl</string>
      <string>limit</string>
      <string>maxproc</string>
      <string>2500</string>
      <string>2500</string>
    </array>
  <key>RunAtLoad</key>
    <true />
  <key>ServiceIPC</key>
    <false />
</dict>
</plist>

要使星号在启动时运行,请运行

cd /Library/LaunchDaemons
sudo launchctl load -w org.asterisk.asterisk.plist
sudo launchctl load -w limit.maxfiles.plist
sudo launchctl load -w limit.maxproc.plist

asterisk start 后总是可以通过命令连接到asterisk 服务器

sudo asterisk -r

或更详细

sudo asterisk -rvvvv

【讨论】:

    【解决方案4】:

    我按照以下步骤在 OSX 10.9.5 (13F34) 上安装并运行了 Asterisk 12.0:

    如下安装自制软件和软件包:

    $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    $ brew doctor
    $ brew tap leedm777/asterisk
    $ brew tap homebrew/versions
    $ brew install pjsip iksemel unixodbc srtp gcc48 sqlite openssl speex
    

    转到未解压的星号目录。

    $ ./configure CC=gcc-4.8 CXX=g++-4.8 --with-ssl=/usr/local/opt/openssl --with-sqlite3=/usr/local/opt/sqlite --without-netsnmp --with-unixodbc=/usr/local/opt/unixodbc --without-gtk2 --prefix=/opt/Asterisk
    $ make
    $ make install
    $ make samples
    

    【讨论】:

      【解决方案5】:

      我已经在 OS X 10.9 Mavericks 和 10.10 Yosemite 上成功构建并使用了 Asterisk 12.x。虽然我最初尝试使用https://github.com/leedm777/homebrew-asterisk,但它对我不起作用,所以我最终使用MacPorts 安装了先决条件,并使用gcc4.8 从源代码编译,只对configure 的调用进行了一些小的修改。我一直在向brew 公式提交反馈,希望它变得足够稳定以适用于大多数人。总而言之,我不会在这里讨论这个过程(尽管当我有正确的公开记录时我可能会链接到它)因为那是针对 Asterisk 12,而不是 Asterisk 11。

      我还试图让 Asterisk 11 在 OS X 10.9 Mavericks 上正常运行,但在编译 Asterisk 11.15.0 时遇到了同样的错误:

      [CC] enum.c -> enum.o
      enum.c: In function 'blr_txt':
      enum.c:225:41: error: 'C_IN' undeclared (first use in this function)
      ret = ast_search_dns(&context, domain, C_IN, T_TXT, txt_callback);
      

      经过一番挖掘,我发现'C_IN' undeclared 错误的原因是main/enum.cmain/srv.c 仅在OS X 上包含arpa/nameser_compat.h,如果您使用Apple 版本的cc,但是我们正在使用 GCC。因此,您需要修补这些文件以删除该要求,如下面的差异所示:

       #ifdef __APPLE__
      -#if __APPLE_CC__ >= 1495
      +//#if __APPLE_CC__ >= 1495
       #include <arpa/nameser_compat.h>
      -#endif
      +//#endif
       #endif
      

      虽然上述修复将允许成功编译,但您会遇到“非法指令:4”运行时错误,除非您更新链接器使用的最低 OS X 版本。您可以轻松修改Makefilemain/Makefile如下:

      sed -i .original 's|-Xlinker 10\.4|-Xlinker 10.9|' Makefile
      sed -i .original 's|-Xlinker 10\.4|-Xlinker 10.9|' main/Makefile
      

      这些更改使我能够在 OS X 10.9 Mavericks 上编译和安装 Asterisk 11.15.0 和 11.16.0。

      【讨论】:

        猜你喜欢
        • 2014-07-08
        • 2014-10-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-28
        • 2014-04-15
        • 1970-01-01
        相关资源
        最近更新 更多