Compiling SQLite for Windows (64-bit) Compiling SQLite for Windows (64-bit) sqlite sqlite

Compiling SQLite for Windows (64-bit)


You are compiling to an EXE. Calling it a DLL won't magically make it a DLL.

You need to pass special linker options to gcc to make it create DLLs.Quoted from Mingw site: (Sort of, I replaced g++ with gcc)

gcc -c -DBUILDING_EXAMPLE_DLL example_dll.cppgcc -shared -o example_dll.dll example_dll.o -Wl,--out-implib,libexample_dll.a

The page also explains that functions you want your DLL to export, must be declared with __declspec(dllexport). (Further down, there is an example on how to export all global functions to the DLL, like usually happens in Unix.)

The -Wl argument to gcc is what tells gcc to pass on the further arguments --out-implib,libexample_dll.a to the linker.

I would also make 100% sure that the built DLL is actually a 64 bit DLL and not a 32 bit DLL. Do you have any way to check that? On Linux you can run the "file" command.

You can also try adding the -m64 option to the gcc commandline, that should force gcc to target the amd64 target.

If that doesn't work, you may have the wrong compiler altogether. Make sure you have the x86_64/amd64 version of the Mingw toolchain. Installation is as simple as finding the right ZIP, unpacking it, and setting the path.

If all of that fails, or if you just want to verify against a supposedly correctly compiled setup, try precompiled 64-bit binaries here or from here.


What would work in your case is this single link-and-compile command:

g++ -shared-DWIN64-DNDEBUG-D_WINDOWS-D_USRDLL-DNO_TCL-D_CRT_SECURE_NO_DEPRECATE-DTHREADSAFE=1-DTEMP_STORE=1-DSQLITE_MAX_EXPR_DEPTH=0-I.shell.c sqlite3.c-o sqlite_x64.dll-Wl,--out-implib,libsqllite_x64.dll.a

The compile and link stage will be performed at once. The defined can be added on the commandline. The headers need not be compiled, but you need to pass the current directory as a header search directory, and specify the names of the dll and import file.