SQLite is easy to compile
jvns.ca
jvns.ca
This is an infuriating property of the runtime linkers on both Linux and Windows: if you're trying to load file A, and dependency B of file A does not exist, you just get "file not found" with no indication of which file it was, and it's extremely hard to debug. At least on linux the "show dependencies" tool is built in.
In this case, it was ld.so itself that was missing, so it didn't have a chance to tell you what's wrong.
This is because the author of SQLite publishes it this way as a convenience to integrators; the actual day-to-day coding is not done in a single C file.
In fact, the README[1] calls out twelve "key files", and explicitly warns that SQLite "will not be the easiest library in the world to hack."
But it does make much more sense that it is worked on in pieces and then put back together.
That's true - but in order for it be able to be reduced to a single C file, a lot of thought had to go into the process.
It shouldn't be very hard, but most projects fail already at the dependency stage.
As in, source to source amalgamation rather than a more complicated build system to generate a binary.
It's already impossible to compile Firefox on a machine with 1GB of RAM because some of the files are just too big. Even with swapping enabled the build process crapped out for me last time I tried it. While 1GB machines are pretty rare these days outside of SBCs, you could easily blow out a 4GB machine if you tried to compile the whole damn thing at once, and 4GB machines are still commonly found.
It also means that you're effectively linking all you dependencies statically. In some cases this can be a plus, in some cases a minus. I think having the choice is important though.
I imagine there are lots of other parts of the toolchain that would have to be updated to support this workflow. Seems like a lot of hassle for something that, though at times complicated, mostly works.
* Build time and memory increases.
* Debugger locations are less clear. MSVC debugging doesn't even work past 64KB lines.
* You still need to link it anyway when using as a library.
* Linker optimization has improved (especially clang).
* It's more difficult to modify.
SQLite has some decent reasons for it especially historically; I'm not sure those reasons are as strong for other projects.
For applications, distributing binaries is even more convenient than source code (assuming they exist for your platform).
And for libraries, "header-only" can be more of a convenience than "single-file".
Are there any ways of doing that sort of distribution header-only then, rather than single file?
https://www.sqlite.org/src/artifact/5fed3d75069d8f66
Some other details / rationale:
https://www.sqlite.org/amalgamation.html
Combining all the code for SQLite into one big file makes SQLite easier to deploy — there is just one file to keep track of. And because all code is in a single translation unit, compilers can do better inter-procedure optimization resulting in machine code that is between 5% and 10% faster.
But there it is, a fully featured SQL engine in an EXE file that I can use with any application I want.
In a world that requires a million SDK's, DLL's, dependencies, etc, this is the most refreshing thing in the world.
If only there was like, a tool, to help you manage compile-time dependencies.
I wish there was a `yarn` equivalent for C projects.
Those two concepts will always remain the same despite the underlying workings, no?
If you're saying "wouldn't it be great if C the language came with an integrated package manager that worked the same on all platforms and was available everywhere", then yes, that would be great, and I too would like a pony. I just think the ecosystem is way too fragmented to ever achieve that. Doubly so if you have to start thinking about cross-compilers and the long tail of little embedded targets.
(PS: today Yarn and Nuget does some of this for the Node/JS/etc and .Net ecosystem but back when Maven arrived those weren't even planned.)
git clone https://github.com/golang/go
cd go/src
./make.bash # or make.bat for Windows
And that's it. You can then use "bin/go" to compile your projects.Moreover, you cannot compare cloning a git repository with downloading a single c source file... This seems equivalent in complexity to the good old "git clone; ./configure; make"
UPDATE: maybe not so much assembly is required... just running "make" built the project without any drama (I'm on macOS with XCode and tooling for Xamarin already installed - YMMV in terms whether you might need to install something to compile from source).
gcc *.c -o sqlite2
and it was done. That much simple.(Especially when many of my compiling-from-source experiences resemble what the author was anticipating)