x2bool x2bool - 9 months ago 55
C Question

How to fix "cannot find entry point sqlite3_open_v2 in DLL sqlite3" when compiling SQLite from the source code?

I am trying to compile sqlite from sources (amalgamation) to use it from C#. The reason to compile it myself rather than use precompiled version is that I need JSON support which is not included by default. This is how I compiled it:

cl sqlite3.c -DSQLITE_ENABLE_JSON1 -link -dll -out:sqlite3.dll

Then I tried to replace precompiled version of sqlite3.dll in my application with the version I compiled myself, and my C# application started to crash with EntryPointNotFoundException.

How to fix this, and what is the right way to compile SQLite?

Answer Source

The solution is to export the API functions:

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