I'm just beginning to experiment with C/C++ and SQLite, and installed the minGW-w64 compiler and was able to get the little "Hello, world." code to compile to an .exe file and run it.
Then I added the sqlite3.c amalgamation file to the directory and attempted to compile it with the helloworld.c file, and the first result was many, many rows of errors and warnings, it appears because I used g++
instead of gcc
.
I have two very basic questions.
The .exe file was 53kb for hello world compiled alone and 1,015kb for the combination even though no SQLite statements were used.
g++
generate the large error list and gcc
did not generate any? I realize that g++
is for c and c++ and sqlite3 is c. Does this mean that a c++ file and sqlite3.c cannot be compiled together?Thank you.
Yes, bundling sqlite like that is intended behavior.
You can compile sqlite3.c
with a C compiler first and link the result into a binary:
gcc -O2 -c sqlite3.c
g++ -O2 sqlite3.o myapp.cpp -o myapp.exe
I strongly suggest automating this project with a simple makefile or Cmake.