Results 1 to 2 of 2

Thread: Cannot compile sqlite

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2025
    Posts
    1
    Platforms
    Windows

    Default Cannot compile sqlite

    Hi everyone,

    I'm new to QtCreator.
    I have a small C++ project that adds chess tournaments/games/players in a SQLite database (for statistics), and I want to develop a UI for it.

    But I have an issue and I dont find a way to resolve it
    I'm getting linker errors like:

    Qt Code:
    1. ${CMAKE_SOURCE_DIR}\file.cpp:34: error: undefined reference to `sqlite3_step'
    To copy to clipboard, switch view to plain text mode 
    This happens for every file that uses SQLite functions.

    I have #include <sqlite3.h> in my code (I also tried #include "sqlite3.h") and everything works well when I compile with g++ g++ -std=c++17 -Wall -Wextra -g -o exe time.o timecontrol.o player.o tournament.o game.o main.o db.o tool.o -lsqlite3 and use ./exe in the shell.


    All the SQLite sources (sqlite3.c, sqlite3.h, sqlite3ext.h) are into an external/sqlite3 directory, and the qcreator projet is in chessdb directory.
    .
    My CMakeLists.txt adds ../external/sqlite3/sqlite3.c to the sources for the executable, like this:
    Qt Code:
    1. if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
    2. qt_add_executable(chessdb
    3. MANUAL_FINALIZATION
    4. ${PROJECT_SOURCES}
    5. ../external/sqlite3/sqlite3.c
    6. ../db.cpp ../game.cpp ../player.cpp ../Time.cpp ../TimeControl.cpp ../tool.cpp ../Tournament.cpp
    7. )
    To copy to clipboard, switch view to plain text mode 

    And I include the external directory like that :
    Qt Code:
    1. target_include_directories(chessdb PRIVATE
    2. ${CMAKE_CURRENT_SOURCE_DIR}/../external/sqlite3
    3. )
    4.  
    5. target_link_libraries(chessdb PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
    To copy to clipboard, switch view to plain text mode 



    The file sqlite3.c appears in the source tree in QtCreator, but during build, there is no step compiling sqlite3.c (sqlite3.c.obj is never created).


    What could I be missing in the CMakeLists.txt ?

    Thanks for your answers
    Last edited by d_stranz; 7th July 2025 at 16:55. Reason: missing [code] tags

Similar Threads

  1. Replies: 14
    Last Post: 1st January 2016, 03:03
  2. [Qt][SQLite] Two problems with SQLite.
    By Xandareva in forum Newbie
    Replies: 6
    Last Post: 6th April 2010, 23:06
  3. Cannot load SQLITE driver on clean target
    By ForestDweller in forum Installation and Deployment
    Replies: 1
    Last Post: 15th December 2008, 00:49
  4. cannot compile the MainWindow example with vs2005
    By billconan in forum Qt Programming
    Replies: 5
    Last Post: 31st May 2008, 18:27
  5. Newbie:cannot compile - moc'ing error
    By publicENEMY in forum Installation and Deployment
    Replies: 2
    Last Post: 1st June 2006, 07:55

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.