Will03uk
Will03uk

Reputation: 3444

How do I add sqlite3 to my project

How do I statically link the sqlite3 libary to my C++ program? I am using the G++ compiler.

Upvotes: 1

Views: 3588

Answers (4)

broc
broc

Reputation: 222

Go to www.sqlite.org and download the latest version's amalgamation tarball. Include their source files to your project (make file, whatever) and forget about it. It's embedded anyway, they compile in a jiffy, if you put into your version control repo, you know what version you're using in what version of your application and you can forget about linking options. Just remember that their source files are C and not C++.

Upvotes: 0

Tobias
Tobias

Reputation: 845

On a Linux system I recommend using pkg-config. Running pkg-config --cflags --libs --static sqlite3 should give you the compiler and linker flags you need.

Upvotes: 1

wkl
wkl

Reputation: 79893

Assuming you're on Linux and using the GNU ld linker:

g++ <your-code> -Wl,--Bstatic -lsqlite3

Of course, if libsqlite3.a isn't in your library path, you have to pass the directory it's in to the compiler as an additional -L flag.

If you don't have a static version (I don't on my system), you either have to check if you can get one or if you'll have to build your own.

Upvotes: 2

oscarkuo
oscarkuo

Reputation: 10453

in Unix/Linux you'll have to make sure the library (e.g. libsqlite3.a) is in your LD_LIBRARY_PATH and then you add "-lsqlite3 -static" to the g++ option.

Upvotes: 3

Related Questions