leedm777 / homebrew-asterisk

Homebrew tap for building an Asterisk dev environment
50 stars 27 forks source link

Build fails on OS X Yosemite 10.10.1 due to errors in compat.h #10

Closed morgant closed 9 years ago

morgant commented 10 years ago

Build fails on OS X Yosemite 10.10.1 w/Xcode 6.1.1 (though I'm using GCC 4.8, as described) with the following error (there are more, of course, but all related to this error):

/usr/local/bin/gcc-4.8 -o pbx_ael.o -c pbx_ael.c -MD -MT pbx_ael.o -MF .pbx_ael.o.d -MP -D_THREAD_SAFE  -I/private/tmp/asterisk-UUBG64/asterisk-12.2.0/include -fno-strict-aliasing  -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 -pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations  -g3  -D__Darwin__ -mmacosx-version-min=10.6 -O3 -fPIC -DAST_MODULE=\"pbx_ael\"   
In file included from /usr/include/sys/_endian.h:130:0,
                 from /usr/include/i386/endian.h:99,
                 from /usr/include/machine/endian.h:35,
                 from /usr/include/sys/types.h:81,
                 from /private/tmp/asterisk-UUBG64/asterisk-12.2.0/include/asterisk/compat.h:49,
                 from /private/tmp/asterisk-UUBG64/asterisk-12.2.0/include/asterisk.h:27,
                 from chan_bridge_media.c:35:
/private/tmp/asterisk-UUBG64/asterisk-12.2.0/include/asterisk/compat.h:97:10: error: expected ')' before '?' token
 uint64_t htonll(uint64_t host64);

Note that the configure output shows:

checking for htonll... no

Full verbose output from brew install -vd ~/Projects/homebrew-asterisk/asterisk.rb can be found in this gist.

morgant commented 10 years ago

In troubleshooting with an Asterisk developer, I've discovered that this is because configure is not correctly identifying htonll & ntohll, which are now defined in /usr/include/sys/_endian.h in OS X 10.10 Yosemite, while they were not in earlier versions of OS X. See ASTERISK-24544.

yluom commented 10 years ago

So, did you found a workaround to fix this issue ? I'm getting the same compile error (when compiling from source, not with brew, I'm stuck with another problem installing w/ brew)...

leedm777 commented 10 years ago

@yluom I'm working on a patch to fix the issue. I hope to have an updated formula shortly, but it will upgrade to Asterisk 13, since Asterisk 12 is in security fix only mode.

Since you're building from source, you can try the relevant portion of the patch: https://gist.github.com/393f797c80bdb192da19

Apply the patch, run ./bootstrap.sh, and try your compilation again. Asterisk 12 should be fine, but there are a few other problems that 13 has building on OS X that I'm working on.

morgant commented 10 years ago

@yluom You can use @leedm777's patch or just append #define HAVE_HTONLL 1 & #define HAVE_NTOHLL 1 to include/asterisk/autoconfig.h (after running ./configure, of course). Whichever is easier for you. Naturally, both of these workarounds are Yosemite-specific and will cause the compile to fail on Mavericks and earlier.

leedm777 commented 10 years ago

I have a branch where I'm updating Asterisk to work on Yosemite, but I'm having some trouble.

I am getting this crazy error:

gcc-4.9  -o libasteriskssl.dylib -D_THREAD_SAFE    -L/usr/local/lib -Wl,-rpath,/usr/local/Cellar/asterisk/13.0.1/lib -dynamiclib -install_name /usr/local/Cellar/asterisk/13.0.1/lib/libasteriskssl.dylib -Xlinker -dylib -mmacosx-version-min=10.6 -Xlinker -undefined -Xlinker dynamic_lookup /usr/lib/bundle1.o   libasteriskssl.o  -L/usr/local/opt/openssl/lib -lssl -lcrypto
ld: unknown option: -Wl,-dylib

What's crazy about it is if I debug the install, drop into the shell, and run exactly that command in that directory, it works fine. Or even just running make again will pick up compilation from that step.

If anyone wants to look at my branch, help is appreciated.

morgant commented 9 years ago

I currently have it building with gcc4.8 & dependancies installed via MacPorts, but I will try to look at this again at some point.

leedm777 commented 9 years ago

I think I've finally got a fix for this. Please let me know if you have further issues.