I did some changes on qsql_db2 in order to compile it, did I brake the drivers?



  • I was trying to compile the db2 drivers for mac and constantly getting the error bellow

    @sudo /Users/administrator/Qt/5.3/clang_64/bin/qmake "INCLUDEPATH+=/opt/IBM/db2/V10.1/include" "LIBS+=-L/opt/IBM/db2/V10.1/lib64 -ldb2"

    make
    ../../../sql/drivers/db2/qsql_db2.cpp:1143:15: error: cast from pointer to smaller type 'SQLHANDLE' (aka 'int') loses information
    d->hEnv = (SQLHANDLE)env;
    ^~~~~~~~~~~~~~
    ../../../sql/drivers/db2/qsql_db2.cpp:1144:15: error: cast from pointer to smaller type 'SQLHANDLE' (aka 'int') loses information
    d->hDbc = (SQLHANDLE)con;
    ^~~~~~~~~~~~~~
    ../../../sql/drivers/db2/qsql_db2.cpp:1208:66: warning: cast to 'void *' from smaller integer type 'SQLUINTEGER' (aka 'unsigned int')
    [-Wint-to-void-pointer-cast]
    r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_ACCESS_MODE, (SQLPOINTER) v, 0);
    ^
    ../../../sql/drivers/db2/qsql_db2.cpp:1211:68: warning: cast to 'void *' from smaller integer type 'SQLUINTEGER' (aka 'unsigned int')
    [-Wint-to-void-pointer-cast]
    r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) v, 0);
    ^
    ../../../sql/drivers/db2/qsql_db2.cpp:1510:13: warning: enumeration value 'CancelQuery' not handled in switch [-Wswitch]
    switch (f) {
    ^
    ../../../sql/drivers/db2/qsql_db2.cpp:1583:39: warning: cast to 'void *' from smaller integer type 'SQLUINTEGER' (aka 'unsigned int')
    [-Wint-to-void-pointer-cast]@

    So I changed qsql_db2 lines 1143 and 1144 to this

    @ d->hEnv = (SQLHANDLE)&env;
    d->hDbc = (SQLHANDLE)&con;@

    This way it did compile but when I try to connect to the server I get an error about the environment handles

    QDB2Driver::open: Unable to allocate environment

    If I am not wrong the part I changed has to do with those handles.

    So is it my fault that I can't connect (I can connect just fine in windows) and if yes, is there a way to avoid the errors during the build process and have a functioning driver in the end?

    Thanks.



  • I am still struggling with this. Could it be a bug? The developers give a warning inside qsql_db2_p.h

    @// W A R N I N G
    // -------------
    //
    // This file is not part of the Qt API. It exists purely as an
    // implementation detail. This header file may change from version to
    // version without notice, or even be removed.
    //
    // We mean it.@

    Plus I read that you should never cast to void, so I am starting to believe that this is not my fault but it must be a universal thing for all users. Until now I haven't found someone trying to compile those drivers though. I will update if I find something useful.



  • I think I am able to identify the problem better now. I can't rule out the possibility that the changes I did to the source file may cause a problem later on but this error is actually caused by the dependencies you have to use. It seems that using libdb2.dylib that comes with db2 won't do.

    Instead you need the one provided by the clidriver. The thing is that IBM does not provide a mac version. I figured this out while trying to run my app on my deployment machine for windows. I experienced the same error as in Mac because I accidentally put the wrong libraries in. Once changed it worked fine again, so the same thing probably causes the mac errors.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.