Recent

Author Topic: MySQL3 for Linux i386 - Linker Problem?  (Read 1305 times)

Snify

  • New Member
  • *
  • Posts: 11
MySQL3 for Linux i386 - Linker Problem?
« on: September 02, 2021, 12:54:49 pm »
Good day everyone :)
And thank you in advance for reading this!

So, here is the thing:
I have a very old Kylix Project, which used to run on a pure 32-bit (Suse) Linux.

The project uses the class/component "TSQLConnection" from the "SqlExpr" unit, to connect to a very old MySQL 3 (not exactly sure about the minor version).

The goal is to keep the code as compatible as possible and it should be converted/ported to Lazarus and be able to connect to a MySQL 3.

Besides all of this, the project runs in its own isolated 32bit Linux environment (with it's own 32bit libs) via chroot in an overlayed multiarch Linux, where Lazarus/FPC is installed and used for porting.

I have found, that FPC offers a unit "mysql3", which I would like to use (and need?).

So I decided to implement the unit and started compiling a test project for i386 on the overlaying Linux machine.
(The cross-compiler settings, etc. has been configured and installed by fpcupdeluxe)

The first (linker) error was, that the "mysqlclient" library was missing.
Quote
/usr/bin/i586-suse-linux-ld: cannot find -lmysqlclient

After some research, I found that I can add some paths with the "-Fl" parameter and added the paths below.

In the chroot directory (where the old project resides and links to it's own libraries), I could find some mysqlclient libraries:

(THIS IS WITHIN THE CHROOT DIRECTORY)
Code: Pascal  [Select][+][-]
  1. SuSE8:/ # find -name libmysqlclient*
  2. ./usr/lib/libmysqlclient.so.10                                                                                                                                                                        
  3. ./usr/lib/libmysqlclient.so.7.0.0                                                                                                                                                                      
  4. ./usr/lib/libmysqlclient.so.10.0.0                                                                                                                                                                    
  5. ./usr/lib/libmysqlclient.so.7                                                                                                                                                                          
  6. ./usr/lib/mysql/libmysqlclient.so.10                                                                                                                                                                  
  7. ./usr/lib/mysql/libmysqlclient.a                                                                                                                                                                      
  8. ./usr/lib/mysql/libmysqlclient.so.10.0.0                                                                                                                                                              
  9. ./usr/lib/mysql/libmysqlclient.so                                                                                                                                                                      
  10. ./usr/lib/mysql/libmysqlclient.la                                                                                                                                                                      
  11. SuSE8:/ # find -name libsqlmy*                                                                                                                                                                        
  12. ./usr/local/lib/libsqlmy.so                                                                                                                                                                            
  13. ./usr/local/lib/libsqlmy23.so                                                                                                                                                                          
  14. ./usr/local/lib/k3/libsqlmy.so                                                                                                                                                                        
  15. ./usr/local/lib/k3/libsqlmy23.so                                                                                                                                                                      
  16. ./usr/local/lib/k3/libsqlmy23.so.1.0                                                                                                                                                                  
  17. ./usr/local/lib/libsqlmy23.so.1.0                                                                                                                                                                      
  18. ./usr/local/lib/k1/libsqlmy.so.1                                                                                                                                                                      
  19. ./usr/local/lib/k1/libsqlmy.so.1.0
         

After adding these paths to the "-Fl" parameter, I get another linker error:
Quote
Debug: /usr/bin/i586-suse-linux-ld: /chroot_directory/usr/lib/mysql//libmysqlclient.so: undefined reference to `errno@GLIBC_2.0'


The old Kylix Project has code like this:

Code: Pascal  [Select][+][-]
  1.    SQLConn.VendorLib := 'libmysqlclient.so.10.0.0';
  2.    SQLConn.LibraryName := 'libsqlmy.so';
  3.    SQLConn.ConnectionName := 'MySqlConnection';
  4.    SQLConn.DriverName     := 'MYSQL';
  5.    SQLConn.GetDriverFunc  := 'getSQLDriverMYSQL';        
  6.    SQLConn.Params.Add ( 'DriverName=MYSQL' );
  7.    SQLConn.Params.Add ( 'BlobSize=-1' );
  8.    SQLConn.Params.Add ( 'Database=' + db_str );  

So now my question is: How can I proceed the linking? And will my built Lazarus Application work within the chroot directory with these old libs and successfully connect to a MySQL 3 database?

I would like to avoid upgrading the database, the libraries and so fort and keep it as original as possible.

Thank you so much for your help in advance!
If you need any further information, please let me know.
« Last Edit: September 02, 2021, 01:16:08 pm by Snify »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8386
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: MySQL3 for Linux i386 - Linker Problem?
« Reply #1 on: September 17, 2021, 07:53:10 am »
Debug: /usr/bin/i586-suse-linux-ld: /chroot_directory/usr/lib/mysql//libmysqlclient.so: undefined reference to `errno@GLIBC_2.0'
This means libmysqlclient.so contains references to variable errno but the linked glibc doesn't have it. You might want to manually specify which libc the chroot environment is using or my usual trick is to make a symlink to it. Success guarantee varies, but trying won't hurt.

 

TinyPortal © 2005-2018