You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VS2017 C++项目目录中添加sqlite3.h、sqlite3.dll并解决E1696错误

Hey there! Let's walk through how to properly add SQLite3 to your Visual Studio 2017 C++ project and fix that annoying E1696 "cannot open source file 'sqlite3.h'" error. Here's a step-by-step breakdown:

Step 1: Grab the Required SQLite3 Files

First, you'll need three key files for SQLite3 integration:

  • sqlite3.h: The header file that defines SQLite's API
  • sqlite3.lib: The import library needed for linking your project to the dynamic library
  • sqlite3.dll: The dynamic link library your program will load at runtime

You can get these from SQLite's official precompiled binaries page—just pick the package matching your project's architecture (32-bit or 64-bit).

Step 2: Organize Files in Your Project Directory

Keeping your project tidy will save you headaches later:

  • Create a subfolder in your project root (e.g., libs/sqlite) to store all SQLite files
  • Copy sqlite3.h, sqlite3.lib, and sqlite3.dll into this new folder
Step 3: Configure Visual Studio Project Settings

This is where we fix the E1696 error and set up proper linking. Open your project's properties by right-clicking the project in Solution Explorer and selecting Properties.

3.1 Tell Visual Studio Where to Find sqlite3.h

  • Navigate to Configuration Properties > C/C++ > General
  • Find the Additional Include Directories field, click the dropdown, and select <Edit...>
  • Add the path to your SQLite folder (e.g., $(ProjectDir)libs/sqlite—the $(ProjectDir) variable automatically points to your project's root directory)
  • Click OK to save this setting

3.2 Add the Library Directory for sqlite3.lib

  • Stay in the Properties window, go to Configuration Properties > Linker > General
  • In Additional Library Directories, add the same path to your SQLite folder (e.g., $(ProjectDir)libs/sqlite)
  • Save the change
  • Go to Configuration Properties > Linker > Input
  • In the Additional Dependencies field, add sqlite3.lib
  • Click OK to apply all project settings
Step 4: Make Sure sqlite3.dll is Available at Runtime

Since we're using a dynamic library, your program needs to find sqlite3.dll when it runs:

  • Manually copy sqlite3.dll into your project's output directory (e.g., x64/Debug or x86/Release—this is where your compiled .exe lives)
  • Or set up a post-build event to automate this:
    • Go to Configuration Properties > Build Events > Post-Build Event
    • In the Command Line box, paste: copy "$(ProjectDir)libs/sqlite/sqlite3.dll" "$(OutDir)"
    • Now the DLL will copy automatically every time you build your project
Troubleshooting the E1696 Error

If you still see the error after following the steps:

  • Double-check the path in Additional Include Directories—typos or wrong relative paths are common culprits
  • Ensure you've edited the settings for the correct configuration (Debug vs Release, x86 vs x64)—settings are per-configuration!
  • Verify that sqlite3.h is actually present in the folder you specified
  • Try closing and reopening Visual Studio—sometimes the IDE needs a refresh to pick up new settings

内容的提问来源于stack exchange,提问作者hannu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 17:02:46