Recent

Author Topic: Sqlite3 problem  (Read 17847 times)

Jaco

  • New Member
  • *
  • Posts: 45
Sqlite3 problem
« on: February 06, 2008, 10:43:41 pm »
Hi,

After a serious struggle to get Lazarus up and running on a MacOS 10.5, I tried to compile a tiny test application I made in Lazarus for Windows, using a Sqlite3 database.
The project fails to compile with a long list of "Undefined symbols", like:
Undefined symbols:
  "_sqlite3_exec", referenced from:     SQLITE3DS_TSQLITE3DATASET_$__SQLITEEXEC$PCHAR$TSQLITECDECLCALLBACK$POINTER$$LONGINT in sqlite3ds.o


Does anyone have a suggestion how to solve this problem?

Thanks, from a Mac newbie

Jaco

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Sqlite3 problem
« Reply #1 on: February 07, 2008, 04:31:22 pm »
Quote from: "jvoorham"
The project fails to compile with a long list of "Undefined symbols", like:
Undefined symbols:
  "_sqlite3_exec", referenced from:     SQLITE3DS_TSQLITE3DATASET_$__SQLITEEXEC$PCHAR$TSQLITECDECLCALLBACK$POINTER$$LONGINT in sqlite3ds.o


What version and build of FPC are you using?

Where are your sqlite3 client libraries located on your Mac? You'll need to link against them. I don't have any experience with sqlite3 but looking at FPC's sqlite.pp I see that it uses an external library for sqlite_exec and other functions. This library is probably named libsqlite.dylib on your Mac.

Thanks.

-Phil

Jaco

  • New Member
  • *
  • Posts: 45
RE: Re: Sqlite3 problem
« Reply #2 on: February 08, 2008, 12:04:55 pm »
FPC is 2.2.0, from an image a couple of days ago.
I found a file named libsqlite3.0.dylib
in /usr/lib/
with an alias named libsqlite3.dylib
Would it be sufficient to copy this library to, e.g., my application's directory?

Thanks,

Jaco

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: Sqlite3 problem
« Reply #3 on: February 08, 2008, 03:47:10 pm »
Quote from: "jvoorham"
FPC is 2.2.0, from an image a couple of days ago.
I found a file named libsqlite3.0.dylib
in /usr/lib/
with an alias named libsqlite3.dylib


Leave the files where they are and add /usr/lib to Libraries in Compiler Options. If you're compiling from a script, use the -Fl/usr/lib switch for FPC. See if that helps the linker find the libraries.

Did you install these libraries? I'm not at my Mac right now so I don't know if these are included with OS X or not. This will determine whether you need to distribute the .dylib files with your app or not.

Thanks.

-Phil

Jaco

  • New Member
  • *
  • Posts: 45
RE: Re: RE: Re: Sqlite3 problem
« Reply #4 on: February 10, 2008, 11:44:31 am »
OK, I got it working by adding a {$linklib sqlite3.dylib} statement in the sqlite3.pp file, an copying the sqlite* files to my project directory. Maybe not worth a beauty contest, but at least it works.
Thanks for pointing me into the direction of the dylib.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: RE: Re: Sqlite3 problem
« Reply #5 on: February 10, 2008, 09:15:41 pm »
Quote from: "jvoorham"
OK, I got it working by adding a {$linklib sqlite3.dylib} statement in the sqlite3.pp file, an copying the sqlite* files to my project directory. Maybe not worth a beauty contest, but at least it works.
Thanks for pointing me into the direction of the dylib.


I was confused when I wrote that. Yes, when the library is specified with "external", you need to include $linklib with OS X. See how they did it in FPC's gtk.pp.

I think you should file a bug report for this, so that somebody adds $linklib to sqlite3.pp with $IFDEF for Darwin the way it's done in gtk.pp.

I believe that libsqlite3.dylib is included with OS X. You can maybe do some googling to verify this. What that means is that you won't have to distribute it with your app. I believe FPC includes /usr/lib when it passes switches to the linker so it should still work without copying the .dylib to your project's folder - or maybe you're only copying the source files. Let me know if this works with the .dylib in /usr/lib.

Thanks.

-Phil

bobyuan

  • Newbie
  • Posts: 4
Re: RE: Re: RE: Re: Sqlite3 problem
« Reply #6 on: June 26, 2009, 05:03:52 pm »
OK, I got it working by adding a {$linklib sqlite3.dylib} statement in the sqlite3.pp file, an copying the sqlite* files to my project directory. Maybe not worth a beauty contest, but at least it works.
Thanks for pointing me into the direction of the dylib.

Where did you find the sqlite3.pp file? I met the same problem but have no clue to find the sqlite3.pp file. Please help!

thanks in advance.
bob

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1071
Re: RE: Re: RE: Re: Sqlite3 problem
« Reply #7 on: June 26, 2009, 08:05:16 pm »
OK, I got it working by adding a {$linklib sqlite3.dylib} statement in the sqlite3.pp file, an copying the sqlite* files to my project directory. Maybe not worth a beauty contest, but at least it works.
Thanks for pointing me into the direction of the dylib.

Where did you find the sqlite3.pp file? I met the same problem but have no clue to find the sqlite3.pp file. Please help!


You can also add that linklib directive to your main program source file, it will have the same effect.

bobyuan

  • Newbie
  • Posts: 4
Re: RE: Re: RE: Re: Sqlite3 problem
« Reply #8 on: June 27, 2009, 04:11:39 am »
You can also add that linklib directive to your main program source file, it will have the same effect.

I was trying to install the package of sqlite3laz. I don't have a project to run.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1071
Re: RE: Re: RE: Re: Sqlite3 problem
« Reply #9 on: June 28, 2009, 12:58:32 am »
You can also add that linklib directive to your main program source file, it will have the same effect.

I was trying to install the package of sqlite3laz. I don't have a project to run.

The problem described above was fixed in FPC 2.2.4. You should not have to add this linklib statement anywhere anymode.

bobyuan

  • Newbie
  • Posts: 4
Re: RE: Re: RE: Re: Sqlite3 problem
« Reply #10 on: June 29, 2009, 03:58:20 am »
You can also add that linklib directive to your main program source file, it will have the same effect.

I was trying to install the package of sqlite3laz. I don't have a project to run.

The problem described above was fixed in FPC 2.2.4. You should not have to add this linklib statement anywhere anymode.


I installed 2.2.4 fpc, fpc src and lazarus (lazarus is 2.2.4 20748 build). When I tried to install sqlite3.laz under Developer/Lazarus/Components/sqlite, same error message.

Anyone can provide some hint to help me install SQLite3 packages?

thanks.

Hinnack

  • New Member
  • *
  • Posts: 11
Re: Sqlite3 problem
« Reply #11 on: July 19, 2009, 06:38:09 pm »
I do have th same problem with lazarus from svn trunk and fpc 2.2.4

on recompiling the IDE I get:

Undefined symbols:
  "_sqlite3_prepare", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALGETHANDLE$$POINTER in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALINITFIELDDEFS in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__EXECUTEDIRECT$ANSISTRING in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__BUILDLINKEDLIST in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__QUICKQUERY$ANSISTRING$TSTRINGS$BOOLEAN$$ANSISTRING in sqlite3ds.o
  "_sqlite3_errmsg", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALGETHANDLE$$POINTER in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__RETURNSTRING$$ANSISTRING in sqlite3ds.o
  "_sqlite3_column_decltype", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALINITFIELDDEFS in sqlite3ds.o
  "_sqlite3_column_name", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALINITFIELDDEFS in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALINITFIELDDEFS in sqlite3ds.o
  "_sqlite3_exec", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__SQLITEEXEC$PCHAR$TSQLITECDECLCALLBACK$POINTER$$LONGINT in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__BUILDLINKEDLIST in sqlite3ds.o
  "_sqlite3_column_text", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__BUILDLINKEDLIST in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__QUICKQUERY$ANSISTRING$TSTRINGS$BOOLEAN$$ANSISTRING in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$_QUICKQUERY$crc9A533FFC_FILLSTRINGSANDOBJECTS in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$_QUICKQUERY$crc9A533FFC_FILLSTRINGS in sqlite3ds.o
  "_sqlite3_column_type", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALINITFIELDDEFS in sqlite3ds.o
  "_sqlite3_open", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALGETHANDLE$$POINTER in sqlite3ds.o
  "_sqlite3_step", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALINITFIELDDEFS in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__EXECUTEDIRECT$ANSISTRING in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__BUILDLINKEDLIST in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__BUILDLINKEDLIST in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__QUICKQUERY$ANSISTRING$TSTRINGS$BOOLEAN$$ANSISTRING in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$_QUICKQUERY$crc9A533FFC_FILLSTRINGSANDOBJECTS in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$_QUICKQUERY$crc9A533FFC_FILLSTRINGS in sqlite3ds.o
  "_sqlite3_libversion", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__GETSQLITEVERSION$$ANSISTRING in sqlite3ds.o
  "_sqlite3_column_count", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALINITFIELDDEFS in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__BUILDLINKEDLIST in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__QUICKQUERY$ANSISTRING$TSTRINGS$BOOLEAN$$ANSISTRING in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__QUICKQUERY$ANSISTRING$TSTRINGS$BOOLEAN$$ANSISTRING in sqlite3ds.o
  "_sqlite3_close", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALCLOSEHANDLE in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALGETHANDLE$$POINTER in sqlite3ds.o
  "_sqlite3_finalize", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALGETHANDLE$$POINTER in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__INTERNALINITFIELDDEFS in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__EXECUTEDIRECT$ANSISTRING in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__BUILDLINKEDLIST in sqlite3ds.o
      _SQLITE3DS_TSQLITE3DATASET_$__QUICKQUERY$ANSISTRING$TSTRINGS$BOOLEAN$$ANSISTRING in sqlite3ds.o
  "_sqlite3_changes", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$__GETROWSAFFECTED$$LONGINT in sqlite3ds.o
  "_sqlite3_column_int", referenced from:
      _SQLITE3DS_TSQLITE3DATASET_$_QUICKQUERY$crc9A533FFC_FILLSTRINGSANDOBJECTS in sqlite3ds.o
ld: symbol(s) not found
An error occurred while linking
Error: Error while linking
TExternalToolList.Run Exception: Error: Error while linking


bobyuan

  • Newbie
  • Posts: 4
Re: Sqlite3 problem
« Reply #12 on: July 20, 2009, 08:40:18 pm »
Any one is kind enough to provide some help on this problem?

thanks in advance.

laguna

  • Sr. Member
  • ****
  • Posts: 327
Re: Sqlite3 problem
« Reply #13 on: July 20, 2009, 08:43:21 pm »
Solution use ZeosDB.

View my topic Zeos DB

http://lazarus.freepascal.org/index.php/topic,7034.0.html

Loesje

  • Full Member
  • ***
  • Posts: 168
    • Lazarus Support website
Re: Sqlite3 problem
« Reply #14 on: July 21, 2009, 08:28:00 pm »
I think that your sqlite3.dylib is too old, or maybe even for sqlite2?

 

TinyPortal © 2005-2018