Recent

Author Topic: SQLite3 and Linux  (Read 19591 times)

adamski

  • New Member
  • *
  • Posts: 16
SQLite3 and Linux
« on: November 04, 2009, 12:22:28 am »
Hi;
I would love to use SQLite in a new Lazarus project, but I'm finding it suprisingly difficult to use.

I'm using the latest 0.9.28 release, which has the tsqlite3connection component, already installed. I've found a copy of the "libsqlite3.so" file, and have placed that in my project directory - i.e next to my executable.

However, as soon I as try to set the component property "connected" to true - via the object inspector or programmatically - I get the following error:

"
Cannot not load SQLite client library "libsqlite3.so
"

If it's next to the executable I cannot understand why it cannot be found.

Also how do you specify the db file to use - in my case it's "test.db"


Thanks for any help,
Marc



theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: SQLite3 and Linux
« Reply #1 on: November 04, 2009, 12:38:00 am »
I've found a copy of the "libsqlite3.so" file, and have placed that in my project directory - i.e next to my executable.

Linux doesn't look for libraries "next to the executable". It has to go to /usr/lib/ or a path which you define in a start script like

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<yourpath>

adamski

  • New Member
  • *
  • Posts: 16
Re: SQLite3 and Linux
« Reply #2 on: November 04, 2009, 01:11:40 am »
Hi Theo - thanks for the quick reply.

I'm not that familiar with Lazarus under linux.

I've set the following under the compiler options:
paths -> libraries = $(ProjOutDir)/lib/

I would have thought, the project would now include any libs in the project's "lib" subdirectory.
( and I've placed the required library in this sub dir )

Unfortunately, the application still cannot find the library.

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 457
Re: SQLite3 and Linux
« Reply #3 on: November 04, 2009, 02:07:45 am »
It's necessary to install the dev package in the developer machine. See http://sqlite4fpc.yolasite.com/install-sqlite.php

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: SQLite3 and Linux
« Reply #4 on: November 04, 2009, 03:13:42 am »
It's necessary to install the dev package in the developer machine. See http://sqlite4fpc.yolasite.com/install-sqlite.php
All required headers come with Lazarus+fpc. Problem is that there is no libsqlite3.so in system.
Basically it all depends on system but in general you must type as root (network connection required):
On Debian/Ubuntu like systems: apt-get install sqlite3
On RedHat and other yum based: yum install sqlite3
On openSUSE: zypper install sqlite3

Eventually it can be sqlite package not sqlite3. Just to clarify it what distribution are you using?

adamski

  • New Member
  • *
  • Posts: 16
Re: SQLite3 and Linux
« Reply #5 on: November 04, 2009, 09:26:47 am »
Thanks Alter;

I'm using Ubuntu, and I've already installed the "sqlite3" package.
I suppose I have to add a path into my project, to point to where this library it installed?

Is this done through : compiler options -> paths -> libraries?

I'll try tonight..

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: SQLite3 and Linux
« Reply #6 on: November 04, 2009, 12:56:44 pm »
So another one thing. Check if you have libsqlite3.so (or something like this) in /usr/lib or /usr/lib64 (if distro is 64bit then I don't remember where Ubunty stored 64bit libraries). Just fo sure as root run ldconfig if there is libsqlite3.so-something but no symlink to it with the name libsqlite3.so (it is required to have either library with this name or symlink to existing file)
Also if you have 64bit Ubuntu then make sure that both Lazarus environment (IDE, units, fpc) and sqlite3 library are either 64bit or 32bit

adamski

  • New Member
  • *
  • Posts: 16
Re: SQLite3 and Linux
« Reply #7 on: November 05, 2009, 12:45:30 am »
Hi Alter;

Thanks for the help - i've created a softlink in the /usr/lib directory, and now lazarus is picking up the file.

Just one other question: I plan to write a small application and deploy on both windows and linux.
How easy is it to deploy libraries (e.g. sqlite), as part of an installation (on windows and linux)?

If it's easy, I'll write my app using sqlite, and worry about the deployment later.


Thanks for everyone's help,
Marc

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: SQLite3 and Linux
« Reply #8 on: November 05, 2009, 02:05:54 am »
Actually in case of Linux it is complicated. First you should most likely learn something about creating deb and rpm packages. Second way is to distribute as source code (if your licence for your application allows that) or eventually you may distribute as archive (like tar.gz or so).

 

TinyPortal © 2005-2018