title: Create SQLite Database in Qt (C++)
body: <p>I'm trying to create a SQLite database in Qt. This is the code that I have:</p>
  
  <pre><code>#include &lt;QtCore/QCoreApplication&gt;
  #include &lt;QtSql/QSqlDatabase&gt;
  
  int main(int argc, char *argv[])
  {
      QCoreApplication a(argc, argv);
  
      QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
      db.setDatabaseName("C:\\Users\\Tanner\\Desktop\\db.sqlite");
  
      return a.exec();
  }
  </code></pre>
  
  <p>However, it doesn't work. This is the output I receive:</p>
  
  <blockquote>
    <p>C:\Users\Tanner\qt\sqltest-build-desktop..\sqltest\main.cpp:8: error:
    undefined reference to `<em>imp</em>__ZN12QSqlDatabase17defaultConnectionE'</p>
    
    <p>C:\Users\Tanner\qt\sqltest-build-desktop..\sqltest\main.cpp:8: error:
    undefined reference to `<em>imp</em>__ZN12QSqlDatabase11addDatabaseERK7QStringS2_'</p>
    
    <p>C:\Users\Tanner\qt\sqltest-build-desktop..\sqltest\main.cpp:8: error:
    undefined reference to `<em>imp</em>__ZN12QSqlDatabaseD1Ev'</p>
    
    <p>C:\Users\Tanner\qt\sqltest-build-desktop..\sqltest\main.cpp:9: error:
    undefined reference to `<em>imp</em>__ZN12QSqlDatabase15setDatabaseNameERK7QString'</p>
    
    <p>C:\Users\Tanner\qt\sqltest-build-desktop..\sqltest\main.cpp:11:
    error: undefined reference to `<em>imp</em>__ZN12QSqlDatabaseD1Ev'</p>
    
    <p>C:\Users\Tanner\qt\sqltest-build-desktop..\sqltest\main.cpp:11:
    error: undefined reference to `<em>imp</em>__ZN12QSqlDatabaseD1Ev'</p>
    
    <p>:-1: error: collect2: ld returned 1 exit status</p>
  </blockquote>
  
  <p>I'm sure that I'm doing something wrong as this is the first time I have tried to work with a database in C++/Qt. Any help in creating a database is greatly appreciated! I added an extra slash in the filepath because the compiler kept complaining about character escaping. Could the the extra slashes have anything to do with it? If so, how can I enter the path without it thinking I'm trying to escape the next character.</p>