Recent

Author Topic: Cannot load DB-Lib "libsybdb.so"  (Read 9129 times)

Edson

  • Hero Member
  • *****
  • Posts: 1302
Cannot load DB-Lib "libsybdb.so"
« on: December 02, 2016, 07:18:27 pm »
Trying to connect to Sybase DB, from CentOS 6.8 - fpc 3.0.0. I Get

Quote
EInOutError/Can not load DB-Lib client library "libsybdb.so". Check your installation.

I have installed "freetds", before and can connect correctly using fisql and tsql.

I have libsybdb.so:

Quote
[usuario@CENTOS-64 ~]$ find / -name libsybdb.so
/home/usuario/freetds-1.00/src/dblib/.libs/libsybdb.so
/usr/local/lib/libsybdb.so

I have tried creating a link: ln -s /home/usuario/freetds-1.00/src/dblib/.libs/libsybdb.so /lib/libsybdb.so
but not success

Any help would be appreciated?
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

vrull

  • Full Member
  • ***
  • Posts: 118
Re: Cannot load DB-Lib "libsybdb.so"
« Reply #1 on: December 09, 2016, 12:53:40 am »
I think your program is looking for
/usr/lib/libsybdb.so instead of /usr/local/lib/libsybdb.so.

Try
Code: Pascal  [Select][+][-]
  1. SQLDBLibraryLoader.LibraryName := '/usr/local/lib/libsybdb.so'; // full path here
  2. SQLDBLibraryLoader.ConnectionType := 'Sybase';
  3. SQLDBLibraryLoader.Enabled := true;
  4. SQLDBLibraryLoader.LoadLibrary;

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Cannot load DB-Lib "libsybdb.so"
« Reply #2 on: December 13, 2016, 10:18:17 pm »
I don't know exactly, how to use SQLDBLibraryLoader. I hope it's OK in my code:

Code: Pascal  [Select][+][-]
  1. program tisql;
  2. {$mode objfpc}{$H+}
  3. uses
  4.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  5.   cthreads,
  6.   {$ENDIF}{$ENDIF}
  7.   Classes,
  8.   SysUtils, db, sqldb, Dialogs, sqldblib,
  9.   mssqlconn; // mssqlconn was added to 2.6.1, you need a recent 2.6.1
  10. var
  11.   Connection: TSybaseConnection;
  12.   SQLTransaction1: TSQLTransaction;
  13.   SQLQuery1: TSQLQuery;
  14.   SQLDBLibraryLoader1: TSQLDBLibraryLoader;
  15. begin
  16.   SQLDBLibraryLoader1 := TSQLDBLibraryLoader.Create(nil);
  17.   SQLDBLibraryLoader1.LibraryName := '/usr/lib/libsybdb.so'; // full path here
  18.   SQLDBLibraryLoader1.ConnectionType := 'Sybase';
  19.   SQLDBLibraryLoader1.Enabled := true;
  20.   SQLDBLibraryLoader1.LoadLibrary;
  21.  
  22.   Connection:= TSybaseConnection.Create(nil);
  23.   SQLTransaction1:= TSQLTransaction.Create(nil);
  24.   SQLQuery1:= TSQLQuery.Create(nil);
  25.  
  26.   Connection.UserName:='sa';
  27.   Connection.Password:='xxx';
  28.   Connection.HostName:='192.168.1.33'+':'+'5000';
  29.   Connection.DatabaseName:='master';
  30.  
  31.   SQLTransaction1.DataBase:=Connection;
  32.   SQLQuery1.DataBase:=Connection;
  33.   SQLQuery1.SQL.Text := 'select dbname, suid, status  from syslogins';
  34.   try
  35.     Connection.Connected:=true;
  36.   except
  37.     on E: Exception do
  38.     begin
  39.       writeln('Error connecting to database: '+E.ClassName+'/'+E.Message);
  40.     end;
  41.   end;
  42.   try
  43.     SQLquery1.Open;
  44.     SQLquery1.First;
  45.     while not SQLquery1.EOF do
  46.     begin
  47.       writeln(SQLquery1.FieldByName('dbname').AsString);
  48.       SQLquery1.Next;
  49.     end;
  50.   except
  51.     writeln('Error ejecutando consulta.');
  52.   end;
  53.  
  54.   writeln('hola mundo');
  55.  
  56.   SQLQuery1.Destroy;
  57.   SQLTransaction1.Destroy;
  58.   Connection.Destroy;
  59. //  readln;
  60.   SQLDBLibraryLoader1.Destroy;
  61. end.
  62.  

It compiles, but when exec:

Quote
An unhandled exception occurred at $000000000052B51F:
EInOutError: Can not load DB-Lib client library "libsybdb.so". Check your installation.
Success
  $000000000052B51F
  $00000000004BCB76

Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Thaddy

  • Hero Member
  • *****
  • Posts: 14377
  • Sensorship about opinions does not belong here.
Re: Cannot load DB-Lib "libsybdb.so"
« Reply #3 on: December 13, 2016, 10:24:15 pm »
If there is a correct installation in /usr/lib/ or /usr/local/lib/ there is never the need for a full path.
Your installation is wrong, or your header file is wrong. Check the libname in your header file/interface unit first, otherwise your installation is wrong or non-existent.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Cannot load DB-Lib "libsybdb.so"
« Reply #4 on: December 15, 2016, 07:18:47 pm »
If there is a correct installation in /usr/lib/ or /usr/local/lib/ there is never the need for a full path.
Your installation is wrong, or your header file is wrong. Check the libname in your header file/interface unit first, otherwise your installation is wrong or non-existent.

I don't think the installation is wrong because the "fisql" tool, can connect correctly in this Centos.

Moreover, the same program (without TSybaseConnection) runs OK in a Ubuntu PC.

What is my header file?
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Cannot load DB-Lib "libsybdb.so"
« Reply #5 on: December 16, 2016, 06:02:30 pm »
Tested with another installation of FreeTDS:

Quote
[usuario@CENTOS-64 ~]$ tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds vdev.1.00.106
             freetds.conf directory: /usr/local/etc
     MS db-lib source compatibility: no

but not success  >:(:

It still showing the message:

Quote
EInOutError/Can not load DB-Lib client library "libsybdb.so". Check your installation.

But I can connect correctly with fisql:


Quote
[usuario@CENTOS-64 ~]$ fisql -S SILICIO1 -U sa -P xxx -i a.sql -n
Changed database context to 'master'.

dbname                         suid        status
master                         1           0     
sybsystemdb                    2           0     
master                         3           0     
master                         4           8     
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Thaddy

  • Hero Member
  • *****
  • Posts: 14377
  • Sensorship about opinions does not belong here.
Re: Cannot load DB-Lib "libsybdb.so"
« Reply #6 on: December 16, 2016, 06:47:34 pm »
your header file is the interface unit to libsybdb.so
That probably contains an error in the name or the version.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11455
  • FPC developer.
Re: Cannot load DB-Lib "libsybdb.so"
« Reply #7 on: December 16, 2016, 07:19:16 pm »
Something security oriented like Centos may have the standard *nix protection that libraries can only be loaded from directories known to the library loader.

These directories are configured with the "ldconfig" tool.

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Cannot load DB-Lib "libsybdb.so"
« Reply #8 on: December 16, 2016, 08:15:06 pm »
Finally success  :).

I'm using:

Quote
  SQLDBLibraryLoader1 := TSQLDBLibraryLoader.Create(nil);
  SQLDBLibraryLoader1.ConnectionType := 'Sybase';
  SQLDBLibraryLoader1.LibraryName := '/usr/lib/libsybdb.so'; // full path here
  SQLDBLibraryLoader1.Enabled := true;
  SQLDBLibraryLoader1.LoadLibrary;

The key is putting:

  SQLDBLibraryLoader1.ConnectionType := 'Sybase';

just after creating the object, like indicated in http://wiki.freepascal.org/TSQLDBLibraryLoader

I don't know, why it's needed to use TSQLDBLibraryLoader, but it's the only way it works for me.

Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018