- edited description
Windows static extension
It is possible to configure CMake to generate static SQLite extension under Windows? I only see a hardcoded add_definitions(-DNU_DYNAMIC_EXTENSION)
call in CMakeLists.txt
for the extension.
Comments (12)
-
reporter -
reporter - marked as minor
-
repo owner There is no static SQLite extension target in CMake currently, but it should be possible to just compile
nusqlite3.c
as any other C-source file, link with it (and nunicode) and then callnunicode_sqlite3_static_init()
somewhere in code. -
repo owner Check out
sqlite3/samples/autoextension.c
/sqlite3/samples/CMakeLists.txt
for example. -
reporter Thanks, that will be probably what I will do. I was just curious if there is something possible currently. I am planning using your extension inside a library, which includes SQLite and other code, so that everything is in a single DLL.
-
repo owner - marked as enhancement
The reason why there is no static target is because such static library would contain a single object file (
nusqlite3.c.o
). So there is not a lot of value, in my opinion, to build such target,nusqlite3.c
can be just added to a project and compiled along other files. But it's not hard to add this, for example:sqlite3/CMakeLists.txt
include_directories(${CMAKE_SOURCE_DIR} ${SQLITE3_INCLUDE_DIR} ".") if(NU_BUILD_SAMPLES) add_subdirectory(samples) endif(NU_BUILD_SAMPLES) link_libraries(nu) add_library(nusqlite3-static STATIC nusqlite3.c) add_library(nusqlite3 SHARED nusqlite3.c) set_target_properties(nusqlite3 PROPERTIES COMPILE_DEFINITIONS NU_DYNAMIC_EXTENSION=1)
sqlite3/samples/CMakeLists.txt
link_libraries(nu sqlite3) add_executable(../autoextension autoextension.c) target_link_libraries(../autoextension nusqlite3-static) add_executable(../loadextension loadextension.c)
And this produces
libnusqlite3-static.a
which is essentiallynusqlite3.c.o
ar'ed.Please let me know if there is any inconvenience with or without static SQLite3 extension, i'll keep this issue open for a while anyway.
-
repo owner By the way, while checking autoextension, i've found that it segfaults on SQLite 3.23.0. I've updated extension for newer SQLite in 67e9dc4 (no other changes). If you want to try it, when you will probably need updated
nusqlite3.c
, it's on master: https://bitbucket.org/alekseyt/nunicode/src/master/sqlite3/nusqlite3.c,git pull
will update it too if you have it cloned. It's going to be included into next release (this summer, around Unicode 11 release). -
reporter If I try to build the static nusqlite3, I get the following error in VC 2017:
Error C2375 'sqlite3_nunicode_init': redefinition; different linkage nusqlite3-static ...\sqlite3\nusqlite3.c 496
-
repo owner Sadly i don't have MSVC, so i can't check if it compiles or not with that compiler. You could try 66dfe6e, hopefully fixed.
-
reporter Excellent! Everything seems to work OK now. Thank you very much!
Could you please add the changes to the sqlite3/CMakeLists.txt above in the future commits?
-
repo owner Glad to hear it works. I'll review all the changes later and add static target for SQLite extension if i won't come up with anything against it. I'll update this issue.
-
repo owner - changed status to resolved
Added static SQLite extension target in 5025bca.
- Log in to comment