6

Asterisk 13.1.0 is available in the repos for Xenial.

But I'm supporting an application that needs Asterisk 1.8 LTS, because we use a custom plugin. We need to keep using Asterisk 1.8 and building it from source until we can port our plugin forward to the newer version of Asterisk.

However, it seems like Asterisk 1.8 cannot be built with the version of g++ available on Xenial, which is 5.3.1. I get a ton of warnings, which can be silenced, but also a lot of fatal errors about duplicate-defined symbols, and possibly other fatal errors even if I could resolve these.

Example:

iax2-parser.o: In function `ast_atomic_fetchadd_int':
asterisk-1.8/include/asterisk/lock.h:600: multiple definition of `ast_atomic_fetchadd_int'
chan_iax2.o:asterisk-1.8/include/asterisk/lock.h:600: first defined here
iax2-parser.o: In function `ast_atomic_dec_and_test':
asterisk-1.8/include/asterisk/lock.h:646: multiple definition of `ast_atomic_dec_and_test'
chan_iax2.o:asterisk-1.8/include/asterisk/lock.h:646: first defined here
...etc...

I've been reading other posts from people struggling with this, and I've been trying to use compiler options to work around it with no success.

My question is whether there is any solution to do one of the following:

  • Build Asterisk 1.8 using g++ 5.3.1 and resolve the compile errors.
  • Install an old version of g++ on Xenial (for example I know g++ 4.4.7 works to compile Asterisk 1.8 on our old OS).
  • Some other solution to build a version of Asterisk that will run on Xenial. Perhaps build on Ubuntu 14.04 and tar up the binaries? I'd expect to get library version conflicts.

Some people will be glib and say, "you should really just upgrade to Asterisk 13.1.0." Yes, I know of course that would be a better plan. I know Asterisk 1.8 has passed its EOL. Getting a resource to port our plugin forward to Asterisk 13.1.0 is what is holding us back.

Bill Karwin
  • 211
  • 1
  • 7
  • I would say install GCC 4.4.7 and compile Asterisk using that since it has worked previously. – edwinksl Jun 07 '16 at 23:20
  • Do you mean build GCC 4.4.7 from source? Sure, that might be possible. In general, I prefer to use binaries from an official repo, but I can do that. – Bill Karwin Jun 07 '16 at 23:32
  • 2
    I'd suggest trying [gcc/g++ 4.8.5 from the Xenial repository](http://packages.ubuntu.com/xenial/gcc-4.8) before resorting to older manually installed versions (I don't have access to a 16.04 system, but FWIW it appeared to build OK on 14.04 using gcc 4.8.5) – steeldriver Jun 07 '16 at 23:38
  • @steeldriver, that worked! Thank you! If you post an answer, I'll mark it accepted, or else if you like I'll post an answer describing what I did in detail. – Bill Karwin Jun 08 '16 at 00:02
  • 1
    Nope I meant installing it using a PPA if you can find one. Anyway, it seems @steeldriver's solution works for you. – edwinksl Jun 08 '16 at 00:49
  • 3
    @BillKarwin yes please go ahead and write an answer - I can only guess the exact steps since I don't have access to 16.04 – steeldriver Jun 08 '16 at 00:59

4 Answers4

5

Based on the lead from @steeldriver, I learned that Ubuntu 16.04 has a package in its standard repo for gcc-4.8 and g++-4.8. I installed g++ and a few other packages needed for building Asterisk 1.8:

apt-get install g++-4.8 libcurl4-openssl-dev libncurses5-dev libxml2-dev

This installs g++4.8 as a distinct binary from g++ version 5.3.1, which is also installed. I just need to configure the Asterisk build to use g++4.8, and build:

./configure CXX=g++4.8
make -j4
make install

And eureka! It worked! I built this outdated version of Asterisk 1.8 on Ubuntu 16.04.

Bill Karwin
  • 211
  • 1
  • 7
2

As Bill Karwin answered, it's a gcc issue. But I've managed to build Asterisk 1.8 only after adding an extra flag to configure:

./configure CXX=g++-4.8 CC=gcc-4.8

Also note hyphens in the values.

Alex Svetkin
  • 121
  • 4
1

On Ubuntu 18.04:

sudo apt install g++-4.8

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 1`  
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 1`  

For tcptls:

sudo apt install libssl1.0-dev`

./configure 
make menuselect
make
Daniele Santi
  • 3,084
  • 4
  • 30
  • 30
1

I found out this is caused by inline issue.

In include/asterisk/inline_api.h line #49:

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

change this to:

define AST_INLINE_API(hdr, body) hdr;

Then make will passed.

BaldrSky
  • 11
  • 1
  • Thanks for the tip, but I solved it by installing gcc 4.8 as I noted above. Also, it was 3.5 years ago, and I no longer work at that job, so I'll probably never have to compile an outdated version of Asterisk again! :-) – Bill Karwin Dec 26 '19 at 17:49