views:

352

answers:

2

I am building an application in C++ which uses sqlite3 as an embedded database. The source for sqlite3 is distributed as an amalgamated source code file sqlite3.c and two header files.

What are the relative advantages or disadvantages of linking the sqlite3 code directly into my program binary versus compiling sqlite3 as a static library and linking it in that way?

I have already decided against linking to the sqlite3 code as a dynamic library.

+2  A: 

It really doesn't make much difference.
Assuming you have some sort of makefile environment the sqlite.c will only be built once if you don't change anything and the linker will combine the object file in almost the same way as plugging in a static library.

Martin Beckett
+2  A: 

Static library gets compiled into your program. Linking code directly gets compiled into your program. So it seems it's actually the same thing :) It might be easier to manage the project if you link it as static library since you'll have fewer source files. On the other hand if you need to make quick modifications to the library source files, it won't require rebuilding the static library. Ultimately it's up to you.

ttvd