Last active
April 2, 2023 22:21
-
-
Save dgovil/6d5ecce129f1c46e6f9df69d86ddd146 to your computer and use it in GitHub Desktop.
SQLite Cmake Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.25) | |
project(sqlite_example) | |
set(CMAKE_CXX_STANDARD 20) | |
find_package(SQLite3 REQUIRED) | |
add_executable(${PROJECT_NAME} main.cpp) | |
target_link_libraries(${PROJECT_NAME} PRIVATE ${SQLite3_LIBRARIES}) | |
target_include_directories(${PROJECT_NAME} PRIVATE ${SQLite3_INCLUDE_DIRS}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <sqlite3.h> | |
int main() { | |
sqlite3* db; | |
int status = sqlite3_open("test_dub.db", &db); | |
if (status) { | |
std::cerr << "Failed to open open database: " << sqlite3_errmsg(db) << std::endl; | |
return -1; | |
} else { | |
std::cout << "Opened database" << std::endl; | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment