Recent

Author Topic: libsqlite3.so vs libsqlite3.a  (Read 14269 times)

Pascal

  • Hero Member
  • *****
  • Posts: 932
libsqlite3.so vs libsqlite3.a
« on: October 24, 2018, 08:49:22 am »
My app uses SQLite3Conn. When cross compiling to powerpc64-aix it tries to link libsqlite3.a although only libsqlite3.so
is availabel. How can i enable dynamic linking here?
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: libsqlite3.so vs libsqlite3.a
« Reply #1 on: October 24, 2018, 09:06:37 am »
I added -XD to "Custom Options" but linker still complains:

Code: Text  [Select][+][-]
  1. Hint: (11030) Start of reading config file C:\freepascal\fpc\trunk\bin\i386-win32\fpc.cfg
  2. Hint: (11031) End of reading config file C:\freepascal\fpc\trunk\bin\i386-win32\fpc.cfg
  3. Free Pascal Compiler version 3.3.1 [2018/10/24] for powerpc64
  4. Copyright (c) 1993-2018 by Florian Klaempfl and others
  5. (1002) Target OS: AIX for PowerPC64
  6. (3104) Compiling susMake.lpr
  7. (9009) Assembling susmake
  8. (9015) Linking C:\freepascal\projects\susMake\susmake
  9. C:\freepascal\fpc\trunk\bin\i386-win32\powerpc64-aix-ld.exe: cannot find -lsqlite3
  10. C:\freepascal\projects\susMake\susMake.lpr(30,44) Error: (9013) Error while linking
  11. C:\freepascal\projects\susMake\susMake.lpr(30,44) Fatal: (10026) There were 1 errors compiling module, stopping
  12. Fatal: (1018) Compilation aborted
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: libsqlite3.so vs libsqlite3.a
« Reply #2 on: October 24, 2018, 10:10:56 am »
I also tried to add option "-dy", "-Bdynamic" to linker. No success.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: libsqlite3.so vs libsqlite3.a
« Reply #3 on: October 24, 2018, 10:44:21 am »
Did you double check that the files are for the correct architecture (IOW power64 ?)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: libsqlite3.so vs libsqlite3.a
« Reply #4 on: October 24, 2018, 10:49:10 am »
Did you double check that the files are for the correct architecture (IOW power64 ?)
Don't know. libsqlite3.so could by 32bit. How can i check this?
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: libsqlite3.so vs libsqlite3.a
« Reply #5 on: October 24, 2018, 11:14:28 am »
Tried powerpc instead of powerpc64:

Code: Text  [Select][+][-]
  1. Hint: (11030) Start of reading config file C:\freepascal\fpc\trunk\bin\i386-win32\fpc.cfg
  2. Hint: (11031) End of reading config file C:\freepascal\fpc\trunk\bin\i386-win32\fpc.cfg
  3. Free Pascal Compiler version 3.3.1 [2018/10/24] for powerpc
  4. Copyright (c) 1993-2018 by Florian Klaempfl and others
  5. (1002) Target OS: AIX for PowerPC
  6. (3104) Compiling susMake.lpr
  7. (9009) Assembling susmake
  8. (9015) Linking C:\freepascal\projects\susMake\susMake
  9. C:\freepascal\fpc\trunk\bin\i386-win32\powerpc-aix-ld.exe: cannot find -lsqlite3
  10. C:\freepascal\projects\susMake\susMake.lpr(30,44) Error: (9013) Error while linking
  11. C:\freepascal\projects\susMake\susMake.lpr(30,44) Fatal: (10026) There were 1 errors compiling module, stopping
  12. Fatal: (1018) Compilation aborted

So nothing changed here.

If i provide a libsqlite3.a in C:\freepascal\aixroot\lib it links in both, 32bit and 64bit.

So the linker does not seem to get informed that it shoul link dynamic!
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: libsqlite3.so vs libsqlite3.a
« Reply #6 on: October 24, 2018, 11:23:03 am »
Pass -s and check the generated ppas.sh/.bat and link.res to see what parameters the linker gets.

If you back up some files, you can do various linking attempts by running ppas.bat without rebuilding everything every time

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: libsqlite3.so vs libsqlite3.a
« Reply #7 on: October 24, 2018, 12:15:34 pm »
Sqlite is one of the few large opensource projects for which you can say: if in doubt, compile it yourself.
Sqlite3 is very easy to compile yourself for your platform.
Specialize a type, not a var.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: libsqlite3.so vs libsqlite3.a
« Reply #8 on: October 24, 2018, 12:45:24 pm »
Pass -s and check the generated ppas.sh/.bat and link.res to see what parameters the linker gets.

If you back up some files, you can do various linking attempts by running ppas.bat without rebuilding everything every time

Thanks for the hints!

I could see that -Xc does nothing here. I used -k-dy and linker gets called with -dy but it is not willing to link libsqlite3.so neither in 32bit nor 64bit.

If i use --verbose i can see that linker only tries to find "libsqlite3.a".
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: libsqlite3.so vs libsqlite3.a
« Reply #9 on: October 24, 2018, 12:58:22 pm »
It is possible that cross linkers can't shared link, or refuses to do so if some global resource (like ld.so.conf) is not found.

It is also possible that certain default paths are set. Maybe the linker makes a difference between shared and static linking directories.

Anyway, it is clearly not a FPC problem, but a linker one. Searching AIX maillists looking for crosscompiling or simply "windows aix crosscompile" seems the best option.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1739
Re: libsqlite3.so vs libsqlite3.a
« Reply #10 on: October 24, 2018, 03:20:24 pm »
Please try this.

I have uploaded new binutils.
https://github.com/newpascal/fpcupdeluxe/releases/download/wincrossbins_v1.0/powerpc-aix.zip
Just copy them over your existing ones.

Code: Pascal  [Select][+][-]
  1. program project1;
  2. {$L C:\fpclazbydeluxe\trunk\cross\lib\powerpc64-aix\libsqlite3.so}
  3. //{$L libsqlite3.so}
  4.  
  5. uses ctypes;
  6.  
  7. var
  8.   sqlite3_libversion: function(): pansichar; cdecl;
  9.   s:pansichar;
  10.   SQLiteLibraryHandle: TLibHandle;
  11.  
  12. procedure LoadAddresses(LibHandle: TLibHandle);
  13. begin
  14.   pointer(sqlite3_libversion) := GetProcedureAddress(LibHandle,'sqlite3_libversion');
  15. end;
  16.  
  17. begin
  18.   SQLiteLibraryHandle := LoadLibrary('libsqlite3.so');
  19.   LoadAddresses(SQLiteLibraryHandle);
  20.   writeln('hello !');
  21.   s:=sqlite3_libversion();
  22.   writeln(s);
  23. end.

The above does cross-compile. But if it works on AIX you have to test yourself !

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: libsqlite3.so vs libsqlite3.a
« Reply #11 on: October 24, 2018, 03:56:46 pm »
Please try this.

I have uploaded new binutils.
https://github.com/newpascal/fpcupdeluxe/releases/download/wincrossbins_v1.0/powerpc-aix.zip
Just copy them over your existing ones.

Code: Pascal  [Select][+][-]
  1. program project1;
  2. {$L C:\fpclazbydeluxe\trunk\cross\lib\powerpc64-aix\libsqlite3.so}
  3. //{$L libsqlite3.so}
  4.  
  5. uses ctypes;
  6.  
  7. var
  8.   sqlite3_libversion: function(): pansichar; cdecl;
  9.   s:pansichar;
  10.   SQLiteLibraryHandle: TLibHandle;
  11.  
  12. procedure LoadAddresses(LibHandle: TLibHandle);
  13. begin
  14.   pointer(sqlite3_libversion) := GetProcedureAddress(LibHandle,'sqlite3_libversion');
  15. end;
  16.  
  17. begin
  18.   SQLiteLibraryHandle := LoadLibrary('libsqlite3.so');
  19.   LoadAddresses(SQLiteLibraryHandle);
  20.   writeln('hello !');
  21.   s:=sqlite3_libversion();
  22.   writeln(s);
  23. end.

The above does cross-compile. But if it works on AIX you have to test yourself !

For me too! But the executable is unusable. See output:
Code: Text  [Select][+][-]
  1. exec(): 0509-036 Das Programm unixtest kann wegen der folgenden Fehler nicht geladen werden:
  2.         0509-150   Das abhängige Modul C:\freepascal\aixroot/lib/libsqlite3.so konnte nicht geladen werden.
  3.         0509-022 Das Modul C:\freepascal\aixroot/lib/libsqlite3.so kann nicht geladen werden.
  4.         0509-026 Systemfehler: Eine Datei oder ein Verzeichnis des Pfadnamens ist nicht vorhanden.
  5.  
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1739
Re: libsqlite3.so vs libsqlite3.a
« Reply #12 on: October 24, 2018, 03:59:37 pm »
Use this one:
{$L libsqlite3.so}
(without the path)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: libsqlite3.so vs libsqlite3.a
« Reply #13 on: October 24, 2018, 06:04:53 pm »
Use this one:
{$L libsqlite3.so}
(without the path)

I did! Same result. The linker adds "C:\freepascal\aixroot\lib\".

I also tried /usr/lib/libsqlite3.so but that doesn't link!  %)
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: libsqlite3.so vs libsqlite3.a
« Reply #14 on: October 24, 2018, 06:17:36 pm »
I believe that is what -Xr is for.

 

TinyPortal © 2005-2018