Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

SQLAPI++ undefined reference error



  • Hi I want to use 3rd part library which is SQLAPI++. I try to include all header files and libs but when i run "Add Library" and select all paths, it gives me error while compiling " error: undefined reference to `SAConnection::SAConnection()' ". I use MinGW compiler and here is how my .pro file looks like

    TEMPLATE = app
    CONFIG += console c++11
    CONFIG += app_bundle
    CONFIG += qt
    
    SOURCES += \
            main.cpp
    
    
    
    
    INCLUDEPATH += C:\Users\Piotrek\Downloads\SQLAPI\include
    
    LIBS += -LC:\Users\Piotrek\Download\SQLAPI\lib
    
    win32:CONFIG(release, debug|release): LIBS += -llibsqlapi -llibsqlapid -llibsqlapiddll -llibsqlapidll -llibsqlapiu -llibsqlapiud -llibsqlapiuddll -llibsqlapiudll
    else:win32:CONFIG(debug, debug|release): LIBS += -llibsqlapi -llibsqlapid -llibsqlapiddll -llibsqlapidll -llibsqlapiu -llibsqlapiud -llibsqlapiuddll -llibsqlapiudll
    else:unix: LIBS += -llibsqlapi -llibsqlapid -llibsqlapiddll -llibsqlapidll -llibsqlapiu -llibsqlapiud -llibsqlapiuddll -llibsqlapiudll
    
    

    The SQLAPI++ comes with separated MinGW lib files (SQLAPI\lib and SQLAPI\MinGW_version\lib). First i tried to set the path to the SQLAPI\MinGW\libs folder but the problem still occured so i put them all into SQLAPI\lib directory and linked as you can see above, and still the same "undefined reference" error. The problem is i get this "undefined reference" all the time no matter what path i include, either SQLAPI\MinGW\lib or SQLAPI\lib . Maybe i should change kit form MinGW to Qt 5.12.1 MSVC 2017 but i have no idea how to connect msvc compiler to this kit ( i got Visual Studio Community 2019 ). My Qt Creator Version is 4.8.2 and QT 5.12.1 . I'm still learning so if there is something i understand incorrectly please explain it in your responses.

    Any answer would be appreciated.


  • Lifetime Qt Champion

    An include path is for headers, not for libraries. You have to define the lib to use in LIBS


  • Lifetime Qt Champion

    Hi
    Make sure your mingw compiler version matches the version used for the
    precompiled libs
    "The SQLAPI++ comes with separated MinGW lib files "

    And you cannot use visual studio with mingw libs.



  • @Christian-Ehrlicher Thank you for replay. I think i did define LIBS += path. Please check my .pro file if it is defined properly.


  • Lifetime Qt Champion

    Hi,

    To add to my fellows, did you also check that the architecture of your library matches the one of your application ?



  • @mrjj Thank you for your replay. I've checked my MinGW version and it's 7.3.0, in SQLAPI files there are only directory for MinGW_5.3, what should i do then ?

    ~"And you cannot use visual studio with mingw libs."
    I know, there are also folders for visual compiler, but i don't know how to connect QT 5.12.1 MSVC 2017 to a proper compiler. Can you please tell me how to do that or link a helpful article?
    Thank you.



  • @SGaist Tanks for response. I'm sorry but i don't know what you mean
    ~"the architecture of your library matches the one of your application"
    How to check that out?


  • Lifetime Qt Champion

    Hi
    Using visual studio with QT 5.12.1 MSVC 2017 requires you to download
    the compiler from microsoft and install it. Make sure only to select the c++
    component as else it installs a tons extra.
    https://visualstudio.microsoft.com/downloads/

    also make sure the architecture matches (as @SGaist says) , that is if 32 bit libs or 64 bit libs as you app need to be the same. (to load them)

    Its not really clear from their site what visual studio version they support.
    https://www.sqlapi.com/

    Hmm it seems fairly old versions ??

    MSVC++ Visual Studio 6, 2005 (x86 and x86-64), 2010 (x86 and x86-64), 2012 (x86 and x86-64), 2013 (x86 and x86-64), 2017 (x86 and x86-64)

    MinGW g++ version 3.4, 4.8 (TDM x86 and x86-64), 4.9 (TDM x86 and x86-64), 5.1 (TDM x86 and x86-64)

    Do you have a license ?
    it says "SQLAPI++ ships with all the sources."
    so you might end up in needing to compile them yourself as to match compiler
    for lib and app and Qt.
    https://www.sqlapi.com/ApiDoc/build-lib/



  • @mrjj Ok i will try to download this microsoft compiler.

    I don't have license, i use trial version unfortunately i don't know how to "build" this library, can you please link some sources where i can learn how to do that?

    I'm sorry if i'm being annoying but as i mentioned i'm still learning.
    Thank you for your responses.


  • Lifetime Qt Champion

    @PiotrWojtowicz
    Hi
    The build instructions is here
    https://www.sqlapi.com/ApiDoc/build-lib/
    but you need the source.

    You are not annoying at all. Just ask good/detailed questions and you get good
    answers :)

    I think using the trial version with visual studio can work
    MSVC++ Visual Studio 6, 2005 (x86 and x86-64), 2010 (x86 and x86-64), 2012 (x86 and x86-64), 2013 (x86 and x86-64), 2017 (x86 and x86-64)

    Note you need a MS account to get VS 2017.
    I think 2019 also will work since they are said to be compatible.

    make sure to only INSTALL the c++ part as else it will install GIGABYTES of
    stuff.
    alt text



  • @mrjj Hi
    First of all THANK YOU i will definitely give it a try and write soon if it works for me.

    However you really interested me with build option.
    I've checked the docs on SQLAPI++ out but still i don't know how to build that. Can you please give me a hand with that one?
    How to add these build options to qmake or mingw32-make command ?


  • Lifetime Qt Champion

    Hi
    The docs says
    "You should use appropriate batch file located in the src subdirectory of SQLAPI++ distribution (sqlapi_msvc.bat, sqlapi_bcc.bat, sqlapi_mingw.bat, sqlapi_gcc, sqlapi_ss). These files also allow to modify SQLAPI++ build options."

    So it sounds like you can just edit the right bat file (sqlapi_msvc.bat)
    and you should be able to set/unset the options needed/wanted.

    Also a note about the many databases supported.
    I would assume you will need to download their client libraries
    so you have their headers and such. Its unlikely the source contains all of these.


  • Lifetime Qt Champion

    @PiotrWojtowicz,

    I just wanted to mention the obvious: Qt already contains SQL drivers for popular databases, which includes very well into other parts of Qt.

    So whats your reason to use this SQLAPI?

    Regards



  • Ok guys thank you for help i eventually figure it out. Topic is closed.


  • Moderators

    @PiotrWojtowicz said in SQLAPI++ undefined reference error:

    Ok guys thank you for help i eventually figure it out.

    Great!

    Could you please share your solution in case it helps others?



  • @JKSH
    Yes i actually downloaded and installed MSVS c++ compiler then connected it to the MSVC 2017 Kit (its is compaible with 2019 microsoft sdk) and set the LIBS += path to msvc2019 lib directory. Thank you again for help!


Log in to reply