Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot be built externally with Asterisk 16 #15

Closed
bernhardschmidt opened this issue Jan 20, 2019 · 2 comments · Fixed by #16
Closed

Cannot be built externally with Asterisk 16 #15

bernhardschmidt opened this issue Jan 20, 2019 · 2 comments · Fixed by #16

Comments

@bernhardschmidt
Copy link

Building an external shared module (with the Makefile opposed to patching the Asterisk source) does not work anymore with Asterisk 16. It probably doesn't work starting with Asterisk 14, as this is apparently the version where the very very lightly documented requirement for AST_MODULE_SELF_SYM has been introduced.

https://issues.asterisk.org/jira/browse/ASTERISK-26278
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=919828

gcc -o codecs/codec_opus_open_source.so  -DAST_MODULE=\"codec_opus_open_source\" -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/<<BUILDDIR>>/asterisk-opus-13.7+20171009=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -g3 -O3 -lopus -shared -Wl,-z,relro codecs/codec_opus_open_source.c
In file included from codecs/codec_opus_open_source.c:39:
/usr/include/asterisk.h:232:2: error: #error "Externally compiled modules must declare AST_MODULE_SELF_SYM."
 #error "Externally compiled modules must declare AST_MODULE_SELF_SYM."
  ^~~~~
In file included from codecs/codec_opus_open_source.c:56:
codecs/codec_opus_open_source.c: In function 'load_module':
codecs/codec_opus_open_source.c:833:8: error: 'AST_MODULE_SELF' undeclared (first use in this function); did you mean 'AST_MODULE_INFO'?
  res = ast_register_translator(&opustolin);
        ^~~~~~~~~~~~~~~~~~~~~~~
codecs/codec_opus_open_source.c:833:8: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [Makefile:50: codecs/codec_opus_open_source.so] Error 1
make[1]: Leaving directory '/<<BUILDDIR>>/asterisk-opus-13.7+20171009'
@bernhardschmidt
Copy link
Author

Note that other projects building external modules have resolved this by setting -DAST_MODULE_SELF_SYM to something like __internal_<modulename>_self, i.e. zaf/Asterisk-Flite@2bdc757 . This seems to work for asterisk-opus as well (at least it builds), but I have no idea what it does.

@traud
Copy link
Owner

traud commented Jan 21, 2019

Puh, I never tested that code with Asterisk 14 or newer. Thanks for the note!

Yes, that is the solution. The same was done in Asterisk itself (see the modules pbx_ael and codec_lpc10). Are you able to create a Pull Request? That way, it is easier for me to merge that change (as you have tested it already) and you get a linked contributor.

And yes, after a bit of Git blame investigation, the original change happened back in May 2015 with Asterisk 14 already:

It was code clean-up, adding an additional burden on external modules. If you do not know how to create a Pull Request, you can use the edit interface of the GitHub webpage instead. That creates a Pull Request automatically. If all this is too complicated, just say so, and I change it directly.

bernhardschmidt added a commit to bernhardschmidt/asterisk-opus that referenced this issue Jan 24, 2019
This is necessary for external module compilation since Asterisk 14

gcc -o codecs/codec_opus_open_source.so  -DAST_MODULE=\"codec_opus_open_source\" -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/<<BUILDDIR>>/asterisk-opus-13.7+20171009=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -g3 -O3 -lopus -shared -Wl,-z,relro codecs/codec_opus_open_source.c
In file included from codecs/codec_opus_open_source.c:39:
/usr/include/asterisk.h:232:2: error: #error "Externally compiled modules must declare AST_MODULE_SELF_SYM."
 #error "Externally compiled modules must declare AST_MODULE_SELF_SYM."
  ^~~~~
In file included from codecs/codec_opus_open_source.c:56:
codecs/codec_opus_open_source.c: In function 'load_module':
codecs/codec_opus_open_source.c:833:8: error: 'AST_MODULE_SELF' undeclared (first use in this function); did you mean 'AST_MODULE_INFO'?
  res = ast_register_translator(&opustolin);
        ^~~~~~~~~~~~~~~~~~~~~~~
codecs/codec_opus_open_source.c:833:8: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [Makefile:50: codecs/codec_opus_open_source.so] Error 1

Fixes traud#15
greenfieldtech-nirs pushed a commit to cloudonix/asterisk-opus that referenced this issue Nov 27, 2019
This is necessary for external module compilation since Asterisk 14

gcc -o codecs/codec_opus_open_source.so  -DAST_MODULE=\"codec_opus_open_source\" -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/<<BUILDDIR>>/asterisk-opus-13.7+20171009=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -g3 -O3 -lopus -shared -Wl,-z,relro codecs/codec_opus_open_source.c
In file included from codecs/codec_opus_open_source.c:39:
/usr/include/asterisk.h:232:2: error: #error "Externally compiled modules must declare AST_MODULE_SELF_SYM."
 #error "Externally compiled modules must declare AST_MODULE_SELF_SYM."
  ^~~~~
In file included from codecs/codec_opus_open_source.c:56:
codecs/codec_opus_open_source.c: In function 'load_module':
codecs/codec_opus_open_source.c:833:8: error: 'AST_MODULE_SELF' undeclared (first use in this function); did you mean 'AST_MODULE_INFO'?
  res = ast_register_translator(&opustolin);
        ^~~~~~~~~~~~~~~~~~~~~~~
codecs/codec_opus_open_source.c:833:8: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [Makefile:50: codecs/codec_opus_open_source.so] Error 1

Fixes traud#15
@traud traud closed this as completed in #16 Oct 17, 2021
traud pushed a commit that referenced this issue Oct 17, 2021
If the shared libraries are not compiled in source tree but externally via the Makefile (for example, Asterisk was already installed via a package manager in Linux), the header asterisk.h of Asterisk (14 and newer) error with: Externally compiled modules must declare AST_MODULE_SELF_SYM.

closes #15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants