fnc12/sqlite_orm

Windows linker error SQLite3

adamski opened this issue · 4 comments

I'm trying to integrate into a Windows CMake build and currently blocked as I can't seem to link it.

-- CPM: adding package sqliteOrm@1.8.2 (v1.8.2)
-- SQLITE_ORM: Build with C++14 features
-- Configuring sqlite_orm 1.8.0
-- Found SQLite3: C:/Users/Adam/dev/source/sayit/CoreLibrary/cmake-build-release/_deps/sqlite3-src (found version "3.42.0") 
CMake Error at C:/Users/Adam/AppData/Local/Programs/CLion Nova/bin/cmake/win/x64/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find SQLite3 (missing: SQLite3_INCLUDE_DIR SQLite3_LIBRARY)

I'm doing this to create the static lib but it does not seem to be creating it:


FetchContent_Declare(sqlite3 URL https://www.sqlite.org/2023/sqlite-amalgamation-3420000.zip)
if (NOT sqlite3_POPULATED)
      # notice that we do not call `add_subdirectory`, we simply fetch and then
      # use the subdirectory sources directly.
      FetchContent_Populate(sqlite3)
endif ()

add_library(sqlite3 STATIC
      ${sqlite3_SOURCE_DIR}/sqlite3.c
      ${sqlite3_SOURCE_DIR}/sqlite3ext.h
)

Fixed it - the sqlite.lib was being built I just needed to find and point to the location:

FetchContent_Declare(sqlite3 URL https://www.sqlite.org/2023/sqlite-amalgamation-3420000.zip)
if (NOT sqlite3_POPULATED)
        # notice that we do not call `add_subdirectory`, we simply fetch and then
        # use the subdirectory sources directly.
        FetchContent_Populate(sqlite3)
endif ()

add_library(sqlite3 STATIC
        ${sqlite3_SOURCE_DIR}/sqlite3.c
        ${sqlite3_SOURCE_DIR}/sqlite3ext.h
)


set (SQLite3_INCLUDE_DIR ${sqlite3_SOURCE_DIR})
set (SQLite3_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/sqlite3.lib)

@adamski Is it a problem related to sqlite_orm?

@trueqbit I think its due to how sqlite_orm depends on sqlite. It might be good to add this as an example for building and linking with a local sqlite lib rather than a system installed version.

closing cause due to comments the problem is over