4
votes

I'm trying to install Asterisk on my Macbook Pro (Intel Core i5) running Mavericks. Ideally I want to install version 1.8, because that's what's running on the server, but 11.7 is fine too.

After googling around I've tried many permutations of configure flags, but that strategy is not getting me anywhere.

I have Xcode 5.0.2. and the command line tools installed, as well as gcc-4.8 via Homebrew:

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

Based on what I saw in this homebrew formula I tried replacing OPTIMIZE=-O6 with OPTIMIZE=-Os. This seems to have the same effect as CFLAGS=-mtune=generic, namely preventing this error:

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

The other option I'm using is --without-netsnmp as suggested here because that module was throwing errors during the make process as well.

I also tried using the option , --host=x86_64-darwin. I tried both with the default compiler and with CC=gcc-4.8.

I tried both make and make -j 4, as suggested here.

Two examples of output (using version 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);

Using Os instead of 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

I'll either need actually understand what's going on or a "magic" solution.

5
Why you need that on maveric? That is highly experemental and unsupported setup. Use virtualization if you need it run on your laptop(but anyway run voip server on laptop is bad idea).arheops
@arheops it's for development purposes. I would prefer to avoid the added complexity of a virtual machine, but that's probably the best solution.Sjors Provoost

5 Answers

4
votes

A number of developers both in the Asterisk Developer community as well as at Digium use Macs for development. One of them, David Lee, has put a number of his Homebrew formulas up on GitHub. They might be helpful in working through the various issues you're running into.

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

2
votes

I got asterisk 1.8 on OS X (10.9, Mavericks) compiled and running.

Complete the following steps:

First make the source code compatible to clang according to the llvm documentation. If you are interested have a look to the "C99 inline functions" section.

The "thing" is how clang expects inline function definition.

Open the file:

include/asterisk/inline_api.h

find the following block:

#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

than change this line

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

to

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

then open the main Makefile and change the following line

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

to

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

do the same in main/Makefile and change

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

to

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

If you let asterisk compile with macosx_version_min=10.4 the compiled binary won't start and throw an "illegal instruction 4"

finally run

make

If you have got the SNMP module activated you'll get another error while compiling:

snmp/agent.c:841:43: error: use of undeclared identifier 'RONLY'

This is, because OS X expects the 'modern' SNMP API and so this block in /usr/include/net-snmp/library/snmp_impl.h gets never compiled:

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

I just worked around this by editing res/snmp/agent.c

I just put the definition for RONLY right after the SNMP includes:

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

then run make again. That should do the job.

2
votes

I am able to build via Homebrew and start Asterisk 15 w/g729 codec on

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

Below are the installation steps for Asterisk 15 w/bcg729 on Mac OS X High Sierra v10.13.4

  1. minor issues in asterisk.rb and pjsip-asterisk.rb during brew
  2. change "<<-EOS.undent" to "<<~EOS" as suggest by brew solve the problem

-

#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

Below is for Asterisk 13.4.0 on Mac OS X Yosemite v10.10.3

Install GCC4.8 via macports and select it. There should be other dependencies for this asterisk build. I can found all for them within macport

sudo port install gcc48
sudo port select gcc mp-gcc48

Download current asterisk version 13, configure and make

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

Below is for G.729 codec support for Asterisk using 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

To run asterisk just type

sudo asterisk

Add to LaunchDaemon by creating file "/Library/LaunchDaemons/org.asterisk.asterisk.plist" to start asterisk automatically on startup

<?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>

And add to LaunchDaemon by creating file "/Library/LaunchDaemons/limit.maxfiles.plist" to ensure maxfiles is set correctly

<?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>

And add to LaunchDaemon by creating file "/Library/LaunchDaemons/limit.maxproc.plist" to ensure maxprco is set correctly

<?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>

To make the asterisk running at startup, run

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

After asterisk start can always connect to asterisk server via command

sudo asterisk -r

or more verbose

sudo asterisk -rvvvv
0
votes

I got Asterisk 12.0 installed & running on OSX 10.9.5 (13F34) by following these steps:

Install homebrew & packages as below:

$ 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

Go to untarred asterisk directory.

$ ./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
0
votes

I have successfully built and am using Asterisk 12.x on OS X 10.9 Mavericks & 10.10 Yosemite. While I initially tried using https://github.com/leedm777/homebrew-asterisk, it didn't work for me, so I ended up installing prerequisites using MacPorts and compiling from source using gcc4.8 with only some minor modifications to the call to configure. I have been submitting feedback back to that brew formula in the hopes that it becomes stable enough to work for most. That all said, I won't go over that process here (though I may link to it when I have it properly & publicly documented) as that was for Asterisk 12, not Asterisk 11.

I am also attempting to get Asterisk 11 functional on OS X 10.9 Mavericks and ran into the same error you did while compiling 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);

After quite a bit of digging, I found the cause of the 'C_IN' undeclared error is that main/enum.c & main/srv.c only include arpa/nameser_compat.h on OS X if you're using Apple's version of cc, but we're using GCC. So, you need to patch those files to remove that requirement, as shown in the following diff:

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

While the above fix will allow a successful compilation, you'll encounter "Illegal instruction: 4" runtime errors unless you update the minimum OS X version used by the linker. You can easily modify Makefile and main/Makefile as follows:

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

These changes have allowed me to compile & install both Asterisk 11.15.0 & 11.16.0 on OS X 10.9 Mavericks.