SQLite Forum

Help Compiling SQLite for UWP ARM64
Login

Help Compiling SQLite for UWP ARM64

(1) By AlainBirchmeier on 2020-09-11 11:36:27 [link] [source]

Hi,

Sorry I'm pretty new to source compilation. I'm trying to build SQLite for UWP ARM64 so I can use it on HoloLens 2.

I followed the How to compile section from my Windows 10 pc :

  • Downloaded the Amalgamation sources
  • Open MSVC command console.
  • Executed `vcvars64.bat amd64_arm64 uwp 10.0.16299.0 for cross compilation of uwp dll (my laptop is x64 and i'm targeting UPW arm64)
  • I ran cl sqlite3.c -link -dll -out:sqlite3.dll

This output a dll, but when loaded on HoloLens 2, I got this error :


ERROR

EntryPointNotFoundException: Unable to find an entry point named 'sqlite3_libversion_number' in 'sqlite3'.


I don't know how to debug this problem, or if I did something wrong when compiling the source code.

I would really appreciate some support.

Thanks

(2.1) By Larry Brasfield (LarryBrasfield) on 2020-09-11 13:31:24 edited from 2.0 in reply to 1 [source]

Here is how to diagnose and fix this problem:

  1. Look through the source you are compiling to find where sqlite3_libversion_number is defined. (Use findstr or your editor's search.)

  2. Locate preprocessor conditionals (#ifdef, etc.) that are positioned to prevent that definition from being compiled.

  3. By study of those conditionals, determine what preprocessor symbols must be defined or given a specific value to get that definition compiled.

  4. Add options to your CL invocation such as -DSOME_SYMBOL or -DSOME_SYMBOL=1, as appear to be needed from your study of step 3.

  5. You can use DUMPBIN to see what named objects are defined in your binary.

I was tempted to do steps 1-4 and provide the answer, but this is such a fundamental developer skill that you need to learn it unless you intend to be merely a drudge for some real developer(s).

(3) By AlainBirchmeier on 2020-09-11 13:56:27 in reply to 2.1 [link] [source]

Thanks for the quick answer. I must say I haven't been through the source code and haven't thought that some preprocessor symbols were not defined. I'll follow your steps and come back to update on my state later :)

Thanks again

(4.1) By Larry Brasfield (LarryBrasfield) on 2020-09-11 17:06:04 edited from 4.0 in reply to 3 [link] [source]

After taking a look at the amalgamation source, and considering your stated problem more carefully, I have come to believe my advice is not what you needed. (It would be if a few API entry points were missing, but I think that is not the case here.)

Your problem is simple, and has resulted in all SQLite API entry points being not exported in your DLL.

Without recommending that you use what follows, here is what a modified version of Makefile.msc causes nmake to do to build a sqlite3.dll: cl -nologo -W4 -DINCLUDE_MSVC_H=1 -DSQLITE_OS_WIN=1 -I. -I. -fp:precise -MD -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=2 -DSQLITE_MAX_TRIGGER_DEPTH=100 -DSQLITE_DQS=0 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_DEFAULT_FOREIGN_KEYS=1 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK=1 -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_BYTECODE_VTAB -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION -DSQLITE_USE_URI -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_USE_ALLOCA -DSQLITE_DEFAULT_SYNCHRONOUS=3 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_REPLACE_INVALID_UTF -DSQLITE_DEFAULT_WORKER_THREADS=3 -Os -favor:blend -Fosqlite3.lo -Fdsqlite3.pdb -DSQLITE_API=__declspec(dllexport) -c sqlite3.c echo #ifndef SQLITE_RESOURCE_VERSION > sqlite3rc.h echo #define SQLITE_RESOURCE_VERSION 3,32,2 >> sqlite3rc.h echo #endif >> sqlite3rc.h rc -DSQLITE_OS_WIN=1 -I. -I. -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=2 -DSQLITE_MAX_TRIGGER_DEPTH=100 -DSQLITE_DQS=0 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_DEFAULT_FOREIGN_KEYS=1 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK=1 -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_BYTECODE_VTAB -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION -DSQLITE_USE_URI -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_USE_ALLOCA -DSQLITE_DEFAULT_SYNCHRONOUS=3 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_REPLACE_INVALID_UTF -DSQLITE_DEFAULT_WORKER_THREADS=3 -r -fo sqlite3res.lo .\sqlite3.rc link.exe ..\..\zlib-1.2.11\contrib\vstudio\vc14\x64\ZlibDllRelease\zlibwapi.lib /INCREMENTAL:NO /NOLOGO /MACHINE:x64 /DLL /OUT:sqlite3.dll sqlite3.lo sqlite3res.lo

There is a lot there, some of which you likely need or want and some not. However, this compilation flag, -DSQLITE_API=__declspec(dllexport) is quite important for ultimately getting a useful DLL. It causes the token, SQLITE_API, found on all SQLite exposed API definitions, to be substituted with a qualifier that tells the compiler to mark that name so that it ends up being among the exported symbols of the finally linked DLL. This can be seen in the following partial session screen scrape: > dumpbin /exports sqlite3.dll | findstr libversion 119 76 00001020 sqlite3_libversion 120 77 00001040 sqlite3_libversion_number >

I think, at your stage of developer development, that you might want to try using the Makefile.msc that comes with the amalgamation rather than rolling your own CL and LINK invocations. At the very least, you will benefit from studying that makefile.

(5) By anonymous on 2023-01-07 04:25:28 in reply to 4.1 [link] [source]

Hi anyone help in providing the details steps to compile the SQLite for UWP ARM.

(6) By Keith Medcalf (kmedcalf) on 2023-01-07 13:10:38 in reply to 1 [link] [source]

Windows does not export symbols from the DLL unless you tell it to do so either with a .def file or by marking the symbols you want exported.

Add -DSQLITE_API=__declspec(dllexport) to your command line before the source file name so that the SQLITE_API is exported.

(7) By anonymous on 2023-01-10 09:21:09 in reply to 6 [link] [source]

Where can we find .def file. Should we added the above command before the source filename in the parent directory->Sqlite. Could you elaborate on the above solution?

(8.1) By Keith Medcalf (kmedcalf) on 2023-01-10 17:13:34 edited from 8.0 in reply to 7 [link] [source]

The .def file is included with the amalgamation download, I believe. Otherwise, it is constructed when you run NMAKE against the full source tree and generate the amalgamation (sqlite3.c) because the Makefile.msc uses the .def method rather than __declspec(dllexport).

You said:

I ran cl sqlite3.c -link -dll -out:sqlite3.dll

Instead cl -DSQLITE_API=__declspec(dllexport) sqlite3.c -link -dll -out:sqlite3.dll

which would be the application of "insert -DSQLITE_API=__declspec(dllexport) to your command line before the source file name"

(9) By anonymous on 2023-01-12 04:03:38 in reply to 8.1 [link] [source]

Thanks for the quick reply. After generating the above command, sqlite3.dll got generated but without the version. Is there any way to generate sqlite3.dll specifying version.

(10) By Larry Brasfield (larrybr) on 2023-01-12 04:18:21 in reply to 9 [link] [source]

Is there any way to generate sqlite3.dll specifying version.

Download the amalgamation with configure, then study the file within named Makefile.msc . Pay particular attention to use of the resource compiler (rc.exe) and what is done with its output.

(11) By anonymous on 2023-01-23 17:21:08 in reply to 10 [link] [source]

Does USE_RC help to generate sqlite3.dll with version

cl -USE_RC=1 -DSQLITE_API=__declspec(dllexport) sqlite3.c -link -dll -out:sqlite3.dll

(12.1) By Larry Brasfield (larrybr) on 2023-01-23 18:03:25 edited from 12.0 in reply to 11 [link] [source]

Does USE_RC help to generate sqlite3.dll with version

cl -USE_RC=1 -DSQLITE_API=__declspec(dllexport) sqlite3.c -link -dll -out:sqlite3.dll

The file named Makefile.msc shows the usage of the symbol USE_RC. It is not passed to the compile/link driver known as CL.exe .

If learning to read a Makefile is to be avoided, you can perhaps still see some of what it does thusly: nmake -n -f Makefile.msc USE_RC=1 sqlite3.dll > mkdllrc.cmd , after which a study of the captured output, "mkdllrc.cmd", will show use of the resource compiler (rc.exe, invoked as "rc") to produce a file, "sqlite3res.lo", which is then linked with compiled code to produce "sqlite3.dll".