I followed the 'C/C++ for Visual Studio Code' official tutorial https://code.visualstudio.com/docs/languages/cpp and was able to compile a Hello World.
However now that I'm trying to compile this, the compile fails:
'banking.cpp'
#include <iostream>
#include "sqlite3.h"
int main(int argc, char** argv)
{
sqlite3* DB;
int exit = 0;
exit = sqlite3_open("banking.db", &DB);
if(exit)
{
std::cerr << "Error opening DB" << sqlite3_errmsg(DB) << std::endl;
}
else
{
std::cout << "Opened Datadase Successfully!" << std::endl;
sqlite3_close(DB);
}
return (0);
}
Error Message:
C:\msys64\mingw64\bin\g++.exe -fdiagnostics-color=always -g C:\Users\locti\OneDrive\Documents\cpp_projects\banking_cpp\banking.cpp -o C:\Users\locti\OneDrive\Documents\cpp_projects\banking_cpp\banking.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\locti\AppData\Local\Temp\ccHQC2y3.o:C:\Users\locti\OneDrive\Documents\cpp_projects\banking_cpp/banking.cpp:23: undefined reference to `sqlite3_open'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\locti\AppData\Local\Temp\ccHQC2y3.o: in function `main':
C:\Users\locti\OneDrive\Documents\cpp_projects\banking_cpp/banking.cpp:27: undefined reference to `sqlite3_errmsg'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\locti\OneDrive\Documents\cpp_projects\banking_cpp/banking.cpp:32: undefined reference to `sqlite3_close'
collect2.exe: error: ld returned 1 exit status
Here is the folder structure:
/banking_cpp
|/.vscode
|/sqlite
||shell.c
||sqlite3.c
||sqlite3.h
||sqlite3ext.h
|banking.cpp
Werid thing is that vs code managed to create a banking.exe before I restarted my computer but that exe couldnt be debugged and gave file format not recognized
error