Lazarus
Free Pascal => Unix => Topic started by: dbannon on November 13, 2019, 11:28:21 am
-
I have been tring to build Lazarus from FPC320 (from snapshots) but hit a strange linking issue. I can build a simple helloworld type pascal programme but trying to build Lazarus fails to link because it cannot find libX11. So I added a -Fl to fpc.cfg, its in /usr/lib/x86_64-linux-gnu/ I also added a -k to be passed directly to ld, that it should search that directory. One or both should work ....
......
(9022) Compiling resource ../units/x86_64-linux/qt5/lazarus.or
(9015) Linking ../lazarus
/usr/bin/ld: cannot find -lX11
/home/dbannon/Lazarus/lazarus_2_0_6/ide/lazarus.pp(165,1) Error: (9013) Error while linking
dbannon@U1910-test:~/Lazarus/lazarus_2_0_6$ ls -l /usr/lib/x86_64-linux-gnu/libX11.so.6
lrwxrwxrwx 1 root root 15 Nov 11 18:15 /usr/lib/x86_64-linux-gnu/libX11.so.6 -> libX11.so.6.3.0
dbannon@U1910-test:~/Lazarus/lazarus_2_0_6$ grep x86_64-linux-gnu /etc/fpc.cfg
-Fl/usr/lib/gcc/x86_64-linux-gnu/9
-Fl/usr/lib/x86_64-linux-gnu
-Fl/usr/lib/gcc/x86_64-linux-gnu/9
-Fl/usr/lib/x86_64-linux-gnu
-k-L/usr/lib/x86_64-linux-gnu
So, I added a specific linker line that points straight to libX11, hey, it cannot ignore that said I.
dbannon@U1910-test:~/Lazarus/lazarus_2_0_6$ grep libX11.so.6 /etc/fpc.cfg
-k-l/usr/lib/x86_64-linux-gnu/libX11.so.6
......
lazres.pp(361,7) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined
Linking ./lazres
/usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu/libX11.so.6
Error: Error while linking
Fatal: There were 1 errors compiling module, stopping
While failing at a different spot, lazres does not need X11 I guess, its still failing because it cannot find libX11 but its there !
Any suggestions please ?
Davo
-
Check your fpc.cfg if the paths are correct- and leave out the number from the lib.
-
My first post shows the paths in fpc.cfg. As near as I can tell, they are correct ! The libX11.so.6 is there, I showed an ls command looking for it. And I grep'ed the fpc.cfg so show the line that tells fpc to look in that directory (and even the stupid case of were I specified the -k to a specific file name.
Oh, I only put in the full library name to demonstrate its not listening, normally all it should need is the directory path, ld reports that it cannot find X11, that means its looking for (eg) libX11.so.6 \
Davo
-
Try a
-Fl/usr/lib/x86_64-linux-gnu
in your fpc.cfg or cmdline
-
-Fl/usr/lib/x86_64-linux-gnu
in your fpc.cfg or cmdline
Second last line of the first block of code in first post.
So, here is a much simpler example of what I am seeing. Its clearly something I misunderstand ...
A simple hello world app, does not need eg X11 but should be able to find it and the smart linker won't use it. I tell the linker, with the -k switch, that it should include a specific library -
dbannon@U1910-test:~/Downloads$ fpc -k-l/usr/lib/x86_64-linux-gnu/libX11.so.6 hello.pas
Free Pascal Compiler version 3.2.0-beta [2019/11/12] for x86_64
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling hello.pas
Linking hello
/usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu/libX11.so.6
hello.pas(4,1) Error: Error while linking
hello.pas(4,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode
So, yes, I know it does not need it but when it tries to find it, it fails. But its it is definitly there :
dbannon@U1910-test:~/Downloads$ ls -l /usr/lib/x86_64-linux-gnu/libX11.so.6
lrwxrwxrwx 1 root root 15 Nov 11 18:15 /usr/lib/x86_64-linux-gnu/libX11.so.6 -> libX11.so.6.3.0
Think I need to put strace on this VM .....
EDIT: Nice, U1910 already has strace. But it tells me nothing, shows me all the compile steps but not link. Can someone tell me how to do separate compile and link stages please ? I really need to see the link command that fpc (or ppcx64 is generating.
Davo
-
Use -s for the link stage and -a to retain the assembler.
The commandline will be in ppas.sh
-
Thanks marcov, that was what I needed.
Revealed that the linker was looking for libX11.so. When I added a complete file name, the linker still added .so to the end of that so trying to rub its nose in what was there was unproductive.
In my directory, I have -
root@U1910-test:/usr/lib/fpc/3.2.0# ls -la /usr/lib/x86_64-linux-gnu/libX11.so*
lrwxrwxrwx 1 root root 15 Nov 11 18:15 /usr/lib/x86_64-linux-gnu/libX11.so.6 -> libX11.so.6.3.0
-rw-r--r-- 1 root root 1298024 Sep 19 00:09 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
But no symlink to libX11.so , I have no idea if I should have it and there is some issue with U1910 or if the linker is at fault for not trying libX11.so.6 . I don't think its fpc's fault for not specifying more explicitly on the command line, do you ?
But either way, adding an appropriate symlink made the problem go away.
Davo
-
But no symlink to libX11.so , I have no idea if I should have it and there is some issue with U1910 or if the linker is at fault for not trying libX11.so.6
Install the development package of X11 to get the symlink. See e.g. the answers to https://unix.stackexchange.com/questions/475/how-do-so-shared-object-numbers-work for more details.
-
Indeed Jonas, installing the dev version of libX11 does create the necessary symlink.
Thanks.
Those rather fascinating fpc snapshots don't seem to get any docs (eg about how to install). Pity, running one of them in a VM is cool way to try out the future versions without risking my working install of 3.0.4. But of course installing from a snapshot does not resolve dependencies !
Davo