Built the DLL but getting Entry Point not found errors
(1) By Aask (AAsk1902) on 2024-09-28 01:10:11 [link] [source]
Following the instructions for Building a Windows DLL, I can build the DLL (using CL) without any reported errors.
However, on attempting to use the DLL I am getting entry point not found errors.
I am missing something but I'm not sure what as I am out of my depth.
My guess is that I EITHER need to export the functions in the DLL OR use SQLite.def (which is not included in the amalgamation source zip) in the build process.
I need some help overcoming the error.
(2.1) By Larry Brasfield (larrybr) on 2024-09-28 02:23:25 edited from 2.0 in reply to 1 [source]
Your guess is nearly spot-on. s/EITHER/BOTH/ and s/OR/AND/
Here is the output of doing "nmake -f Makefile.msc sqlite3.dll" in the project root directory:
> nmake -f Makefile.msc sqlite3.dllMicrosoft (R) Program Maintenance Utility Version 14.31.31104.0 Copyright (C) Microsoft Corporation. All rights reserved.
cl -nologo -W4 -DINCLUDE_MSVC_H=1 -DSQLITE_OS_WIN=1 -I. -I. -I.\src -fp:precise -MT -DNDEBUG -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_TEMP_STORE=1 -DSQLITE_MAX_TRIGGER_DEPTH=100 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_STMTVTAB=1 -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_ENABLE_BYTECODE_VTAB=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_MATH_FUNCTIONS -O2 -Zi -Fosqlite3.lo -Fdsqlite3.pdb -c sqlite3.c
sqlite3.c lib.exe /NOLOGO /MACHINE:x64 /OUT:libsqlite3.lib sqlite3.lo echo EXPORTS > sqlite3.def dumpbin /all libsqlite3.lib | tclsh .toolreplace.tcl include "^s+1 _?(sqlite3(?:session|changeset|changegroup|rebaser|rbu)?_[^@]*)(?:@d+)?$" 1 | sort >> sqlite3.def link.exe /DEBUG /NOLOGO /MACHINE:x64 /DLL /DEF:sqlite3.def /OUT:sqlite3.dll sqlite3.lo sqlite3res.lo
The important aspect here is the construction of sqlite3.def and its use in the link phase.
Note that a TCL installation (providing tclsh.exe in the PATH) is needed if the amalgamation and shell.c will have to be built. Above, they did not.
(4) By Aask (AAsk1902) on 2024-09-28 05:50:45 in reply to 2.1 [link] [source]
Thank you.
When I build from tarball, I have no (entry point not found) problems using the DLL.
(3) By Larry Brasfield (larrybr) on 2024-09-28 03:15:49 in reply to 1 [link] [source]
Another approach if you have only the amalgamation and wish to use the MSVC compiler:
cl /LD -DSQLITE_API=__declspec(dllexport) sqlite3.c
You can add other preprocessor symbol definitions and optimization flags to that invocation to suit your purposes.
(5) By Aask (AAsk1902) on 2024-09-28 06:08:29 in reply to 3 [link] [source]
Perfect!
cl /LD -DSQLITE_API=__declspec(dllexport) sqlite3.c
That worked perfectly.
Microsoft (R) Incremental Linker Version 14.29.30154.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:sqlite3.dll
/dll
/implib:sqlite3.lib
sqlite3.obj
Creating library sqlite3.lib and object sqlite3.exp
I assume that the DLL thus created has no dependency on the .obj, .lib and .exp files also created; I can easily test this.
You can add other preprocessor symbol definitions and optimization flags to that invocation to suit your purposes.
As yet, I have no need for further optimisation.
I wanted to build from the amalgamation so that I could create both the x86 and x64 versions of the CLI and (thought I'll carry on with) the library. The pre-compiled version of the CLI is 64-bit; I realise that the pre-compiled DLL downloads come in both flavours. However, with this knowledge, I can create the DLL from older amalgamation and/or interim releases.
Thank you.