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 [link] [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 [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.