{"id":19187,"date":"2025-03-06T20:34:04","date_gmt":"2025-03-06T12:34:04","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=19187"},"modified":"2025-05-04T22:01:51","modified_gmt":"2025-05-04T14:01:51","slug":"visual-studio-2022-%e4%bd%bf%e7%94%a8-c-%e8%bf%9e%e6%8e%a5-sqlite3","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=19187","title":{"rendered":"Visual Studio 2022 \u4e0b C++ \u8c03\u7528 SQLite3 \u73af\u5883\u914d\u7f6e"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor:pointer\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.iyatt.com\/?p=19187\/#%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83\" >\u6d4b\u8bd5\u73af\u5883<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.iyatt.com\/?p=19187\/#%E5%BC%80%E5%8F%91%E4%B8%AD%E4%BD%BF%E7%94%A8%E5%8A%A8%E6%80%81%E5%BA%93\" >\u5f00\u53d1\u4e2d\u4f7f\u7528\u52a8\u6001\u5e93<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.iyatt.com\/?p=19187\/#%E5%87%86%E5%A4%87_SQLite3_%E5%BA%93%E6%96%87%E4%BB%B6\" >\u51c6\u5907 SQLite3 \u5e93\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.iyatt.com\/?p=19187\/#%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE\" >\u521b\u5efa\u9879\u76ee<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.iyatt.com\/?p=19187\/#%E6%B5%8B%E8%AF%95\" >\u6d4b\u8bd5<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.iyatt.com\/?p=19187\/#SQLite3_%E5%91%BD%E4%BB%A4%E5%B7%A5%E5%85%B7\" >SQLite3 \u547d\u4ee4\u5de5\u5177<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.iyatt.com\/?p=19187\/#Window_%E6%9C%AC%E5%9C%B0%E7%BC%96%E7%A0%81%E5%AE%BD%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%92%8C_UTF-8_%E7%AA%84%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%BA%92%E7%9B%B8%E8%BD%AC%E6%8D%A2\" >Window \u672c\u5730\u7f16\u7801\u5bbd\u5b57\u7b26\u4e32\u548c UTF-8 \u7a84\u5b57\u7b26\u4e32\u4e92\u76f8\u8f6c\u6362<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/blog.iyatt.com\/?p=19187\/#%E5%AE%9E%E6%88%98%E6%A1%88%E4%BE%8B\" >\u5b9e\u6218\u6848\u4f8b<\/a><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83\"><\/span>\u6d4b\u8bd5\u73af\u5883<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<ul>\n<li>Windows 11 24H2 64\u4f4d<\/li>\n<li>Visual Studio 2022\uff08\u5df2\u5b89\u88c5<strong>\u4f7f\u7528 C++ \u7684\u684c\u9762\u5f00\u53d1\uff09<\/strong><\/li>\n<li>SQLite 3.49.1<\/li>\n<\/ul>\n<h1><span class=\"ez-toc-section\" id=\"%E5%BC%80%E5%8F%91%E4%B8%AD%E4%BD%BF%E7%94%A8%E5%8A%A8%E6%80%81%E5%BA%93\"><\/span>\u5f00\u53d1\u4e2d\u4f7f\u7528\u52a8\u6001\u5e93<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u8fd9\u91cc\u662f\u4ee5\u5df2\u7ecf\u7f16\u8bd1\u597d\u7684\u52a8\u6001\u5e93\u7684\u65b9\u5f0f\u4f7f\u7528 SQLite3\u3002SQLite3 \u662f\u5f00\u6e90\u7684\uff0c\u4e14 Public Domain\uff0c\u76f4\u63a5\u628a\u5b83\u7684\u6e90\u7801\u653e\u8fdb\u81ea\u5df1\u7684\u9879\u76ee\u91cc\u4e00\u8d77\u7f16\u8bd1\u4e5f\u662f\u6ca1\u6709\u987e\u8651\u7684\uff0c\u8fd9\u6837 SQLite3 \u7684\u6e90\u7801\u5c31\u6210\u81ea\u5df1\u9879\u76ee\u7684\u4e00\u90e8\u5206\u4e86\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E5%87%86%E5%A4%87_SQLite3_%E5%BA%93%E6%96%87%E4%BB%B6\"><\/span>\u51c6\u5907 SQLite3 \u5e93\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>SQLite \u5b98\u7f51\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/www.sqlite.org\/download.html\">https:\/\/www.sqlite.org\/download.html<\/a><br \/>\n\u4e0b\u8f7d\u5408\u5e76\u7248\u6e90\u6587\u4ef6\u548c Windows x64 \u7248\u5e93\u6587\u4ef6<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741261496045.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 1137px; --smush-placeholder-aspect-ratio: 1137\/1074;\" \/><\/p>\n<p>\u89e3\u538b\u5e93\u6587\u4ef6\u5305\uff0c\u5c06\u6587\u4ef6\u5939\u91cd\u547d\u540d\u4e3a <strong>sqlite<\/strong><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741257528303.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 681px; --smush-placeholder-aspect-ratio: 681\/229;\" \/><\/p>\n<p>\u89e3\u538b\u6e90\u6587\u4ef6\u5305\u540e\uff0c\u5c06\u91cc\u9762\u7684 <strong>.h<\/strong> \u6587\u4ef6\u590d\u5236\u5230\u4e0a\u9762\u5e93\u6587\u4ef6\u7684 sqlite \u6587\u4ef6\u5939\u4e2d<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741261767755.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 858px; --smush-placeholder-aspect-ratio: 858\/282;\" \/><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741261792893.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 653px; --smush-placeholder-aspect-ratio: 653\/290;\" \/><\/p>\n<p>\u6253\u5f00 VS \u7684\u5de5\u5177\u547d\u4ee4\u884c <strong>x64 Native Tools Command Prompt for VS 2022<\/strong><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741257656845.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 767px; --smush-placeholder-aspect-ratio: 767\/739;\" \/><\/p>\n<p>\u5207\u6362\u5230 <strong>sqlite<\/strong> \u6587\u4ef6\u5939<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741257736634.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 704px; --smush-placeholder-aspect-ratio: 704\/268;\" \/><\/p>\n<p>\u6267\u884c\u547d\u4ee4\u5bfc\u51fa lib \u6587\u4ef6<\/p>\n<pre><code class=\"language-bash\">LIB \/MACHINE:X64 \/DEF:sqlite3.def<\/code><\/pre>\n<p><img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741257974474.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 607px; --smush-placeholder-aspect-ratio: 607\/105;\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE\"><\/span>\u521b\u5efa\u9879\u76ee<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u8fd9\u91cc\u5c31\u65b0\u5efa\u4e00\u4e2a\u7a7a\u9879\u76ee<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741261889268.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 993px; --smush-placeholder-aspect-ratio: 993\/390;\" \/><\/p>\n<p><img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741262416186.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 1012px; --smush-placeholder-aspect-ratio: 1012\/669;\" \/><\/p>\n<p>\u5728\u9879\u76ee\u4e0a\u53f3\u952e<strong>\u5728\u6587\u4ef6\u8d44\u6e90\u7ba1\u7406\u5668\u4e2d\u6253\u5f00\u6587\u4ef6\u5939<\/strong><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741262446479.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 520px; --smush-placeholder-aspect-ratio: 520\/995;\" \/><\/p>\n<p>\u628a\u4e0a\u9762\u914d\u7f6e\u597d\u7684 sqlite \u6587\u4ef6\u5939\u590d\u5236\u8fdb\u53bb<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741262506710.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 727px; --smush-placeholder-aspect-ratio: 727\/340;\" \/><\/p>\n<p><strong>\u6e90\u6587\u4ef6<\/strong>\u4e0a\u53f3\u952e<strong>\u6dfb\u52a0<\/strong>-&gt;<strong>\u65b0\u5efa\u9879<\/strong><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741262766445.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 938px; --smush-placeholder-aspect-ratio: 938\/529;\" \/><\/p>\n<p>\u65b0\u5efa\u4e00\u4e2a test.cpp \u6587\u4ef6<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741262816642.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 441px; --smush-placeholder-aspect-ratio: 441\/170;\" \/><\/p>\n<p>\u5728\u9879\u76ee\u4e0a\u53f3\u952e\u5c5e\u6027<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741262537873.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 549px; --smush-placeholder-aspect-ratio: 549\/975;\" \/><\/p>\n<p>\u5728<strong>C\/C++<\/strong>-&gt;<strong>\u5e38\u89c4<\/strong>\u4e0b\uff0c<strong>\u9644\u52a0\u5305\u542b\u76ee\u5f55<\/strong>\u628a<strong>sqlite<\/strong>\u76ee\u5f55\u6dfb\u52a0\u8fdb\u53bb<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741266568520.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 787px; --smush-placeholder-aspect-ratio: 787\/548;\" \/><\/p>\n<p>\u5728<strong>\u94fe\u63a5\u5668<\/strong>-&gt;<strong>\u5e38\u89c4<\/strong>\u4e0b\uff0c<strong>\u9644\u52a0\u5e93\u76ee\u5f55<\/strong>\u628a<strong>sqlite<\/strong>\u76ee\u5f55\u6dfb\u52a0\u8fdb\u53bb<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741266606795.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 783px; --smush-placeholder-aspect-ratio: 783\/672;\" \/><\/p>\n<p>\u5728<strong>\u94fe\u63a5\u5668<\/strong>-&gt;<strong>\u8f93\u5165<\/strong>\u4e0b\uff0c<strong>\u9644\u52a0\u4f9d\u8d56\u9879<\/strong>\u6dfb\u52a0<strong>sqlite3.lib<\/strong><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741266198737.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 797px; --smush-placeholder-aspect-ratio: 797\/617;\" \/><\/p>\n<p>\u5728<strong>\u8c03\u8bd5<\/strong>\u91cc\uff0c\u73af\u5883\u4e2d\u586b\u5165<strong>PATH=sqlite\u6587\u4ef6\u6240\u5728\u76ee\u5f55<\/strong>\uff0c\u6bd4\u5982\u6211\u8fd9\u91cc\u5199<strong>PATH=D:\\work\\development\\MFC\\Project1\\sqlite<\/strong>\u3002<br \/>\n\u8fd9\u4e00\u6b65\u662f\u8c03\u8bd5\u7684\u65f6\u5019\u4fdd\u8bc1\u7a0b\u5e8f\u53ef\u4ee5\u94fe\u63a5\u5230 <strong>sqlite3.dll<\/strong> \u6587\u4ef6\uff0c\u5982\u679c\u8981\u5c06\u6700\u7ec8\u6784\u5efa\u7684\u7a0b\u5e8f\u53d1\u5e03\u51fa\u53bb\uff0c\u8981\u590d\u5236\u4e00\u4efd <strong>sqlite3.dll<\/strong> \u5230\u6784\u5efa\u7684\u7a0b\u5e8f\u6587\u4ef6\u540c\u76ee\u5f55\u4e0b\uff0c\u6216\u8005\u6dfb\u52a0\u5230\u7cfb\u7edf PATH \u53d8\u91cf\u76ee\u5f55\u4e2d<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741264055900.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 788px; --smush-placeholder-aspect-ratio: 788\/706;\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E6%B5%8B%E8%AF%95\"><\/span>\u6d4b\u8bd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5728\u524d\u9762\u521b\u5efa\u7684 test.cpp \u4e2d\u5199\u5165<br \/>\n\u6ce8\u610f SQLite3 \u662f\u4e00\u4e2a C \u8bed\u8a00\u9879\u76ee\uff0c\u5728 C++ \u4e2d\u4f7f\u7528\u6700\u597d\u6dfb\u52a0\u4e0a <strong>extern &quot;C&quot;<\/strong><\/p>\n<pre><code class=\"language-cpp\">extern &quot;C&quot;\n{\n    #include &quot;sqlite3.h&quot;\n}\n\n#include &lt;iostream&gt;\n\nint main()\n{\n    sqlite3* db;  \/\/ \u53e5\u67c4\n    if (sqlite3_open(&quot;test.db&quot;, &amp;db) != SQLITE_OK)  \/\/ \u6253\u5f00\u6570\u636e\u5e93\n    {\n        std::cerr &lt;&lt; &quot;\u6253\u5f00\u6570\u636e\u5e93\u5931\u8d25\uff01&quot; &lt;&lt; std::endl; \/\/ \u9519\u8bef\u4fe1\u606f\n        return 1;\n    }\n    else\n    {\n        std::cout &lt;&lt; &quot;\u6253\u5f00\u6570\u636e\u5e93\u6210\u529f\uff01&quot; &lt;&lt; std::endl;\n    }\n    sqlite3_close(db);  \/\/ \u5173\u95ed\u6570\u636e\u5e93\n}<\/code><\/pre>\n<p><img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741264361061.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 849px; --smush-placeholder-aspect-ratio: 849\/182;\" \/><\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u521b\u5efa\u4e86\u4e00\u4e2a SQLite3 \u6570\u636e\u5e93\u6587\u4ef6<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741264396986.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 749px; --smush-placeholder-aspect-ratio: 749\/414;\" \/><\/p>\n<h1><span class=\"ez-toc-section\" id=\"SQLite3_%E5%91%BD%E4%BB%A4%E5%B7%A5%E5%85%B7\"><\/span>SQLite3 \u547d\u4ee4\u5de5\u5177<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u4e0b\u8f7d<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741268160653.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 1327px; --smush-placeholder-aspect-ratio: 1327\/1044;\" \/><\/p>\n<p>\u89e3\u538b\u653e\u7f6e\u5230\u67d0\u4e2a\u56fa\u5b9a\u8def\u5f84<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741268209494.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 644px; --smush-placeholder-aspect-ratio: 644\/251;\" \/><\/p>\n<p>\u628a\u8fd9\u4e2a\u8def\u5f84\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf<strong>PATH<\/strong>\u4e2d<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741268251593.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 619px; --smush-placeholder-aspect-ratio: 619\/758;\" \/><\/p>\n<p>\u67e5\u770b\u7248\u672c<\/p>\n<pre><code class=\"language-bash\">sqlite3 --version<\/code><\/pre>\n<p><img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1741269021887.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 946px; --smush-placeholder-aspect-ratio: 946\/148;\" \/><\/p>\n<h1><span class=\"ez-toc-section\" id=\"Window_%E6%9C%AC%E5%9C%B0%E7%BC%96%E7%A0%81%E5%AE%BD%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%92%8C_UTF-8_%E7%AA%84%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%BA%92%E7%9B%B8%E8%BD%AC%E6%8D%A2\"><\/span>Window \u672c\u5730\u7f16\u7801\u5bbd\u5b57\u7b26\u4e32\u548c UTF-8 \u7a84\u5b57\u7b26\u4e32\u4e92\u76f8\u8f6c\u6362<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>Windows \u4e0b\u9ed8\u8ba4\u7684\u7f16\u7801\u4e0d\u662f UTF-8\uff0c\u800c\u662f\u6839\u636e\u8bbe\u7f6e\u8bed\u8a00\u53d8\u5316\u7684\uff0c\u4e2d\u6587\u4e0b\u5c31\u662f GBK\uff0c\u57fa\u4e8e Visual Studio \u5f00\u53d1 Windows \u5e94\u7528\u7684\u65f6\u5019\u9ed8\u8ba4\u7f16\u7801\u662f Unicode\uff08UTF-16LE\uff09\uff0c\u5728\u8fd9\u79cd\u72b6\u6001\u4e0b\u9ed8\u8ba4\u4f7f\u7528\u7684\u662f\u5bbd\u5b57\u7b26\u4e32\uff0c\u800c SQLite3 \u5728\u4e0d\u6307\u5b9a\u7f16\u7801\u7684\u60c5\u51b5\u4e0b\u9ed8\u8ba4\u4f7f\u7528 UTF-8\uff0c\u800c\u4e14\u662f\u7a84\u5b57\u7b26\u4e32\uff0c\u6240\u4ee5\u5982\u679c\u662f\u5728\u57fa\u4e8e Visual Studio \u5f00\u53d1 Windows \u5e94\u7528\uff0c\u8fd8\u9700\u8981\u548c SQLite3 \u4ea4\u4e92\u7684\u8bdd\uff0c\u5f88\u5927\u53ef\u80fd\u9700\u8981\u8fdb\u884c\u8f6c\u6362\uff08\u6211\u7684\u89c2\u70b9\u662f\u4e0d\u6539\u52a8\u73af\u5883\uff0c\u800c\u662f\u8ba9\u5f00\u53d1\u8005\u5199\u7684\u4e1c\u897f\u9002\u5e94\u9ed8\u8ba4\u73af\u5883\uff0c\u8fd9\u6837\u51fa\u9519\u7684\u53ef\u80fd\u6027\u5c31\u5c0f\uff09\u3002<\/p>\n<p>\u4f7f\u7528\u4e0b\u9762\u4ee3\u7801\u6ce8\u610f\u624b\u52a8\u91ca\u653e\u8fd4\u56de\u503c\u7684\u5b57\u7b26\u4e32\uff08<strong>delete[] \u5b57\u7b26\u4e32\u6307\u9488<\/strong>\uff09\uff0c\u4e24\u6bb5\u4ee3\u7801\u90fd\u662f\u57fa\u4e8e Windows API\uff0c\u9700\u8981\u5f15\u7528\u5934\u6587\u4ef6 <strong>Windows.h<\/strong><\/p>\n<pre><code class=\"language-cpp\">char* gbkToUtf8(const WCHAR* gbkStr)\n{\n    \/\/ \u83b7\u53d6\u5bbd\u5b57\u7b26\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\n    int wideCharLen = wcslen(gbkStr) + 1; \/\/ \u5305\u62ec\u7ed3\u5c3e\u7684 &#039;\\0&#039;\n    if (wideCharLen &lt;= 0)\n    {\n        return nullptr; \/\/ \u5982\u679c\u5b57\u7b26\u4e32\u4e3a\u7a7a\uff0c\u76f4\u63a5\u8fd4\u56de nullptr\n    }\n\n    \/\/ \u83b7\u53d6\u9700\u8981\u7684 UTF-8 \u7f16\u7801\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\uff08\u5305\u62ec\u7ed3\u5c3e\u7684 &#039;\\0&#039;\uff09\n    int utf8Len = WideCharToMultiByte(CP_UTF8, 0, gbkStr, -1, nullptr, 0, nullptr, nullptr);\n    if (utf8Len &lt;= 0)\n    {\n        return nullptr; \/\/ \u5982\u679c\u8f6c\u6362\u5931\u8d25\uff0c\u8fd4\u56de nullptr\n    }\n\n    \/\/ \u5206\u914d\u5185\u5b58\u7528\u4e8e\u5b58\u50a8 UTF-8 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\n    char* utf8Str = new char[utf8Len];\n\n    \/\/ \u6267\u884c\u8f6c\u6362\n    if (WideCharToMultiByte(CP_UTF8, 0, gbkStr, -1, utf8Str, utf8Len, nullptr, nullptr) == 0)\n    {\n        delete[] utf8Str; \/\/ \u5982\u679c\u8f6c\u6362\u5931\u8d25\uff0c\u91ca\u653e\u5df2\u5206\u914d\u7684\u5185\u5b58\n        return nullptr;\n    }\n\n    return utf8Str; \/\/ \u8fd4\u56de\u8f6c\u6362\u540e\u7684 UTF-8 \u5b57\u7b26\u4e32\n}<\/code><\/pre>\n<pre><code class=\"language-cpp\">WCHAR* utf8ToGbk(const char* utf8Str)\n{\n    \/\/ \u83b7\u53d6\u5bbd\u5b57\u7b26\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\n    int wideCharLen = MultiByteToWideChar(CP_UTF8, 0, utf8Str, -1, nullptr, 0);\n    if (wideCharLen &lt;= 0)\n    {\n        return nullptr; \/\/ \u5982\u679c\u8f6c\u6362\u5931\u8d25\uff0c\u8fd4\u56de nullptr\n    }\n\n    \/\/ \u5206\u914d\u5185\u5b58\u7528\u4e8e\u5b58\u50a8\u5bbd\u5b57\u7b26\u5b57\u7b26\u4e32\n    WCHAR* wideCharStr = new WCHAR[wideCharLen];\n    MultiByteToWideChar(CP_UTF8, 0, utf8Str, -1, wideCharStr, wideCharLen);\n\n    \/\/ \u83b7\u53d6 GBK \u7f16\u7801\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\n    int gbkLen = WideCharToMultiByte(CP_ACP, 0, wideCharStr, -1, nullptr, 0, nullptr, nullptr);\n    if (gbkLen &lt;= 0)\n    {\n        delete[] wideCharStr; \/\/ \u5982\u679c\u8f6c\u6362\u5931\u8d25\uff0c\u91ca\u653e\u5df2\u5206\u914d\u7684\u5185\u5b58\n        return nullptr;\n    }\n\n    \/\/ \u5206\u914d\u5185\u5b58\u7528\u4e8e\u5b58\u50a8 GBK \u7f16\u7801\u7684\u5b57\u7b26\u4e32\n    char* gbkStr = new char[gbkLen];\n    WideCharToMultiByte(CP_ACP, 0, wideCharStr, -1, gbkStr, gbkLen, nullptr, nullptr);\n\n    \/\/ \u5c06 GBK \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5bbd\u5b57\u7b26\u5b57\u7b26\u4e32\n    int gbkWideLen = MultiByteToWideChar(CP_ACP, 0, gbkStr, -1, nullptr, 0);\n    if (gbkWideLen &lt;= 0)\n    {\n        delete[] wideCharStr;\n        delete[] gbkStr; \/\/ \u5982\u679c\u8f6c\u6362\u5931\u8d25\uff0c\u91ca\u653e\u5df2\u5206\u914d\u7684\u5185\u5b58\n        return nullptr;\n    }\n\n    WCHAR* gbkWideStr = new WCHAR[gbkWideLen];\n    MultiByteToWideChar(CP_ACP, 0, gbkStr, -1, gbkWideStr, gbkWideLen);\n\n    \/\/ \u91ca\u653e\u4e2d\u95f4\u53d8\u91cf\n    delete[] wideCharStr;\n    delete[] gbkStr;\n\n    return gbkWideStr; \/\/ \u8fd4\u56de\u8f6c\u6362\u540e\u7684\u5bbd\u5b57\u7b26\u5b57\u7b26\u4e32\n}<\/code><\/pre>\n<h1><span class=\"ez-toc-section\" id=\"%E5%AE%9E%E6%88%98%E6%A1%88%E4%BE%8B\"><\/span>\u5b9e\u6218\u6848\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u53c2\u8003\uff1a<a href=\"https:\/\/blog.iyatt.com\/?p=19158#%E8%AE%BE%E8%AE%A1_SQLite3_%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AF%BB%E5%86%99%E5%AE%9E%E7%8E%B0\">https:\/\/blog.iyatt.com\/?p=19158#%E8%AE%BE%E8%AE%A1_SQLite3_%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AF%BB%E5%86%99%E5%AE%9E%E7%8E%B0<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6d4b\u8bd5\u73af\u5883 Windows 11 24H2 64\u4f4d Visual Studio 2022\uff08\u5df2\u5b89\u88c5\u4f7f\u7528 C++ \u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"_lmt_disableupdate":"no","_lmt_disable":"no","footnotes":""},"categories":[1,589,594],"tags":[],"class_list":["post-19187","post","type-post","status-publish","format-standard","hentry","category-all","category-c-c","category-594"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/19187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19187"}],"version-history":[{"count":22,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/19187\/revisions"}],"predecessor-version":[{"id":19995,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/19187\/revisions\/19995"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}