[still no solution - anyone have any idea?] Installing ODBC

I’m installing unixODBC and have successfully compiled it. The next step int he instruction set I have says to do the following:

cp app_odbcexec.c /usr/src/asterisk/apps/
vi /usr/src/asterisk/apps/Makefile +28
app_setcdruserfield.so app_random.so app_odbcexec.so
app_odbcexec.so: app_odbcexec.o
$(CC) $(SOLINK) -o $@ $< -lodbc

make
make install

I’ve copied app_odbcexec.c to the asterisk apps directory, but the next step doesn’t make sense to me. After vi /usr/src/asterisk/apps/Makefile +28, I am dropped into the middle of the make file and the next lines in the instructions really don’t belong in that particular spot. I don’t know enough about the dependencies to make an intelligent decision as to where to place these items. Anyone have any experience here?

Thanks in advance.

MtG:/usr/src/asterisk-1.2.10/apps# cat -n Makefile | less

       1  #
     2  # Asterisk -- A telephony toolkit for Linux.
     3  #
     4  # Makefile for PBX applications
     5  #
     6  # Copyright (C) 1999-2005, Digium
     7  #
     8  # Mark Spencer <markster@digium.com>
     9  #
    10  # This program is free software, distributed under the terms of
    11  # the GNU General Public License
    12  #
    13
    14  APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_mp3.so\
    15       app_system.so app_echo.so app_record.so app_image.so app_url.so app_disa.so \
    16       app_adsiprog.so app_getcpeid.so app_milliwatt.so \
    17       app_zapateller.so app_setcallerid.so app_festival.so \
    18       app_queue.so app_senddtmf.so app_parkandannounce.so \
    19       app_setcidname.so app_lookupcidname.so app_macro.so \
    20       app_authenticate.so app_softhangup.so app_lookupblacklist.so \
    21       app_waitforring.so app_privacy.so app_db.so app_chanisavail.so \
    22       app_enumlookup.so app_transfer.so app_setcidnum.so app_cdr.so \
    23       app_hasnewvoicemail.so app_sayunixtime.so app_cut.so app_read.so \
    24       app_setcdruserfield.so app_random.so app_ices.so app_eval.so \
    25       app_nbscat.so app_sendtext.so app_exec.so \
    26       app_groupcount.so app_txtcidname.so app_controlplayback.so \
    27       app_talkdetect.so app_alarmreceiver.so app_userevent.so app_verbose.so \
    28       app_test.so app_forkcdr.so app_math.so app_realtime.so \
    29       app_dumpchan.so app_waitforsilence.so app_while.so app_setrdnis.so \
    30       app_md5.so app_readfile.so app_chanspy.so app_settransfercapability.so \
    31       app_dictate.so app_externalivr.so app_directed_pickup.so \
    32       app_mixmonitor.so app_stack.so
    33
    34  #
    35  # Obsolete things...
    36  #
    37  #APPS+=app_sql_postgres.so
    38  #APPS+=app_sql_odbc.so
    39
    40  #
    41  # Experimental things
    42  #
    43  #APPS+=app_ivrdemo.so
    44  #APPS+=app_skel.so
    45  #APPS+=app_rpt.so
    46
    47  ifndef WITHOUT_ZAPTEL
    48  ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
    49    APPS+=app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so app_page.so
    50  endif
  51  endif # WITHOUT_ZAPTEL
    52
    53  ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/osp/osp.h $(CROSS_COMPILE_TARGET)/usr/include/osp/osp.h),)
    54  APPS+=app_osplookup.so
    55  endif
    56
    57  ifeq ($(findstring BSD,${OSARCH}),BSD)
    58  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
    59  endif
    60
    61  CURLLIBS=$(shell $(CROSS_COMPILE_BIN)curl-config --libs)
    62  ifneq ($(shell if [[ 0x`$(CROSS_COMPILE_BIN)curl-config --vernum` -ge 0x70907 ]]; then echo "OK" ; fi),)
    63    ifneq (${CURLLIBS},)
    64      APPS+=app_curl.so
    65    endif
    66  endif
    67
    68  ifeq (${OSARCH},CYGWIN)
    69  CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
    70  CYGSOLIB=-L.. -L. -L../res -lasterisk.dll -lres_features.so -lres_adsi.so -lres_monitor.so
    71  else
    72  CFLAGS+=-fPIC
    73  APPS+=app_sms.so
    74  endif
    75
    76  #
    77  # If you have UnixODBC you can use ODBC voicemail
    78  # storage
    79  #
    80  # Uncomment to use ODBC storage
    81  #CFLAGS+=-DUSE_ODBC_STORAGE
    82  # Uncomment for extended ODBC voicemail storage
    83  #CFLAGS+=-DEXTENDED_ODBC_STORAGE
    84  # See doc/README.odbcstorage for more information
    85
    86  all: $(APPS)
    87
    88  clean:
    89          rm -f *.so *.o .depend
    90
    91  %.so : %.o
    92          $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
    93
    94  app_rpt.so : app_rpt.o
    95          $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -ltonezone
    96
    97  install: all
    98          for x in $(APPS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
    99          rm -f $(DESTDIR)$(MODULES_DIR)/app_datetime.so
   99          rm -f $(DESTDIR)$(MODULES_DIR)/app_datetime.so
   100          rm -f $(DESTDIR)$(MODULES_DIR)/app_qcall.so
   101
   102  app_curl.so: app_curl.o
   103          $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CURLLIBS)
   104
   105  app_sql_postgres.o: app_sql_postgres.c
   106          $(CC) -pipe -I$(CROSS_COMPILE_TARGET)/usr/local/pgsql/include -I$(CROSS_COMPILE_TARGET)/usr/include/postgresql $(CFLAGS) -c -o app_sql_post
gres.o app_sql_postgres.c
   107
   108  app_sql_postgres.so: app_sql_postgres.o
   109          $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -L/usr/local/pgsql/lib -lpq
   110
   111  app_sql_odbc.so: app_sql_odbc.o
   112          $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc
   113
   114  ifeq (SunOS,$(shell uname))
   115  app_chanspy.so: app_chanspy.o
   116          $(CC) $(SOLINK) -o $@ $< -lrt
   117  endif
   118
   119
   120  ifneq ($(wildcard .depend),)
   121   include .depend
   122  endif
   123
   124  depend: .depend
   125
   126  .depend:
   127          ../build_tools/mkdep $(CFLAGS) `ls *.c`
   128
   129  env:
   130          env

APPS = tells You what application will be compiled and usable in Asterisk (You can always disable it in modules.conf postinstall)
Simpli add app_odbcexec.so at the end of APPS (after app_stack.so)
i would add app_odbcexec.so: app_odbcexec.o $(CC) $(SOLINK) -o $@ $< -lodbc
around line 33, so it should be make-ed and make install-ed always

i could be wrong, i hope that someone more experienced will correct me.

I tried that and got the following:

[root@asterisk apps]# make cc -fPIC -c -o app_odbcexec.o app_odbcexec.c In file included from app_odbcexec.c:21: /usr/include/asterisk/file.h:27:2: #error You must include stdio.h before file.h! In file included from /usr/include/asterisk/linkedlists.h:23, from /usr/include/asterisk/chanvars.h:26, from /usr/include/asterisk/channel.h:111, from /usr/include/asterisk/file.h:30, from app_odbcexec.c:21: /usr/include/asterisk/lock.h: In function `ast_mutex_init': /usr/include/asterisk/lock.h:534: error: `PTHREAD_MUTEX_RECURSIVE' undeclared (first use in this function) /usr/include/asterisk/lock.h:534: error: (Each undeclared identifier is reported only once /usr/include/asterisk/lock.h:534: error: for each function it appears in.) In file included from app_odbcexec.c:21: /usr/include/asterisk/file.h: At top level: /usr/include/asterisk/file.h:56: error: syntax error before '*' token /usr/include/asterisk/file.h:57: error: syntax error before '*' token app_odbcexec.c: In function `odbcexec_exec': app_odbcexec.c:101: error: structure has no member named `callerid' app_odbcexec.c: In function `odbcexec_query': app_odbcexec.c:147: error: structure has no member named `callerid' app_odbcexec.c: In function `odbc_load_module': app_odbcexec.c:232: warning: assignment makes pointer from integer without a cast make: *** [app_odbcexec.o] Error 1 [root@asterisk apps]#

Any suggestions?[/b]

i found in google loligo.com/asterisk/misc/app … _odbcexec/ and downlad app_odbcexec.c, copy it to /usr/src/asterisk-1.2.10/apps
add app_odbcexec at the end of APPS= run make and i get error similar to

In file included from app_odbcexec.c:21:
/usr/include/asterisk/file.h:27:2: #error You must include stdio.h before file.h! 

it was easy to remove, i changed

#include <sys/types.h>
#include <asterisk/options.h>
#include <asterisk/config.h>
#include <asterisk/file.h>
#include <asterisk/logger.h>
#include <asterisk/channel.h>
#include <asterisk/pbx.h>
#include <asterisk/module.h>
#include <asterisk/pbx.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>

into

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/types.h>
#include <asterisk/options.h>
#include <asterisk/config.h>
#include <asterisk/file.h>
#include <asterisk/logger.h>
#include <asterisk/channel.h>
#include <asterisk/module.h>
#include <asterisk/pbx.h>

#include <stdio.h> was added
next make give me error like:

app_odbcexec.c: In function `odbcexec_exec':
app_odbcexec.c:101: warning: implicit declaration of function `qast_exists_extension'
app_odbcexec.c:101: error: structure has no member named `callerid'
app_odbcexec.c: In function `odbcexec_query':
app_odbcexec.c:147: error: structure has no member named `callerid'
app_odbcexec.c: In function `odbc_load_module':

in line 101-102 and 147-148 there is:

   101                  if (ast_exists_extension (chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
   102                          chan->priority += 100;

definition of ast_exist_extenion is in /usr/src/asterisk-1.2.10/include/asterisk/pbx.h

  335  /*! If an extension exists, return non-zero */
   336  /*  work */
   337  /*!
   338   * \param c this is not important
   339   * \param context which context to look in
   340   * \param exten which extension to search for
   341   * \param priority priority of the action within the extension
   342   * \param callerid callerid to search for
   343   * If an extension within the given context(or callerid) with the given priority is found a non zero value will be returned.
   344   * Otherwise, 0 is returned.
   345   */
   346  int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid);

code is in /usr/src/asterisk-1.2.10/pbx.c

2203  int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
  2204  {
  2205          return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_EXISTS);
  2206  }

there is 'const chan *callerid’
i’m not good at programing and i don’t know how to resolve this.
maybe someone more skillfull will have a clue

i think problem is now solved

i downloaded asterisk 1.0.11
copied app_odbcexec to /usr/src/asterisk-1.0.11/apps/
modified Makefile then run make and a while later i see

 +--------- Asterisk Build Complete ---------+
 + Asterisk has successfully been built, but +
 + cannot be run before being installed by   +
 + running:                                  +
 +                                           +
 +               make install                +
 +-------------------------------------------+

app_odbcexec.so was created

if You want to get data from any DB in Asterisk 1.2. branch then i suggest AGI