Summary:ASTERISK-12815: error: ‘PTHREAD_MUTEX_RECURSIVE’ undeclared (first use in this function) on powerpc during compile of 1.6 rc6
Reporter:Brendan Martens (shrift)Labels:
Date Opened:2008-10-02 10:25:06Date Closed:2008-10-05 06:13:55
Versions:Frequency of
Environment:Attachments:( 0) autoconfig.h
( 1) config.log
Description:The gcc compiler on powerpc needs to have "#define _GNU_SOURCE" set in /usr/include/features.h in order for 1.6 to compile cleanly on powerpc architecture. otherwise you will receive errors like this:

  [CC] app_voicemail.c -> app_voicemail.o
In file included from app_voicemail.c:100:
/usr/local/asterisk/include/asterisk/lock.h: In function `ast_mutex_init':
/usr/local/asterisk/include/asterisk/lock.h:749: warning: implicit declaration of function `pthread_mutexattr_settype'
In file included from /usr/local/asterisk/include/asterisk/config.h:30,
                from /usr/local/asterisk/include/asterisk/channel.h:147,
                from app_voicemail.c:102:
/usr/local/asterisk/include/asterisk/utils.h: In function `_ast_strndup':
/usr/local/asterisk/include/asterisk/utils.h:532: warning: implicit declaration of function `strndup'
/usr/local/asterisk/include/asterisk/utils.h:532: warning: assignment makes pointer from integer without a cast
/usr/local/asterisk/include/asterisk/utils.h: In function `_ast_vasprintf':
/usr/local/asterisk/include/asterisk/utils.h:571: warning: implicit declaration of function `vasprintf'
app_voicemail.c: At top level:
app_voicemail.c:169: error: `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' undeclared here (not in a function)
app_voicemail.c:169: error: initializer element is not constant
app_voicemail.c:169: error: (near initialization for `vmstates.lock')
app_voicemail.c:567: error: initializer element is not constant
app_voicemail.c:567: error: (near initialization for `users.lock')
app_voicemail.c:568: error: initializer element is not constant
app_voicemail.c:568: error: (near initialization for `zones.lock')
make[1]: *** [app_voicemail.o] Error 1
make: *** [apps] Error 2

I suggest either the compiler be made to check for this setting or a not be made in the readme. My environment was Debian etc/testing on a powerpc Mac G4.
Comments:By: Sean Bright (seanbright) 2008-10-03 18:56:26

Are you compiling with IMAP_STORAGE defined under "Voicemail Build Options" in menuselect?

By: Brendan Martens (shrift) 2008-10-04 08:08:50

Yes indeed... I should have thought of that when filing this bug... Which I am having a good bit of trouble getting to work as it happens. : (

By: Sean Bright (seanbright) 2008-10-04 08:12:13

OK.  I am going to mark this as a duplicate of issue ASTERISK-12816 which is the same issue.  You can use the fix suggested in that bug to get compiling until we come up with a more elegant solution.

By: Sean Bright (seanbright) 2008-10-04 08:12:45

Duplicate of 0013605

By: Brendan Martens (shrift) 2008-10-04 08:24:48

I don't believe this is a duplicate of that bug. The issue described here just happens to occur on voicemail first, but if i turn on --ignore-errors, it pops up all over the place. As mentioned in my original post, I believe this has to do with the powerpc arch. It needs to have the _GNU_SOURCE variable set before configuring/compiling. After that the whole thing compiled just fine for me.

After googling this issue a bit I have seen this issue discussed previously, this is a bit of an old thread but it seems to be the same issue:


Anyways, I'll leave this to your discretion now, just wanted to clarify all that.

By: Sean Bright (seanbright) 2008-10-04 11:01:53

Can you attach config.log and include/asterisk/autoconfig.h?


By: Brendan Martens (shrift) 2008-10-04 14:21:02

Yes, but note that these are after a successful compile... If you need it I can undefine _GNU_SOURCE and then rerun the configure etc and give you that output. Actually before I attach, is that preferable?

By: Sean Bright (seanbright) 2008-10-04 14:26:01

Yes, that is preferable.

By: Brendan Martens (shrift) 2008-10-04 15:13:15

I have uploaded those files, this is from a ./configure and make --ignore-errors with the _GNU_SOURCE undefined in /usr/include/features.h. I hope this is helpful. I didn't see any more instances of the original error I stated this time. It is entirely possible I am wrong about it occurring in relation to more than just the voicemail. I know I did see it more than that, but I was also doing some weird stuff to the gcc environment variables trying to get this to work. At any rate, those changes were since reverted and this is how it looks with the gcc environment unmodified.

Do you want any other output from the compile? I can paste the entire terminal output into a file too.

By: Sean Bright (seanbright) 2008-10-04 18:49:48

I'm sorry, your last note confused me.

Are you saying that without the changes to your GCC environment, the only warnings you are seeing come from app_voicemail?

Sorry to beat it into the ground, I just want to make sure we are on the same page.

Also, one thing to note from autoconfig.h (the one you attached):
/* Enable GNU extensions on systems that have them.  */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
So regardless of if it is set in /usr/include/features.h, it will be defined by autoconfig.h based on what ./configure discovers.

Anyway, let me know!

By: Brendan Martens (shrift) 2008-10-04 21:19:04

Yes, the only error I see is from app_voicemail. Sorry for the confusion, I was explaining why I said that there were other similar errors earlier, I believe it was due to some changes I made in the build environment trying to make this work.

If the autoconfig is supposed to enable the GNU extensions, it is not properly doing so on powerpc. I can reliably reproduce this error by setting or unsetting the _GNU_SOURCE variable in features.h.

By: Sean Bright (seanbright) 2008-10-04 21:54:27

Right.  This is because autoconfig.h is included (via asterisk.h) _after_ the IMAP related headers are included.  If you do what is suggested in ASTERISK-12816, does the error clear up for you?

By: Brendan Martens (shrift) 2008-10-04 23:26:13

That did work indeed! Sorry for wasting your time troubleshooting my bad info. : (
Thanks for helping me figure this out though. I am rather surprised not to see more people with this issue, is IMAP_STORAGE functional in 1.6.0 at this time?

By: Sean Bright (seanbright) 2008-10-05 06:13:37

Yes, it is.  The change that is causing the compilation problem was introduced just before 1.6.0 was released, and because IMAP_STORAGE is an optional build selection, it just fell through the cracks.  The IMAP functionality itself should work without a problem.

I am going to mark this as a duplicate of ASTERISK-12816 and close this issue in favor of that one.