Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Statically linking SQLite with DMD (Windows x86)

I've tried to statically link with sqlite3 without success. I'm using the 'etc.c.sqlite3' header, and the sqlite3 amalgamation. To create the .lib file I've tried both VC++ and MinGW-gcc, both of these compile the source file successfully - but they both generate COFF object format (optlink, which DMD uses, works with OMF). After reading tons of posts on 'digitalmars.D', I've tried several different solutions.

objconv:

  • tried to convert lib file created with GCC, resulted in undefined symbols such as __divdi3 and __muldi3, wasn't able to solve this.

  • Also tried this to convert the sqlite3.o file to *.obj, and then use digitalmars 'lib.exe' - unsuccessful as well

  • Attempting objconv on a VC++ generated lib fails because: "SQLite.lib is an import library"

implib:

  • If I download the precompiled DLL from sqlite.org and use implib, it generates a lib file, but the name mangling does not seem to match, because even though I link with the static library, I still receive the same sqlite errors (e.g undefined symbol _sqlite3_open, _sqlite3_errmsg, _sqlite3_close...

coffimplib:

  • If I use coffimplib on the VC++ created library file, the program generates a nearly empty file (~2KB) which only contains garbage (i.e no symbols at all and mostly just 'null' values).

  • If I do the same with the GCC created library, coffimplib complains about "not an import library" and no converted library file is generated.

If I use DMC to compile the sqlite3 amalgamation, the compilation fails complaining about tons of errors. So here I am, stuck in nowhere, does anyone have any ideas or tips what might solve this?

NOTE: I do not want to use a DLL, but statically link with sqlite (for executable size concerns).

like image 329
Elliott Darfink Avatar asked Oct 05 '22 22:10

Elliott Darfink


1 Answers

Try using implib with /system switch.

like image 146
Robik Avatar answered Oct 10 '22 02:10

Robik