SQLite User Forum

Building sqlite3.exe for x64 with nmake
Login

Building sqlite3.exe for x64 with nmake

(1) By Adam Baxter (voltagex) on 2022-04-27 06:15:49 [link] [source]

Building sqlite3.exe from https://www.sqlite.org/snapshot/sqlite-snapshot-202204211938.tar.gz with nmake using the VS2022 toolset results in:


nmake /f Makefile.msc PLATFORM=x64
...


link.exe /DEBUG  /NOLOGO /MACHINE:x64 /DYNAMICBASE /NODEFAULTLIB:kernel32.lib mincore.lib /guard:cf "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib  /DLL  /OUT:winsqlite3.dll sqlite3.lo sqlite3res.lo
sqlite3.lo : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX86\x86\link.exe"' : return code '0x458'
Stop.

Forcing the "Developer Command Prompt" into 64 bit mode via VsDevCmd.bat -host_arch=amd64 -arch=amd64 and running nmake again results in

        link.exe /DEBUG  /NOLOGO /MACHINE:x64  /DLL /DEF:sqlite3.def /OUT:sqlite3.dll sqlite3.lo sqlite3res.lo
sqlite3.lo : warning LNK4197: export 'sqlite3_version' specified multiple times; using first specification
sqlite3.lo : warning LNK4197: export 'sqlite3_temp_directory' specified multiple times; using first specification
sqlite3.lo : warning LNK4197: export 'sqlite3_data_directory' specified multiple times; using first specification
   Creating library sqlite3.lib and object sqlite3.exp
sqlite3.lo : error LNK2019: unresolved external symbol _guard_dispatch_icall referenced in function sqlite3_rollback_hook
sqlite3.dll : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\link.exe"' : return code '0x460'
Stop.

What am I missing here? I'd like to use a 64 bit extension so I believe I need to build sqlite3.exe (and eventually the DLL) as 64 bit too.

(2) By Larry Brasfield (larrybr) on 2022-04-27 19:58:43 in reply to 1 [source]

I don't see what you are doing differently from what works fine for me.

I extracted that archive into a fresh directory, started the specialized shell, "x64 Native Tools Command Prompt for VS 2022", (via a Start menu shortcut left by the VS 2022 installation), navigated to that fresh directory, and ran "nmake /f Makefile.msc PLATFORM=x64" with no error output and got build products per the default make target.

This leads me to suspect that your "using the VS2022 toolset" means something different from what happens when using that handy shortcut I used.

The effect of running the batch files which get that specialized shell setup is limited to setting the environment. So by examining that, it should be possible to figure out how your pre-build preparation is going awry.

(3) By Adam Baxter (voltagex) on 2022-04-28 07:03:34 in reply to 2 [link] [source]

Thanks Larry. That pointed me in the right direction, I was using the wrong command prompt (environment setup) - the Developer Command Prompt is not the x64 Native Tools Command Prompt!