1. SQLite 다운로드 페이지에서 Source Code와 Precompiled Binaries for Windows를 다운로드 받고 모두 압축을 푼다
https://www.sqlite.org/download.html
SQLite Download Page
Templates (1) and (2) are used for source-code products. Template (1) is used for generic source-code products and templates (2) is used for source-code products that are generally only useful on unix-like platforms. Template (3) is used for precompiled bi
www.sqlite.org
2. 찾기에서 'Developer Command Prompt for VS 2022' 를 검색
3. sqlite-dll-win-x64-3440200압축을 푼 위치로 이동하여
lib /def:sqlite3.def /machine:x64를 입력하면 sqlite3.lib 파일이 생성됨
4. 프로젝트 파일을 하나 만들고 sqlite3.lib, sqlite3.dll, sqlite3.h 를 프로젝트 경로에 추가
5. 코드에서 sqlite3.h와 sqlite3.lib을 설정하고 sqlite를 실행
test.db를 생성하고 닫음
#include <stdio.h>
#include "sqlite3.h"
#pragma comment(lib, "sqlite3.lib")
int main(void)
{
sqlite3* db = nullptr;
int rc = sqlite3_open("test.db", &db);
if (0 != rc)
{
// 실패
printf("sqlite open error %s\n", sqlite3_errmsg(db));
return 0;
}
// 성공
printf("sqlite open success\n");
// 닫는다
sqlite3_close(db);
return 0;
}
6. 정상적으로 실행시 test.db 파일이 생성됨
'데이터베이스 > SQLite' 카테고리의 다른 글
[SQLite] Windows 명령 프롬프트로 SQLite 실행 (0) | 2024.01.14 |
---|---|
[SQLite] 자료형 (0) | 2024.01.13 |
[SQLite] Ubuntu 설치 및 C++에서 사용 방법 (0) | 2023.10.06 |