Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I did some changes on qsql_db2 in order to compile it, did I brake the drivers?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 952 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ealioneE Offline
    ealioneE Offline
    ealione
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • ealioneE Offline
      ealioneE Offline
      ealione
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • ealioneE Offline
        ealioneE Offline
        ealione
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved