wdoekes / asterisk-chan-dongle

chan_dongle channel driver for Huawei UMTS cards, works with Asterisk 14+
Other
296 stars 104 forks source link

Can't build on Fedora Core 20/21 #169

Closed andy65535 closed 1 year ago

andy65535 commented 1 year ago

Hi! bootstrap and configure --with-astversion=11.14

works well, but make failed:

gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT app.o -MF .app.o.d -MP  -o app.o -c app.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT at_command.o -MF .at_command.o.d -MP  -o at_command.o -c at_command.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT at_parse.o -MF .at_parse.o.d -MP  -o at_parse.o -c at_parse.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT at_queue.o -MF .at_queue.o.d -MP  -o at_queue.o -c at_queue.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT at_read.o -MF .at_read.o.d -MP  -o at_read.o -c at_read.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT at_response.o -MF .at_response.o.d -MP  -o at_response.o -c at_response.c
at_response.c: In function ‘log_cmd_response_error’:
at_response.c:274:3: warning: implicit declaration of function ‘DEBUG_ATLEAST’ [-Wimplicit-function-declaration]
   if (DEBUG_ATLEAST(1)) {
   ^
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT chan_dongle.o -MF .chan_dongle.o.d -MP  -o chan_dongle.o -c chan_dongle.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT channel.o -MF .channel.o.d -MP  -o channel.o -c channel.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT char_conv.o -MF .char_conv.o.d -MP  -o char_conv.o -c char_conv.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT cli.o -MF .cli.o.d -MP  -o cli.o -c cli.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT helpers.o -MF .helpers.o.d -MP  -o helpers.o -c helpers.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT manager.o -MF .manager.o.d -MP  -o manager.o -c manager.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT memmem.o -MF .memmem.o.d -MP  -o memmem.o -c memmem.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT ringbuffer.o -MF .ringbuffer.o.d -MP  -o ringbuffer.o -c ringbuffer.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT cpvt.o -MF .cpvt.o.d -MP  -o cpvt.o -c cpvt.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT dc_config.o -MF .dc_config.o.d -MP  -o dc_config.o -c dc_config.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT pdu.o -MF .pdu.o.d -MP  -o pdu.o -c pdu.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT mixbuffer.o -MF .mixbuffer.o.d -MP  -o mixbuffer.o -c mixbuffer.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT pdiscovery.o -MF .pdiscovery.o.d -MP  -o pdiscovery.o -c pdiscovery.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT error.o -MF .error.o.d -MP  -o error.o -c error.c
gcc -g -O2 -O6 -Wno-old-style-declaration -I. -std=gnu99 -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -D_GNU_SOURCE -I/usr/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT smsdb.o -MF .smsdb.o.d -MP  -o smsdb.o -c smsdb.c
gcc  -shared -Xlinker -x -o chan_dongle.so app.o at_command.o at_parse.o at_queue.o at_read.o at_response.o chan_dongle.o channel.o char_conv.o cli.o helpers.o manager.o memmem.o ringbuffer.o cpvt.o dc_config.o pdu.o mixbuffer.o pdiscovery.o error.o smsdb.o -lsqlite3
at_command.o: In function `ast_atomic_fetchadd_int':
/usr/include/asterisk/lock.h:600: multiple definition of `ast_atomic_fetchadd_int'
app.o:/usr/include/asterisk/lock.h:600: first defined here
at_command.o: In function `ast_atomic_dec_and_test':
/usr/include/asterisk/lock.h:646: multiple definition of `ast_atomic_dec_and_test'
app.o:/usr/include/asterisk/lock.h:646: first defined here
at_command.o: In function `ast_tvdiff_sec':
/usr/include/asterisk/time.h:45: multiple definition of `ast_tvdiff_sec'
app.o:/usr/include/asterisk/time.h:45: first defined here
at_command.o: In function `ast_tvdiff_us':
/usr/include/asterisk/time.h:64: multiple definition of `ast_tvdiff_us'
app.o:/usr/include/asterisk/time.h:64: first defined here
at_command.o: In function `ast_tvdiff_ms':
/usr/include/asterisk/time.h:78: multiple definition of `ast_tvdiff_ms'
app.o:/usr/include/asterisk/time.h:78: first defined here
at_command.o: In function `ast_tvzero':
/usr/include/asterisk/time.h:95: multiple definition of `ast_tvzero'
app.o:/usr/include/asterisk/time.h:95: first defined here
at_command.o: In function `ast_tvcmp':
/usr/include/asterisk/time.h:106: multiple definition of `ast_tvcmp'
app.o:/usr/include/asterisk/time.h:106: first defined here
at_command.o: In function `ast_tveq':
/usr/include/asterisk/time.h:125: multiple definition of `ast_tveq'
app.o:/usr/include/asterisk/time.h:125: first defined here
at_command.o: In function `ast_tvnow':
/usr/include/asterisk/time.h:135: multiple definition of `ast_tvnow'
app.o:/usr/include/asterisk/time.h:135: first defined here
at_command.o: In function `ast_tv':
/usr/include/asterisk/time.h:171: multiple definition of `ast_tv'
app.o:/usr/include/asterisk/time.h:171: first defined here
at_command.o: In function `ast_samp2tv':
/usr/include/asterisk/time.h:186: multiple definition of `ast_samp2tv'
app.o:/usr/include/asterisk/time.h:186: first defined here
at_command.o: In function `_ast_malloc':
/usr/include/asterisk/utils.h:500: multiple definition of `_ast_malloc'
app.o:/usr/include/asterisk/utils.h:500: first defined here
at_command.o: In function `_ast_calloc':
/usr/include/asterisk/utils.h:523: multiple definition of `_ast_calloc'
app.o:/usr/include/asterisk/utils.h:523: first defined here
at_command.o: In function `_ast_realloc':
/usr/include/asterisk/utils.h:559: multiple definition of `_ast_realloc'
app.o:/usr/include/asterisk/utils.h:559: first defined here
at_command.o: In function `_ast_strdup':
/usr/include/asterisk/utils.h:586: multiple definition of `_ast_strdup'
app.o:/usr/include/asterisk/utils.h:586: first defined here
at_command.o: In function `_ast_strndup':
/usr/include/asterisk/utils.h:615: multiple definition of `_ast_strndup'
app.o:/usr/include/asterisk/utils.h:615: first defined here
at_command.o: In function `_ast_vasprintf':
/usr/include/asterisk/utils.h:654: multiple definition of `_ast_vasprintf'
app.o:/usr/include/asterisk/utils.h:654: first defined here
at_command.o: In function `ast_threadstorage_get':
/usr/include/asterisk/threadstorage.h:173: multiple definition of `ast_threadstorage_get'
app.o:/usr/include/asterisk/threadstorage.h:173: first defined here
at_command.o: In function `ast_skip_blanks':
/usr/include/asterisk/strings.h:90: multiple definition of `ast_skip_blanks'
app.o:/usr/include/asterisk/strings.h:90: first defined here
at_command.o: In function `ast_trim_blanks':
/usr/include/asterisk/strings.h:104: multiple definition of `ast_trim_blanks'
app.o:/usr/include/asterisk/strings.h:104: first defined here
at_command.o: In function `ast_skip_nonblanks':
/usr/include/asterisk/strings.h:129: multiple definition of `ast_skip_nonblanks'
app.o:/usr/include/asterisk/strings.h:129: first defined here
at_command.o: In function `ast_strip':
/usr/include/asterisk/strings.h:147: multiple definition of `ast_strip'
app.o:/usr/include/asterisk/strings.h:147: first defined here
at_command.o: In function `ast_copy_string':
/usr/include/asterisk/strings.h:212: multiple definition of `ast_copy_string'
app.o:/usr/include/asterisk/strings.h:212: first defined here
at_command.o: In function `ast_str_create':
/usr/include/asterisk/strings.h:420: multiple definition of `ast_str_create'
app.o:/usr/include/asterisk/strings.h:420: first defined here
at_command.o: In function `ast_str_reset':
/usr/include/asterisk/strings.h:441: multiple definition of `ast_str_reset'
app.o:/usr/include/asterisk/strings.h:441: first defined here
at_command.o: In function `ast_str_update':
/usr/include/asterisk/strings.h:456: multiple definition of `ast_str_update'
app.o:/usr/include/asterisk/strings.h:456: first defined here

....
<cut a lot of similar>
....

smsdb.o: In function `ast_str_create':
/usr/include/asterisk/strings.h:420: multiple definition of `ast_str_create'
app.o:/usr/include/asterisk/strings.h:420: first defined here
smsdb.o: In function `ast_str_reset':
/usr/include/asterisk/strings.h:441: multiple definition of `ast_str_reset'
app.o:/usr/include/asterisk/strings.h:441: first defined here
smsdb.o: In function `ast_str_update':
/usr/include/asterisk/strings.h:456: multiple definition of `ast_str_update'
app.o:/usr/include/asterisk/strings.h:456: first defined here
smsdb.o: In function `ast_str_trim_blanks':
/usr/include/asterisk/strings.h:466: multiple definition of `ast_str_trim_blanks'
app.o:/usr/include/asterisk/strings.h:466: first defined here
smsdb.o: In function `ast_str_strlen':
/usr/include/asterisk/strings.h:481: multiple definition of `ast_str_strlen'
app.o:/usr/include/asterisk/strings.h:481: first defined here
smsdb.o: In function `ast_str_size':
/usr/include/asterisk/strings.h:492: multiple definition of `ast_str_size'
app.o:/usr/include/asterisk/strings.h:492: first defined here
smsdb.o: In function `ast_str_buffer':
/usr/include/asterisk/strings.h:503: multiple definition of `ast_str_buffer'
app.o:/usr/include/asterisk/strings.h:503: first defined here
smsdb.o: In function `ast_str_truncate':
/usr/include/asterisk/strings.h:521: multiple definition of `ast_str_truncate'
app.o:/usr/include/asterisk/strings.h:521: first defined here
smsdb.o: In function `ast_str_make_space':
/usr/include/asterisk/strings.h:581: multiple definition of `ast_str_make_space'
app.o:/usr/include/asterisk/strings.h:581: first defined here
smsdb.o: In function `ast_str_copy_string':
/usr/include/asterisk/strings.h:606: multiple definition of `ast_str_copy_string'
app.o:/usr/include/asterisk/strings.h:606: first defined here
smsdb.o: In function `ast_str_thread_get':
/usr/include/asterisk/strings.h:666: multiple definition of `ast_str_thread_get'
app.o:/usr/include/asterisk/strings.h:666: first defined here
smsdb.o: In function `ast_str_set_va':
/usr/include/asterisk/strings.h:803: multiple definition of `ast_str_set_va'
app.o:/usr/include/asterisk/strings.h:803: first defined here
smsdb.o: In function `ast_str_append_va':
/usr/include/asterisk/strings.h:820: multiple definition of `ast_str_append_va'
app.o:/usr/include/asterisk/strings.h:820: first defined here
smsdb.o: In function `ast_str_set_substr':
/usr/include/asterisk/strings.h:827: multiple definition of `ast_str_set_substr'
app.o:/usr/include/asterisk/strings.h:827: first defined here
smsdb.o: In function `ast_str_append_substr':
/usr/include/asterisk/strings.h:834: multiple definition of `ast_str_append_substr'
app.o:/usr/include/asterisk/strings.h:834: first defined here
smsdb.o: In function `ast_str_set_escapecommas':
/usr/include/asterisk/strings.h:841: multiple definition of `ast_str_set_escapecommas'
app.o:/usr/include/asterisk/strings.h:841: first defined here
smsdb.o: In function `ast_str_append_escapecommas':
/usr/include/asterisk/strings.h:848: multiple definition of `ast_str_append_escapecommas'
app.o:/usr/include/asterisk/strings.h:848: first defined here
smsdb.o: In function `ast_str_set':
/usr/include/asterisk/strings.h:876: multiple definition of `ast_str_set'
app.o:/usr/include/asterisk/strings.h:876: first defined here
smsdb.o: In function `ast_str_append':
/usr/include/asterisk/strings.h:902: multiple definition of `ast_str_append'
app.o:/usr/include/asterisk/strings.h:902: first defined here
smsdb.o: In function `ast_check_digits':
/usr/include/asterisk/strings.h:923: multiple definition of `ast_check_digits'
app.o:/usr/include/asterisk/strings.h:923: first defined here
smsdb.o: In function `ast_tech_to_upper':
/usr/include/asterisk/strings.h:941: multiple definition of `ast_tech_to_upper'
app.o:/usr/include/asterisk/strings.h:941: first defined here
smsdb.o: In function `ast_rq_is_int':
/usr/include/asterisk/config.h:829: multiple definition of `ast_rq_is_int'
app.o:/usr/include/asterisk/config.h:829: first defined here
collect2: error: ld returned 1 exit status
make: *** [chan_dongle.so] Error 1

asterisk 11.14.1 gcc version 4.8.3 20140911

Pleas, help.

wdoekes commented 1 year ago

Works fine over here when the include files/paths are all correct.

$ nm at_command.o | grep ast_
                 U ast_debug_get_by_module
                 U ast_log
                 U ast_options
$ nm at_command.o | grep at_
00000000000001e0 d at_cmd.14
0000000000000060 d at_cmd.2
0000000000000000 d at_cmd.23
00000000000012b0 T at_enqueue_activate
00000000000010f0 T at_enqueue_answer
...

I assume you have a bunch of defined ast_* functions that are defined instead of referenced.

That would mean that the AST_INLINE_API macro is not doing its work correctly on your system. If you check include/asterisk/inline_api.h (outside tree), you should find this:

#if !defined(LOW_MEMORY)

#if !defined(AST_API_MODULE)
#if defined(__clang__) || defined(__GNUC_STDC_INLINE__)
#define AST_INLINE_API(hdr, body) static hdr; static inline hdr body
#else /* if defined(__clang__) */
#define AST_INLINE_API(hdr, body) hdr; extern inline hdr body
#endif
#else /* if !defined(AST_API_MODULE) */
#define AST_INLINE_API(hdr, body) hdr; hdr body
#endif

You could play around and swap those #defines around. But this is not trivial to explain. Using a different gcc can produce different results.

wdoekes commented 1 year ago

Also:

commit 5e46127e17c1a80a03f952c78e0414cf34dfdca7
Author: George Joseph <george.joseph@fairview5.com>
Date:   Mon Apr 6 18:58:30 2015 +0000

    build: Fixes for gcc 5 compilation

    These are fixes for compilation under gcc 5.0...

    chan_sip.c:    In parse_request needed to make 'lim' unsigned.
    inline_api.h:  Needed to add a check for '__GNUC_STDC_INLINE__' to detect C99
                   inline semantics (same as clang).
    ccss.c:        In ast_cc_set_parm, needed to fix weird comparison.
    dsp.c:         Needed to work around a possible compiler bug.  It was throwing
                   an array-bounds error but neither
                   sgriepentrog, rmudgett nor I could figure out why.
    manager.c:     In action_atxfer, needed to correct an array allocation.

    This patch will go to 11, 13, trunk.

    Review: https://reviewboard.asterisk.org/r/4581/
    Reported-by: Jeffrey Ollie
    Tested-by: George Joseph
    ASTERISK-24932 #close

That's a fix for gcc compilation with gcc 5. It is included first in 11.18:

$ git tag --contains 5e46127e17c1a80a03f952c78e0414cf34dfdca7 | sort -V | head -n3
11.18.0
11.18.0-rc1
11.19.0

I think you should update both your Asterisk and your compiler. This is 2015 stuff.

andy65535 commented 1 year ago

I've used inline_api.h from latest Asterisk repo https://github.com/asterisk/asterisk/blob/master/include/asterisk/inline_api.h and now chan_dongle making without errors. Also ast_compat.h needs update:

diff --git a/ast_compat.h b/ast_compat.h
index 1ad407a..6f371bb 100644
--- a/ast_compat.h
+++ b/ast_compat.h
@@ -9,6 +9,15 @@

 #include <asterisk/channel.h>

+#if ASTERISK_VERSION_NUM <=111700
+#define DEBUG_ATLEAST(level) \
+       (option_debug >= (level) \
+               || (ast_opt_dbg_module \
+               && ((int)ast_debug_get_by_module(AST_MODULE) >= (level) \
+                               || (int)ast_debug_get_by_module(__FILE__) >= (level))))
+#endif
+
+
 /* Asterisk 11+ channel opaqification */
 #if ASTERISK_VERSION_NUM < 110000 /* 11- */

Now it works as expected. Thank you!