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


  • New Member
  • *
  • Posts: 13
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.
/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:

Code: Pascal  [Select][+][-]
  1. SuSE8:/ # find -name libmysqlclient*
  2. ./usr/lib/                                                                                                                                                                        
  3. ./usr/lib/                                                                                                                                                                      
  4. ./usr/lib/                                                                                                                                                                    
  5. ./usr/lib/                                                                                                                                                                          
  6. ./usr/lib/mysql/                                                                                                                                                                  
  7. ./usr/lib/mysql/libmysqlclient.a                                                                                                                                                                      
  8. ./usr/lib/mysql/                                                                                                                                                              
  9. ./usr/lib/mysql/                                                                                                                                                                      
  10. ./usr/lib/mysql/                                                                                                                                                                      
  11. SuSE8:/ # find -name libsqlmy*                                                                                                                                                                        
  12. ./usr/local/lib/                                                                                                                                                                            
  13. ./usr/local/lib/                                                                                                                                                                          
  14. ./usr/local/lib/k3/                                                                                                                                                                        
  15. ./usr/local/lib/k3/                                                                                                                                                                      
  16. ./usr/local/lib/k3/                                                                                                                                                                  
  17. ./usr/local/lib/                                                                                                                                                                      
  18. ./usr/local/lib/k1/                                                                                                                                                                      
  19. ./usr/local/lib/k1/

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

The old Kylix Project has code like this:

Code: Pascal  [Select][+][-]
  1.    SQLConn.VendorLib := '';
  2.    SQLConn.LibraryName := '';
  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 »


  • Hero Member
  • *****
  • Posts: 8415
  • 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// undefined reference to `errno@GLIBC_2.0'
This means 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