Closed fredvs closed 10 months ago
Hello.
OK, I found a solution. It is to replace /etc/fpc.cfg with the one of fpcupdeluxe, like this:
$ sudo cp /home/fred/fpcupdeluxe/fpc/bin/x86_64-linux/fpc.cfg /etc/
Now it cross-compile like charm.
EXCELLENT and many thanks for that great project.
Hum, nearly all is working. Assembling is ok but linking not yet:
ld: file not found: Foundation
OK, needed to use -sh to get the script. So the steps:
Compile with -sh parameter to get the script ppas.sh for the linker.
Edit ppas.sh
Remove "-framework AppKit Foundation CoreFoundation".
Run the ppas.sh script.
The project I want to compile uses XQuartz and for linking libX11.dylib and fontconfig.dylib are needed. So libX11.dylib and fontconfig.dylib were copied into /fpcupdeluxe/cross/lib/all-darwin/.
Here those libraries, maybe it could be good that fpcupdeluxe has those libraries and then apps using XQuartz can be cross-compiled out of the box. lib_X11_mac.zip
About the linker parameter "-framework AppKit Foundation CoreFoundation", is it possible to disable it and not be obliged to use -sh and to edit the script and run it?
Anyway, time to exclamation: WOOOOW, I just have try the cross-compiled binary of MSEide for the Mac and it works ! So BIG congratulation to fpcupdeluxe, you are still in the mood of Big Chimp, with always excellent stuffs. Even without install XCode, the binary works!
[EDIT] And to cross-compile from linux x86_64 to darwin aarch64, this fpc parameter needed to be added:
-Fl/home/fred/fpcupdeluxe/cross/lib/all-darwin/
Many thanks Don.
Fre;D
Good. You might be right about linking with AppKit+Foundation+CoreFoundation. But I am not 100% sure. Could you please give me more details about the errors that you encounter with this setup ? I guess some changes are needed, but I a still not certain about it.
Hello.
When compiling the project without -sh parameter, there is that error:
Free Pascal Compiler version 3.2.2-r0d122c49 [2024/01/14] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others (1002) Target OS: Darwin for x86_64 (3104) Compiling mseide.pas ... (9009) Assembling mseide ld: file not found: Foundation (1008) 680615 lines compiled, 27.9 sec (1021) 21 warning(s) issued (1023) 54 note(s) issued
Note that the compilation ended with no error message, only a message ld: file not found: Foundation but the executable is not created. Note too that only "Foundation" appears, not the all "AppKit Foundation CoreFoundation", like in the ppas.sh.
If I compile the project directly on Mac the compilation + linking is ok.
Cross compiling+linking from _linux x8664 to darwin Aarch64, gives exactly the same problem. But using the -sh parameter and editing the script like explained, the cross compilation+linking is OK (BIG WOW).
Fre;D
Hello.
Here is the result of ppas.sh when compiling a project on a real Mac with -sh fpc parameter:
...
echo Linking apps/ide/mseide
OFS=$IFS
IFS="
"
/Library/Developer/CommandLineTools/usr/bin/ld -dead_strip -no_dead_strip_inits_and_terms -x -order_file symbol_order.fpc -multiply_defined suppress -L. -o apps/ide/mseide `cat link897.res` -filelist linkfiles897.res
if [ $? != 0 ]; then DoExitLink apps/ide/mseide; fi
IFS=$OFS
This script produces a working binary.
And here the result of ppas.sh when cross-compiling the same project on a Linux x86_64 machine using /fpcupdeluxe/fpc/bin/x86_64-linux/ppcrossx64 of fpcupdeluxe with -sh and -Tdarwin parameters:
...
echo Linking mseide
OFS=$IFS
IFS="
"
/home/fred/fpcupdeluxe/cross/bin/all-apple/bin/x86_64-apple-darwin19-ld -framework AppKit Foundation CoreFoundation -dead_strip -no_dead_strip_inits_and_terms -x -order_file symbol_order.fpc -multiply_defined suppress -L. -o mseide `cat link17950.res` -filelist linkfiles17950.res
if [ $? != 0 ]; then DoExitLink mseide; fi
IFS=$OFS
Here -framework AppKit Foundation CoreFoundation was added and produces a error at linking.
Ok. Thanks. I guess its this fpcupdeluxe bugger. https://github.com/LongDirtyAnimAlf/fpcupdeluxe/issues/655 Please test the latest [pre-]release.
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/v2.4.0c https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/v2.4.0dp
Hello Don.
Ok, cross compiling to _darwin_x8464 and _darwin_aarch6_4 is ok now, many thanks.
But, like explained in https://github.com/LongDirtyAnimAlf/fpcupdeluxe/issues/659#issuecomment-1901091985 ,I have to copy libX11.dylib and libfontconfig.dylib into /fpcupdeluxe/cross/lib/all-darwin. Also add this fpc parameter:-Fl/fpcupdeluxe/cross/lib/all-darwin/ to enable the linking of those libraries.
Many thanks for your wonderful work.
Fre;D
What version of the SDK has these libs ? I can see them in 10.5 and 10.6, but not in 10.13 and newer. And, if you install X11 on Mac in another way, how do you do this.
In the (great) past XQuartz was installed by default. Now if must be installed by the user. The good news is that XQuartz is still deeply maintained and follows each version of OSX.
It is done by downloading the package and install it from here (really out-of-the-box): https://www.xquartz.org/
And for libfontconfig:
$ brew install fontconfig
But for people that want only to compile applications for XQuartz, like fpGUI or MSEgui, you only need libX11.dylib and libfontconfig.dylib (the zip file of my previous post). Those libraries are only needed for the linking.
Newer ?
If you uses old version of libX11.dylib it still works because X11 dont have update and will never have, the same for libfontconfig. So the deal of XQuartz is to adapt his code to make the old and robust libX11.dylib compatible with each new release of OSX.
I can see them in 10.5 and 10.6, but not in 10.13 and newer.
I suppose it is not in the newer SDK when XQuartz was not installed by default anymore on OSX.
Fantastic!
Many thanks.
Re-hello.
Your cross-compiler to Darwin is a gem. So bright that I have a question: is it possible to use your cross-compil libraries directly on a Mac?
I mean be able to compile a Mac application on the Mac but without the obligation to install XCode (that needs lot of gigas and a Mac-user account)?
It would be great for Mac-users ( maybe, I am only a virtual-Mac user).
If I am not wrong, "xcode-select –-install" is the only thing you need on Mac to get things going.
https://mac.install.guide/commandlinetools/4.html https://mac.install.guide/commandlinetools/index.html
OK, thanks for the info. But using fpcupdeluxe cross-compiler is even (much) simpler ;-)
That is what I meant. If I remember well, with only that command, you can use fpcupdeluxe for crossing on Mac. You are welcome to try and give feedback.
OK, I will try.
But the magic is that when I did cross-compilation from Linux to Mac, using only fpcupdeluxe, the result-binary is working out-of-the-box on a Mac, without installing anything.
For a not-Mac user like me it is fantastic. I have to find somebody that has a Mac with the aarch64 arm cpu to see if the crosscompilation gives also a working binary (the cross compilation from Linux x86_64 to Darwin aarch64 was also ok but I did not test it yet on a real machine).
Aarch64 will also work flawless. But you have to "codesign" the binary. See first fixed issue about this !
See first fixed issue about this !
Huh, sorry but I dont see it. Where must I look?
Ha, ok, some joy of the Mac that I have to discover. OK, noted, thanks.
Hello.
I use last fpcupdeluxe version 2.4.0, installing the cross compiler was ok and clang too.
But when trying to compile a test demo with this:
> /home/fred/fpcupdeluxe/fpc/bin/x86_64-linux/ppcrossx64 -Tdarwin test.pas
there is that error message:
test.pas(533) Error: (9005) Assembler x86_64-darwin-clang not found, switching to external assembling
Must I install something more?
Thanks