Recent

Author Topic: Another question about cross-compiling  (Read 1926 times)

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Another question about cross-compiling
« Reply #15 on: October 12, 2024, 02:36:02 pm »
Thanks Warfley and TRon,

I changes my Lazarus Settings to `/usr/local/bin/fpc` for the Compiler Executable, and it does, indeed as you say, dispatch the command to the correct backend. I thought I had already tried that, but obviously not 😉

Unfortunately, I've just wasted the entire morning, before realising that the build process as started by the `/usr/local/bin/fpc` setting differs from the build process started by the `/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.sh` setting. The difference being that the app built completely and without errors with the second setting whereas with the first setting it gave me all sorts of issues relating to paths and god knows what else!

I was starting to wonder if I had finally lost any remaining grip on tangible reality :o

UPDATE: I looked more closely at the `fpc` that I had used in the failing attempts. It was dated 16/05/2021 so no wonder it failed to build properly.

So the question remains: what setting to I need to put in my "Settings" -> "Environment" -> "Files" -> "Compiler Executable (e.g. fpc)"?
As previously stated, I have to switch between "/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.sh" to build for macOS, and "/usr/local/bin/ppcrossx64" to cross-compile for Windows.

The "fpc.sh" just mentioned consists of...
Code: Bash  [Select][+][-]
  1. #!/bin/sh
  2. # This script starts the fpc compiler installed by fpcup
  3. # and ignores any system-wide fpc.cfg files
  4. # Note: maintained by fpcup; do not edit directly, your edits will be lost.
  5. /Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc -n @/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.cfg "$@"
  6.  
« Last Edit: October 12, 2024, 02:51:08 pm by carl_caulkett »
"It builds... ship it!"

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Another question about cross-compiling
« Reply #16 on: October 12, 2024, 03:03:55 pm »
Thats what the compiler stub is for. The actual compiler are the ppcXXX compilers, the fpc binary is just stub which will dispatch the calls to the correct ppc compiler. So when you in your project options select the correct target architecture the compiler stub should select the correct cross compiler.

You should not need to change the compiler path to the ppcXXX compilers from the fpc (or the fpc.sh in case of fpcup). A few years ago I've built a docker pipeline with Win32 and Win64 cross compilers using fpcup and lazbuild using build configurations, and it worked quite well. I've wrote it down here

If your compiler stub has trouble finding the correct compiler executables, it's probably because they are neither in the search path nor in the same directory. The easiest solution on *nix is usually to just create a symlink into the fpc directory

So where is this platform-agnostic version of `fpc`?
"It builds... ship it!"

TRon

  • Hero Member
  • *****
  • Posts: 3619
Re: Another question about cross-compiling
« Reply #17 on: October 12, 2024, 04:23:25 pm »
So where is this platform-agnostic version of `fpc`?
In your specific case: /Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc

Quote
I was starting to wonder if I had finally lost any remaining grip on tangible reality :o
You made a classical (newbie) error, that's all. It is complicated/overwhelming if you are unfamiliar.

I have to guess a little but it seems that the cross-compiler was installed system-wide while the Lazarus installation came with its own FPC setup.

The trick there is to 'merge' the cross-compiler with the FPC compiler used by Lazarus.

If you remember, I posted a directory/file overview of my setup. I advise to have another look at it.

In the Lazarus FPC directory /Applications/Lazarus_trunk/fpc/ should be a directory located named "units" (that is, if Lazarus  was installed that way).

The (compiled) units of the cross compiler need to be tucked in that same directory using its own cpu-os name combination so that this directory resides along the "x86_64-darwin" directory (to make sure, as a sub-directory of the units directory).

The other thing that needs to be done is to copy the ppcXXX (cross-)compiler to the binary directory of FPC (or wherever FPC (fpc.cfg) expects its tools to be stored).

If FPCUpDeluxe was also used to install Lazarus then it should be possible to update the Lazarus installation with only the cross-compiler so that FPCUpDeluxe does everything (automatically) for you. That only works when the same settings in FPCUpDeluxe are used for both the Lazarus installation and building the cross-compiler.

I would advise to remove the global installed cross-compiler completely and start anew (or cheat by using the instructions that I wrote in this post and copying the required files over to the Lazarus installation first)

I apologize upfront for the messy solution/instructions. In case you are indeed trying to do things manually and if something is not matching my instructions or something seems off then please post. I wrote this all from memory so there might be something off.
« Last Edit: October 12, 2024, 04:35:19 pm by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Another question about cross-compiling
« Reply #18 on: October 12, 2024, 04:35:14 pm »
In your specific case: /Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc

if I choose that, rather than `/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.sh` the build fails with "Fatal: Can't find unit system used by ListMIDIDevices".

I'll stick to switching in both places. At least it works that way 😮
« Last Edit: October 12, 2024, 04:38:50 pm by carl_caulkett »
"It builds... ship it!"

TRon

  • Hero Member
  • *****
  • Posts: 3619
Re: Another question about cross-compiling
« Reply #19 on: October 12, 2024, 05:28:24 pm »
if I choose that, rather than `/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.sh` the build fails with "Fatal: Can't find unit system used by ListMIDIDevices".
For the cross-compilation, yes. Because the cross-compiler is not installed alongside the FPC compiler used by Lazarus (but rather. installed system wide). "There can be only one", "one ring to rule them all" etc..

As a fair warning of someone who has been there and done that, using a standalone and system-wide installation together is a dangerous combination. In the end it'll bite you in the proverbial buttocks  :)

It is not a problem to have different (standalone) installations but one should definitely avoid a system wide installation (either by doing so manually or with your systems package manager if you do so. The latter which btw does not even have a clue about FPC cross-compiler setups nor does it offer them).

Quote
I'll stick to switching in both places. At least it works that way 😮
You should definitely decide that for yourself, and use whatever makes you comfortable.

Just keep this issue in mind in case you happen to bump into another hurdle and remember that you can use the compiler option -vt and/or -vd to tell/show what is actually happening.
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Another question about cross-compiling
« Reply #20 on: October 12, 2024, 05:36:04 pm »
if I choose that, rather than `/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.sh` the build fails with "Fatal: Can't find unit system used by ListMIDIDevices".
For the cross-compilation, yes. Because the cross-compiler is not installed alongside the FPC compiler used by Lazarus (but rather. installed system wide). "There can be only one", "one ring to rule them all" etc..
that you can use the compiler option -vt and/or -vd to tell/show what is actually happening.

So, should I just copy the "system-wide" cross-compiler "/usr/local/bin/ppcrossx64" to somewhere within the "/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin" folder, thus making it available to Lazarus?
"It builds... ship it!"

TRon

  • Hero Member
  • *****
  • Posts: 3619
Re: Another question about cross-compiling
« Reply #21 on: October 12, 2024, 05:57:00 pm »
So, should I just copy the "system-wide" cross-compiler "/usr/local/bin/ppcrossx64" to somewhere within the "/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin" folder, thus making it available to Lazarus?
The short answer, yes.

The long(er) answer:
That particular file (ppcrossx64) can be place next to your Lazarus' fpc executable (or where Lazarus stores its (native) ppc compiler)

The only other thing that needs to be copied are the (compiled) units that where installed by the cross-compiler (inside a directory named units usually with a sub-directory which in your case should probably be named something like aarch-win64 or arm-win64). I do not know where that location is on a mac. Invoking the cross compiler using the fpc script and adding the option -vd to compile a simple program is able to reveal where that location is (other than analyzing the fpc.cfg file that the cross-compiler uses) .

Refer to my directory tree overview of my setup to get a better understanding of how that should end up like when copied to the Lazarus FPC directory) though keep in mind that depending on how you have configured FPCUpDeluxe when Lazarus was installed the exact locations might be different (but you can verify those beforehand with a file-manager).

As long as nothing is overwritten inside your Lazarus installation directories (only add) copying files (f.e.to a wrong location) can't hurt other than making things messy, so take notes in order to remove in case something went wrong.

EDIT:
There is one thing that can make this fail and that is when the Lazarus FPC compiler and standalone cross-compiler do not match versions. They must both be the exact same version.
« Last Edit: October 12, 2024, 05:59:48 pm by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Another question about cross-compiling
« Reply #22 on: October 13, 2024, 12:01:55 am »
So, should I just copy the "system-wide" cross-compiler "/usr/local/bin/ppcrossx64" to somewhere within the "/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin" folder, thus making it available to Lazarus?
The short answer, yes.

The long(er) answer:
That particular file (ppcrossx64) can be place next to your Lazarus' fpc executable (or where Lazarus stores its (native) ppc compiler)

Thanks! I've copied over the alias "/usr/local/bin/ppcrossx64" to the "/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin" folder. What, then, should be the entry in my "Settings" -> "Environment" -> "Files" -> "Compiler Executable (e.g. fpc)" field?
"It builds... ship it!"

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Another question about cross-compiling
« Reply #23 on: October 13, 2024, 12:10:46 am »
No worries! I remembered that I still had my old Lazarus 3.4 installation so I copied the "/usr/local/bin/fpc" entry from there, and, lo and behold, I can switch from Mac to Windows with just one operation. Yay! :D
Thanks for your help, everybody 🙏🏽
« Last Edit: October 13, 2024, 12:16:45 am by carl_caulkett »
"It builds... ship it!"

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Another question about cross-compiling
« Reply #24 on: October 13, 2024, 01:35:22 pm »
Famous last words  ;)

There is still a difference between setting the "Compiler Executable" to "/usr/local/bin/fpc" and setting it to "/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.sh".

In the first case, the build,is failing with camidimac.pas(11,3) Error: Cannot find MacOsAll used by caMidiMac. Make sure all ppu files of a package are in its output directory. ppu in wrong directory=/usr/local/lib/fpc/3.2.2/units/x86_64-darwin/univint/MacOSAll.ppu.."

In the second case, the app builds perfectly!
"It builds... ship it!"

TRon

  • Hero Member
  • *****
  • Posts: 3619
Re: Another question about cross-compiling
« Reply #25 on: October 13, 2024, 01:58:41 pm »
There is still a difference between setting the "Compiler Executable" to "/usr/local/bin/fpc" and setting it to "/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.sh".
The first thing that came to mind is that in one of the earlier made post the code was posted and I noticed inside caMacMidiForm the uses clause to include macosall.

But, that should end up in an error when cross-compiling no matter what.

The only other thing that is able to influence that is differences in fpc.cfg between those between the configuration of the native compiler vs the cross-compiler. FPC allows for specific settings to take place only when it is cross-compiling but a stand-alone cross-compiler (its fpc.cfg) does not have to take that into account (by default).

Are you able to locate anything in the native fpc.cfg compiler settings that would be able to account for dragging in the macos all unit ?

I am out of my comfort zone there because I do not have to hardware to be able to test.
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Another question about cross-compiling
« Reply #26 on: October 13, 2024, 04:20:49 pm »
Thanks for the reply TRon! The unit caMacMidiForm was from a test app. The unit caMidiMac (admittedly the similar names are potentially confusing!) is a unit with the OsmosePresets project, the inclusion of which is governed by {$IFDEF DARWIN} directives.

Both of the scenarios described are with the macOS Project Options selected. The MacOsAll unit should be dragged in, in both cases!

It pains me to say it, but the Windows option is working perfectly ;)
"It builds... ship it!"

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Another question about cross-compiling
« Reply #27 on: October 13, 2024, 08:57:19 pm »
The macOS "Compiler Executable" setting that DOES work is "/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.sh"

"fpc.sh" consists of...
Code: Bash  [Select][+][-]
  1. #!/bin/sh
  2. # This script starts the fpc compiler installed by fpcup
  3. # and ignores any system-wide fpc.cfg files
  4. # Note: maintained by fpcup; do not edit directly, your edits will be lost.
  5. /Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc -n @/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.cfg "$@"
  6.  

while "fpc.cfg", in the same folder, consists of
Code: Pascal  [Select][+][-]
  1. #
  2. # Config file generated by fpcmkcfg on 30-9-24 - 13:44:42
  3. # Example fpc.cfg for Free Pascal Compiler
  4. #
  5.  
  6. # ----------------------
  7. # Defines (preprocessor)
  8. # ----------------------
  9.  
  10. #
  11. # nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
  12. #
  13. # -d is the same as #DEFINE
  14. # -u is the same as #UNDEF
  15. #
  16.  
  17. #
  18. # Some examples (for switches see below, and the -? helppages)
  19. #
  20. # Try compiling with the -dRELEASE or -dDEBUG on the commandline
  21. #
  22.  
  23. # For a release compile with optimizes and strip debuginfo
  24. #IFDEF RELEASE
  25.   -O2
  26.   -Xs
  27.   #WRITE Compiling Release Version
  28. #ENDIF
  29.  
  30. # For a debug version compile with debuginfo and all codegeneration checks on
  31. #IFDEF DEBUG
  32.   -gl
  33.   -Crtoi
  34.   #WRITE Compiling Debug Version
  35. #ELSE
  36.   # Strip debuginfo from the executable if not in debug mode
  37.   -Xs
  38. #ENDIF
  39.  
  40. # assembling
  41. #ifdef darwin
  42. # use pipes instead of temporary files for assembling
  43. -ap
  44. #endif
  45.  
  46. # ----------------
  47. # Parsing switches
  48. # ----------------
  49.  
  50. # Pascal language mode
  51. #      -Mfpc      free pascal dialect (default)
  52. #      -Mobjfpc   switch some Delphi 2 extensions on
  53. #      -Mdelphi   tries to be Delphi compatible
  54. #      -Mtp       tries to be TP/BP 7.0 compatible
  55. #      -Mgpc      tries to be gpc compatible
  56. #      -Mmacpas   tries to be compatible to the macintosh pascal dialects
  57. #
  58. # Turn on Object Pascal extensions by default
  59. #-Mobjfpc
  60.  
  61. # Assembler reader mode
  62. #      -Rdefault  use default assembler
  63. #      -Ratt      read AT&T style assembler
  64. #      -Rintel    read Intel style assembler
  65. #
  66. # All assembler blocks are AT&T styled by default
  67. #-Ratt
  68.  
  69. # Semantic checking
  70. #      -S2        same as -Mobjfpc
  71. #      -Sc        supports operators like C (*=,+=,/= and -=)
  72. #      -Sa        include assertion code.
  73. #      -Sd        same as -Mdelphi
  74. #      -Se<x>     error options. <x> is a combination of the following:
  75. #         <n> : compiler stops after <n> errors (default is 1)
  76. #         w   : compiler stops also after warnings
  77. #         n   : compiler stops also after notes
  78. #         h   : compiler stops also after hints
  79. #      -Sg        allow LABEL and GOTO
  80. #      -Sh        Use ansistrings
  81. #      -Si        support C++ styled INLINE
  82. #      -Sk        load fpcylix unit
  83. #      -SI<x>     set interface style to <x>
  84. #         -SIcom    COM compatible interface (default)
  85. #         -SIcorba  CORBA compatible interface
  86. #      -Sm        support macros like C (global)
  87. #      -So        same as -Mtp
  88. #      -Sp        same as -Mgpc
  89. #      -Ss        constructor name must be init (destructor must be done)
  90. #      -Sx        enable exception keywords (default in Delphi/ObjFPC modes)
  91. #
  92. # Allow goto, inline, C-operators, C-vars
  93. -Sgic
  94.  
  95. # ---------------
  96. # Code generation
  97. # ---------------
  98.  
  99. # Uncomment the next line if you always want static/dynamic units by default
  100. # (can be overruled with -CD, -CS at the commandline)
  101. #-CS
  102. #-CD
  103.  
  104. # Set the default heapsize to 8Mb
  105. #-Ch8000000
  106.  
  107. # Set default codegeneration checks (iocheck, overflow, range, stack)
  108. #-Ci
  109. #-Co
  110. #-Cr
  111. #-Ct
  112.  
  113. # Optimizer switches
  114. # -Os        generate smaller code
  115. # -Oa=N      set alignment to N
  116. # -O1        level 1 optimizations (quick optimizations, debuggable)
  117. # -O2        level 2 optimizations (-O1 + optimizations which make debugging more difficult)
  118. # -O3        level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
  119. # -Oo<x>     switch on optimalization x. See fpc -i for possible values
  120. # -OoNO<x>   switch off optimalization x. See fpc -i for possible values
  121. # -Op<x>     set target cpu for optimizing, see fpc -i for possible values
  122.  
  123. #ifdef darwin
  124. #ifdef cpui386
  125. -Cppentiumm
  126. -Oppentiumm
  127. #endif
  128. #endif
  129.  
  130. # -----------------------
  131. # Set Filenames and Paths
  132. # -----------------------
  133.  
  134. # Both slashes and backslashes are allowed in paths
  135.  
  136. # path to the messagefile, not necessary anymore but can be used to override
  137. # the default language
  138. #-Fr/Applications/Lazarus_trunk/fpc/msg/errore.msg
  139. #-Fr/Applications/Lazarus_trunk/fpc/msg/errorn.msg
  140. #-Fr/Applications/Lazarus_trunk/fpc/msg/errores.msg
  141. #-Fr/Applications/Lazarus_trunk/fpc/msg/errord.msg
  142. #-Fr/Applications/Lazarus_trunk/fpc/msg/errorr.msg
  143.  
  144. # search path for unicode binary files (FPC 2.x does not know this switch)
  145. #ifndef VER2
  146. -FM/Applications/Lazarus_trunk/fpc/share/unicode/
  147. #endif
  148.  
  149. # Search for $fpctarget/$fpcsubarch-$fpcmemorymodel/ subdirectory first
  150. # for i8086 CPU
  151. #ifdef cpui8086
  152. -Fu/Applications/Lazarus_trunk/fpc/units/$fpctarget/$fpcsubarch-$fpcmemorymodel
  153. -Fu/Applications/Lazarus_trunk/fpc/units/$fpctarget/$fpcsubarch-$fpcmemorymodel/*
  154. -Fu/Applications/Lazarus_trunk/fpc/units/$fpctarget/$fpcsubarch-$fpcmemorymodel/rtl
  155. #endif
  156.  
  157. # searchpath for units and other system dependent things
  158. -Fu/Applications/Lazarus_trunk/fpc/units/$fpctarget
  159. -Fu/Applications/Lazarus_trunk/fpc/units/$fpctarget/*
  160. -Fu/Applications/Lazarus_trunk/fpc/units/$fpctarget/rtl
  161.  
  162. #IFDEF FPCAPACHE_1_3
  163. -Fu/Applications/Lazarus_trunk/fpc/units/$fpctarget/httpd13/
  164. #ELSE
  165. #IFDEF FPCAPACHE_2_0
  166. -Fu/Applications/Lazarus_trunk/fpc/units/$fpctarget/httpd20
  167. #ELSE
  168. -Fu/Applications/Lazarus_trunk/fpc/units/$fpctarget/httpd22
  169. #ENDIF
  170. #ENDIF
  171.  
  172. # searchpath for fppkg user-specific packages
  173. -Fu/Applications/Lazarus_trunk/packages.fppkg/units/$fpctarget/*
  174.  
  175. # searchpath for tools
  176. -FD/Applications/Lazarus_trunk/fpc/bin/$FPCTARGET
  177.  
  178. # path to the gcclib
  179. #ifdef Darwin
  180. #ifdef cpui386
  181. -Fl/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/lib/darwin
  182. #endif
  183. #ifdef cpux86_64
  184. -Fl/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/lib/darwin
  185. #endif
  186. -FD/Library/Developer/CommandLineTools/usr/bin
  187. #ifdef cpui386
  188. -Fl/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
  189. #endif
  190. #ifndef cpui386
  191. #ifndef cpupowerpc
  192. #ifndef cpupowerpc64
  193. -XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
  194. #endif
  195. #endif
  196. #endif
  197. #endif
  198.  
  199.  
  200. # searchpath for libraries
  201. #-Fl/Applications/Lazarus_trunk/fpc/lib
  202. #-Fl/lib;/usr/lib
  203. -Fl/Applications/Lazarus_trunk/fpc/lib/$FPCTARGET
  204.  
  205. #IFNDEF Darwin
  206. #DEFINE NEEDCROSSBINUTILS
  207. #ENDIF
  208.  
  209. # never need cross-prefix when targeting the JVM
  210. # (no native compiler, always cross-compiling)
  211. #ifdef cpujvm
  212. #undef NEEDCROSSBINUTILS
  213. #endif
  214.  
  215. # for android cross-prefix is set by compiler
  216. #ifdef android
  217. #undef NEEDCROSSBINUTILS
  218. #endif
  219.  
  220. # never need cross-prefix when targeting the i8086
  221. # (no native compiler, always cross-compiling)
  222. #ifdef cpui8086
  223. #undef NEEDCROSSBINUTILS
  224. #endif
  225.  
  226. # binutils prefix for cross compiling
  227. #IFDEF FPC_CROSSCOMPILING
  228. #IFDEF NEEDCROSSBINUTILS
  229.   -XP$FPCTARGET-
  230. #ENDIF
  231. #ENDIF
  232.  
  233.  
  234. # -------------
  235. # Linking
  236. # -------------
  237.  
  238. # generate always debugging information for GDB (slows down the compiling
  239. # process)
  240. #      -gc        generate checks for pointers
  241. #      -gd        use dbx
  242. #      -gg        use gsym
  243. #      -gh        use heap trace unit (for memory leak debugging)
  244. #      -gl        use line info unit to show more info for backtraces
  245. #      -gv        generates programs tracable with valgrind
  246. #      -gw        generate dwarf debugging info
  247. #
  248. # Enable debuginfo and use the line info unit by default
  249. #-gl
  250.  
  251. # always pass an option to the linker
  252. #-k-s
  253.  
  254. # Always use smartlinking on i8086, because the system unit exceeds the 64kb
  255. # code limit
  256. #ifdef cpui8086
  257. -CX
  258. -XX
  259. #endif
  260.  
  261.  
  262. # -------------
  263. # Miscellaneous
  264. # -------------
  265.  
  266. # Write always a nice FPC logo ;)
  267. -l
  268.  
  269. # Verbosity
  270. #      e : Show errors (default)       d : Show debug info
  271. #      w : Show warnings               u : Show unit info
  272. #      n : Show notes                  t : Show tried/used files
  273. #      h : Show hints                  s : Show time stamps
  274. #      i : Show general info           q : Show message numbers
  275. #      l : Show linenumbers            c : Show conditionals
  276. #      a : Show everything             0 : Show nothing (except errors)
  277. #      b : Write file names messages   r : Rhide/GCC compatibility mode
  278. #          with full path              x : Executable info (Win32 only)
  279. #      v : write fpcdebug.txt with     p : Write tree.log with parse tree
  280. #          lots of debugging info
  281. #
  282. # Display Info, Warnings and Notes
  283. -viwn
  284. # If you don't want so much verbosity use
  285. #-vw
  286.  
  287.  
  288.  
  289. # begin fpcup do not remove : base settings
  290. # Adding binary tools paths to
  291. # plain bin dir and architecture bin dir so
  292. # fpc 3.1+ fpcres etc can be found.
  293. -FD/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin;/Applications/Lazarus_trunk/fpc
  294. # library search path
  295. -Fl/usr/lib/$fpctarget;/usr/lib/$fpctarget-gnu;/lib/$fpctarget;/lib/$fpctarget-gnu
  296. #IFNDEF FPC_CROSSCOMPILING
  297. -Fl/usr/lib/gcc
  298. #ENDIF
  299.  
  300. # Add some extra OSX options, if any
  301. #IFDEF DARWIN
  302. # Prevents crti not found linking errors
  303. #IFNDEF FPC_CROSSCOMPILING
  304. -WM10.9
  305. #ENDIF
  306. #ENDIF
  307.  
  308. # MacOS 10.14 Mojave and newer have libs and tools in new, yet non-standard directory
  309. #IFDEF DARWIN
  310. -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
  311. #ENDIF
  312. -Fl/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
  313. -FD/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  314. # end fpcup do not remove
  315.  


I have to confess that I am finding the "fpc.cfg", shown above, rather intimidating  :o

If someone could offer me some pointers on this, I'd be very grateful 🙏🏽

Just to reiterate, I'm after a single "Compiler Executable" which will call either the macOS "/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.sh" command, or the "/usr/local/bin/ppcrossx64" command for Windows.

I also tried leaving the "/usr/local/bin/ppcrossx64" command in there and choosing the macOS Project Options. The build seemed to progress a long way but eventually failed on the not being able to find MacOsAll, despite me adding the source path and then the "ppu" path in "Compiler Options" -> "Paths". Lazarus itself can clearly find MacOsAll.pas because Ctrl-Enter in the code editor opens the file!
« Last Edit: October 13, 2024, 09:18:21 pm by carl_caulkett »
"It builds... ship it!"

TRon

  • Hero Member
  • *****
  • Posts: 3619
Re: Another question about cross-compiling
« Reply #28 on: October 13, 2024, 09:59:38 pm »
Quote
Just to reiterate, I'm after a single "Compiler Executable" which will call either the macOS "/Applications/Lazarus_trunk/fpc/bin/x86_64-darwin/fpc.sh" command, or the "/usr/local/bin/ppcrossx64" command for Windows.
It should be the former, which script will point to the actual fpc (front-end) compiler.

Selecting the target processor and os in the project options then should automatically invoke the ppccrossx86 cross-compiler.

BTW: perhaps it is me but I could have sworn that you mentioned windows on arm (and therefor also assume mac on arm). Neither of which seems to be true according to what I am able to see now.

Quote
I also tried leaving the "/usr/local/bin/ppcrossx64" command in there and choosing the macOS Project Options. The build seemed to progress a long way but eventually failed on the not being able to find MacOsAll, despite me adding the source path and then the "ppu" path in "Compiler Options" -> "Paths". Lazarus itself can clearly find MacOsAll.pas because Ctrl-Enter in the code editor opens the file!
Apologies for not replying to this part sooner but your previous response threw me a bit off-guard.

There is no macos(all) unit for targets that are not macos.

Reason is simple: the macosall unit binds itself to the underlying required frameworks and these do not exist on other platforms besides macos.

While on the subject of sharing, could you share the fpc.cfg used by the cross-compiler as well ? That should include the missing parts that need to be added top the fpc.cfg that was shared in your post.
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Another question about cross-compiling
« Reply #29 on: October 13, 2024, 10:25:10 pm »
I've just made a discovery which, while not a breakthrough, might offer a clue as to what's going on here. If I load the test app "caMacMidi.lpr" which references my midi files in exactly the same way as my main project "OsmosePresets", the project builds in both macOS and Windows modes.

The first image shows how the test app "caMacMidi.lpr" is structured.

If I load the main app "OsmosePresets.lpr", the structure of which is shown in the second image, the build fails with the message "camidimac.pas(11,3) Error: Cannot find MacOsAll used by caMidiMac. Make sure all ppu files of a package are in its output directory. ppu in wrong directory=/usr/local/lib/fpc/3.2.2/units/x86_64-darwin/univint/MacOSAll.ppu.."

The "camidi..." files referenced by the "../camidi/..." items are attached in the zip file.
The "MacMidi" test app and the "OsmosePresets" app will be attached to the following message.

Note that the only place in the entire code where MacOsAll is mentioned is in the file "camidimac.pas".

« Last Edit: October 13, 2024, 10:27:30 pm by carl_caulkett »
"It builds... ship it!"

 

TinyPortal © 2005-2018