Sqlite3 as a shared object (.so)
(1) By jesito on 2023-01-15 11:02:02 [link] [source]
Hi everybody, I need sqlite3.so for my MX-Linux machine (AMD64). If I install from the Debian repositories via apt, I only get the sqlite3.o file. I've been trying to download and compile it but I'm afraid I lack the needed knowlegde. The standard configure tool and the make it produces, generate the .o file. None of the search queries I've done have proven successful. In some places there are indications to add the "-shared" flag to the CFLAGS prior the configure tool, but it gives me an error, telling it cannot compile C programs. Similar with LDFLAGS. Run out of ideas, so any help will be very welcome. config.log does not provide any enlightment to me. Thanks in advance, Jes,
╰─$ CFLAGS="-Os -shared" ./configure 1 checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p.. . /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in
`/media/jesito/datosLIN/jesito/projects/sqlite-snapshot-202301131932':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
(2) By Keith Medcalf (kmedcalf) on 2023-01-15 15:35:25 in reply to 1 [link] [source]
One usually provides configuration options to configure
and instructions about what to make to make
. Have you tried doing that?
configure
make sqlite3.so
and see what happens?
(3) By jesito on 2023-01-15 21:36:45 in reply to 2 [link] [source]
Thanks for your suggestion, Keith. I tried it but I got an error:
"There is no rule to build the object "sqlite3.so"
(4.1) By Keith Medcalf (kmedcalf) on 2023-01-15 22:56:48 edited from 4.0 in reply to 3 [link] [source]
I dunno then. Maybe read the makefile?
When I checkout the trunk into ~/sqlite3/sqlite3
then cd to ~/sqlite3/build
(making the missing directories as needed), then in ~/sqlite3/build
run ../sqlite3/configure
and then make
, I get the whole kitakaboodle built.
Are you not following the build instructions?
Hint: It appears for me that the libsqlite3.so is put in the .libs subdirectory. (The target name appears to be libsqlite3.la)
THe usual configure / make install seems to do the expected.
(5) By Stephan (stephancb) on 2023-01-16 05:39:18 in reply to 3 [source]
The steps to compile are:
Download the amalgamation as *tar.gz
, the present version is here.
tar zxf sqlite-autoconf-3400000.tar.gz
cd sqlite-autoconf-3400000
./configure
make
sudo make install
That's it, for me with Fedora. It should work equally with other distributions. Of course, replace the version nr when there is an update.
The last step installs libsqlite.so
system-wide in /usr/local/lib
as a link to presently libsqlite3.so.0.8.6
. The libsqlite.so
has a different version numbering than SQLite itself. This should be of no concern, if you are just interested in one (latest) version. With a properly configured account the linker should automatically pick the self-compiled version, possibly before a version provided by the distribution.
For further refinements and optimizations according to your taste
./configure -h
lists possible compile options that you can choose. Even more compile options are available with e.g.
./configure CFLAGS="-O2 -DSQLITE_MAX_MMAP_SIZE=4393751543808"
For all the possible compile options consult Pandora's box here.
Perhaps you don't need all this:
Fedora has under sqlite
only the CLI with a statically linked SQLite. Additionally, for a shared object as compiled by the provider of the distribution, you may need
sqlite-libs
sqlite-devel
But this naming and division of packages depends on the Linux distribution.
(6.1) By jesito on 2023-01-16 12:27:33 edited from 6.0 in reply to 5 [link] [source]
Thanks a lot @stephancb, in the meantime I found a solution. Once configure and make done,I just run the command
gcc -shared sqlite3.c -o sqlite3.so
That did the trick!. I saw a similar solution for generating a .dll in windows, and supposed it could work in Linux.