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:
${CMAKE_SOURCE_DIR}\file.cpp:34: error: undefined reference to `sqlite3_step'
${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:
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(chessdb
MANUAL_FINALIZATION
${PROJECT_SOURCES}
../external/sqlite3/sqlite3.c
../db.cpp ../game.cpp ../player.cpp ../Time.cpp ../TimeControl.cpp ../tool.cpp ../Tournament.cpp
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(chessdb
MANUAL_FINALIZATION
${PROJECT_SOURCES}
../external/sqlite3/sqlite3.c
../db.cpp ../game.cpp ../player.cpp ../Time.cpp ../TimeControl.cpp ../tool.cpp ../Tournament.cpp
)
To copy to clipboard, switch view to plain text mode
And I include the external directory like that :
target_include_directories(chessdb PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../external/sqlite3
)
target_link_libraries(chessdb PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_include_directories(chessdb PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../external/sqlite3
)
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
Bookmarks