Compiling MDBTools for unixODBC

Help
Anonymous
2010-03-11
2013-05-01
  • Anonymous

    Anonymous - 2010-03-11

    Hey everyone,
    I'm having difficulties getting this compiled for Slackware 12.2 for use with unixODBC.  If I run ./configure && make then su to root and run make install, it creates all libraries for various SQL server databases.  However, if I run ./configure -enable-sql -with-unixodbc=/usr/local it will configure but during compilation I get an error regarding a static function.   While googling this, I found that a lot of people are having similar problems.  Some with mdb_backends.  I found a solution for mdb_backends.  Has to do with making a minor change to the source file or something, I can't quite remember.  It's available via google search.

    Found the solution to the msb_backends issue, it also should be is CVS.
    http://osdir.com/ml/db.mdb-tools.devel/2007-03/msg00001.html
    basically the function is declared as extern in one location and static in another, changing the extern to static resolves the issue.

    Anyway, if anyone has any information regarding this 'bind_columns' function, that would be great!

    odbc.c:50:1: warning: "MIN" redefined
    In file included from ../../include/mdbtools.h:31,
                     from ../../include/mdbodbc.h:22,
                     from odbc.c:28:
    /usr/include/glib-1.2/glib.h:137:1: warning: this is the location of the previous definition
    odbc.c: In function 'SQLBindCol':
    odbc.c:494: warning: assignment from incompatible pointer type
    odbc.c: In function 'SQLColAttributes':
    odbc.c:660: warning: dereferencing 'void *' pointer
    odbc.c: At top level:
    odbc.c:779: warning: conflicting types for 'bind_columns'
    odbc.c:779: error: static declaration of 'bind_columns' follows non-static declaration
    odbc.c:201: error: previous implicit declaration of 'bind_columns' was here
    odbc.c: In function '_odbc_get_server_type':
    odbc.c:1449: error: label at end of compound statement
    make: ***  Error 1
    make: Leaving directory `/home/wayne/mdbtools-0.5/src/odbc'
    make: ***  Error 1
    make: Leaving directory `/home/wayne/mdbtools-0.5/src'
    make: ***  Error 1

     
  • Anonymous

    Anonymous - 2010-03-11

    So I figured this out…kinda.

    There are two issues with this.
    Issue 1:
    odbc.c:779: error: static declaration of 'bind_columns' follows non-static declaration
    odbc.c:201: error: previous implicit declaration of 'bind_columns' was here
    To fix this, go to line 779 and copy the function declaration, it should look something like:
    static void bind_columns(struct _hstmt *stmt){
    /*some code*/
    }
    copy this part:
    static void bind_columns(struct _hstmt *stmt)
    and on line 42 paste it after here(other locations are possible) what we are doing here is putting the 'prototype definition'  basically what this does is lets the compiler know that a function of this definition can be used and is declared somewhere in the file.  Don't forget to add a semi-colon(;) at the end of line 43 that you just pasted.  Line 43 should look like:
    static void bind_columns(struct _hstmt *stmt);

    Issue 2:
    odbc.c:1449: error: label at end of compound statement
    Go to line 1449 and you will see that this is an illegal swtich.
    replace:

    switch (clt_type) {
            case SQL_CHAR:
            case SQL_VARCHAR:
            case SQL_BIT:
            case SQL_TINYINT:
            case SQL_SMALLINT:
            case SQL_INTEGER:
            case SQL_DOUBLE:
            case SQL_DECIMAL:
            case SQL_NUMERIC:
            case SQL_FLOAT:
            }
    

    with:

    switch (clt_type) {
            case SQL_CHAR:
                    break;
            case SQL_VARCHAR:
                    break;
            case SQL_BIT:
                    break;
            case SQL_TINYINT:
                    break;
            case SQL_SMALLINT:
                    break;
            case SQL_INTEGER:
                    break;
            case SQL_DOUBLE:
                    break;
            case SQL_DECIMAL:
                    break;
            case SQL_NUMERIC:
                    break;
            case SQL_FLOAT:
                    break;
            }
    

    I suspect this is for write support.  If you look at the function below the one containing this switch
    You will see a similar switch with return statements.  You can use this function to complete the function with the switch we just edited but this is pointless because it's obviously not going to be used…if I do find out that this is required I MAY post back here if I remember to.

    Once I made these two changes, plus the edit required for the mdb_backend static function, I was able to compile and see the libs I need to use unixODBC with PHP using mdbtools.  Again, if I get this to work with PHP I will post it here.

     

Log in to post a comment.