diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index e8699a6b04..afd606c403 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -87,6 +87,9 @@ if(${BUILD_WITH_BDB}) IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/bdb/libdb.a" INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/bdb" ) + target_link_libraries(bdb + INTERFACE pthread + ) endif(${BUILD_WITH_BDB}) # SQLite diff --git a/deps/test/bdb/bdbTest.c b/deps/test/bdb/bdbTest.c index a3e94b6ec1..ab80b33fd0 100644 --- a/deps/test/bdb/bdbTest.c +++ b/deps/test/bdb/bdbTest.c @@ -1,7 +1,28 @@ #include +#include + #include "db.h" +// refer: https://docs.oracle.com/cd/E17076_05/html/gsg/C/BerkeleyDB-Core-C-GSG.pdf + int main(int argc, char const *argv[]) { - printf("Hello world!\n"); + DB * db; + int ret; + uint32_t flags; + + ret = db_create(&db, NULL, 0); + if (ret != 0) { + exit(1); + } + + flags = DB_CREATE; + + ret = db->open(db, NULL, "test.db", NULL, DB_BTREE, flags, 0); + if (ret != 0) { + exit(1); + } + + db->close(db, 0); + return 0; }