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. Installing ODBC driver on Ubuntu getting syntax error after running "make"

Installing ODBC driver on Ubuntu getting syntax error after running "make"

Scheduled Pinned Locked Moved Solved General and Desktop
odbcdrivermakesql serverunixobdc
10 Posts 2 Posters 7.0k 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.
  • A Offline
    A Offline
    Amir5121
    wrote on 3 Jan 2017, 18:15 last edited by
    #1

    I'm trying to install ODBC driver to access a SQL Server Database.. After following the docs here and installing unixODBC from here

    after running

    cd $QTDIR/src/plugins/sqldrivers/odbc
    qmake "INCLUDEPATH+=/usr/local/unixODBC/include" "LIBS+=-L/usr/local/unixODBC/lib -lodbc"
    make
    

    I got a lot of syntax errors

    and still getting

    QSqlDatabase: QODBC driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 
    

    when running my code..

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 3 Jan 2017, 19:32 last edited by
      #2

      Hi and welcome to devnet,

      You are likely using the wrong qmake.

      Use the full path to your Qt 5.7 qmake.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Amir5121
        wrote on 3 Jan 2017, 20:17 last edited by
        #3

        Hi. thanks for the welcome and answer.. i was about to install Windows tbh

        and wow. apparently that was the issue now it compiled.. after that i was getting the same error

        QSqlDatabase: QODBC driver not loaded
        QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
        

        but managed to fix it by copy and pasting the compiled "libqsqlodbc.so" file to

        /home/amir/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers
        

        and

        /home/amir/Qt5.7.0/Tools/QtCreator/lib/Qt/plugins/sqldrivers
        

        but i am failing to open my connection. how can make sure it's working ?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 3 Jan 2017, 20:27 last edited by
          #4

          The open method returns a boolean value so you should check that and if false is returned then you should print the content returned by lastError.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • A Offline
            A Offline
            Amir5121
            wrote on 3 Jan 2017, 20:42 last edited by
            #5

            it says

            [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found QODBC3: Unable to connect
            
            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 3 Jan 2017, 20:54 last edited by
              #6

              What is your connection string ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • A Offline
                A Offline
                Amir5121
                wrote on 3 Jan 2017, 20:57 last edited by Amir5121 1 Mar 2017, 21:01
                #7

                DRIVER={SQL Server};Server=localhost\SQLEXPRESS;Database=honar;Uid=SA;Pwd=*******;

                and i'm using
                Microsoft SQL Server vNext (CTP1.1) - 14.0.100.187 (X64)
                Dec 10 2016 02:51:11
                Copyright (C) 2016 Microsoft Corporation. All rights reserved.
                on Linux (Ubuntu 16.04.1 LTS)

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 3 Jan 2017, 21:03 last edited by
                  #8

                  Did you check unixODBC without the GUI ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • A Offline
                    A Offline
                    Amir5121
                    wrote on 3 Jan 2017, 22:18 last edited by
                    #9

                    Dude you are awesome.. that error is solved but yet exist another one..

                    Failed "[unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: Error code 0x2AF9 [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Invalid connection string attribute QODBC3: Unable to connect"
                    

                    and this is the content of odbc.ini

                    [ODBC Driver 13 for SQL Server]
                    Description         = Microsoft ODBC Driver 13 for SQL Server
                    Driver              = /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.1.0
                    Trace               = Yes
                    TraceFile           = sql.log
                    Database            = 
                    Servername          = localhost
                    UserName            = 
                    Password            = 
                    Port                = 1433
                    Protocol            = 6.4
                    ReadOnly            = No
                    RowVersioning       = No
                    ShowSystemTables    = No
                    ShowOidColumn       = No
                    FakeOidIndex        = No
                    ConnSettings        =
                    

                    and odbcinst.ini

                    [ODBC Driver 13 for SQL Server]
                    Description=Microsoft ODBC Driver 13 for SQL Server
                    Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.1.0
                    Setup=/usr/local/lib/libodbc.so.2.0.0
                    UsageCount=1
                    
                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Amir5121
                      wrote on 3 Jan 2017, 23:30 last edited by
                      #10

                      @SGaist Thanks for your help.. it's successfuly got connected finally.. i changed localhost\sqlexpress to localhost and it got connected.. what ever sqlexpress is there for. Thanks again

                      1 Reply Last reply
                      0

                      4/10

                      3 Jan 2017, 20:27

                      • Login

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