Forum > macOS / Mac OS X
[SOLVED] MacOSX dont find libX11.dylib
(1/1)
Fred vS:
Hello.
I try to compile a application using last release of XQwartz and xlib.pas.
libX11.dylib is located in /usr/X11/lib.
In code there is that in xlib.pas:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{linklib libX11.dylib}const libX11='X11';
But strangely, after compilation that is ok, there is a error message at linking:
--- Quote ---Linking demo
ld: library not found -lX11
An error occured while linking
Fatal: There was 1 errors compiling module, stopping.
--- End quote ---
There is a other strange result: if adding fpc parameter "-Fl/usr/X11/lib", there is that error:
--- Quote ---ld: library not found -lX11.so.6
An error occured while linking
Fatal: There was 1 errors compiling module, stopping.
--- End quote ---
But libX11.so.6 is a Linux library, why fpc gives that error on Mac?
[EDIT] fpc used is 3.2.2 from installing Lazarus 3.0 package and "Command line tools for Xcode" is installed on MacOs 13.0 Ventura and Xcode is 14.3.1.
[EDIT2] Here a very simple program that fails to link X11:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program testxlib;uses xlib;begin end.
Thanks to help.
TRon:
Hi Fred,
Note that I can't verify and do not have any experience with macos.
First of all, are you sure about your:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{linklib libX11.dylib} Because to be correct it should read:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$linklib libX11.dylib}
Secondly (the most obvious one, so don't shoot me but I have to ask to make sure) are you sure you are compiling on/for MacOS ?
Thirdly, as a remark, the library prefix and/or suffix can be set globally with the $LIBPREFIX and $LIBSUFFIX directives. If you have that defined anywhere else (in included units for instance) then your expectations on what the linker actually searches for might be wrong.
Which brings me to to point four :)
Remember that libraries and their numeric suffix (versioning) is problematic to link against (on Linux) ? Linux uses file-links (usually provided by installing a "-dev" package) to be able to link against the correct version of the library.
So, it might be beneficial to analyze some output from the linker because I suspect that somewhere on your system is a link that points to that specific library in your error message. You can use the option -k to pass something to the linker. Because I do not know which linker macos uses I have no idea what parameter to pass but in case you do know the name of the linker then try invoke it from a shell and try to display its help so that you can figure out what arguments to provide in order to debug the linking process.
BTW, because the xlib.pp file is using static linking should the linker not be searching for libx11.a ?
Fred vS:
Hello Ron and thanks to help.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$linklib libX11.dylib}
Yes, of course, I forgot the "$" here but in code it is ok.
I am using VMWare and Mac OSX 13.0 on it.
All works well, including Lazarus that can compile and run LCL application.
But the problem comes from xlib.pp ( from original fpc source ).
To be able to use X11 libraries on Mac, you need to install XQwartz: https://www.xquartz.org/
The installation of XQwartz is easy, just download the package and install it (you may try, it is easy to remove it if you dont want it anymore).
But the problem comes with linking, just try this if you have a Mac (after installing XQwartz.)
Note that xlib.pp is the original from fpc source.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- program testxlib; uses xlib; begin end.
In my case, the compilation is ok but it fails at linking.
--- Quote ---Secondly (the most obvious one, so don't shoot me but I have to ask to make sure) are you sure you are compiling on/for MacOS ?
--- End quote ---
.
Huh, yes it is why I dont understand why there is that error message from fpc if I use that parameter: "-Fl/usr/X11/lib",
--- Quote ---ld: library not found -lX11.so.6
--- End quote ---
It seems to be a Linux error message.
[EDIT] In attachment screenshot of Lazarus working and linking of xlib.pp failing.
Fred vS:
Re-hello.
I have re-tried the compilation of the simple demo:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- program testxlib; uses xlib; begin end.
using that fpc parameters (like I did yesterday deep night, but adding -B parameter):
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---> fpc -B -Fl/usr/X11/lib testxlib.pas
And now the compilation + linking is ok (with a warning at linking but ok)! (see screenshot).
So, once again, sorry for the noise (but I knew that with the Mac there are always strange surprises, mainly late in the night, when I am very tired).
[EDIT] There was a msegui unit not yet adapted for Mac that I did not see yesterday.
Now msegui apps run on the Mac too (but XQwartz must be installed)!
Thanks Ron for helping.
Fre;D
Navigation
[0] Message Index