[fpc-devel] Crosscompiling win towards darwin

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Nov 21 09:35:49 CET 2016


Alfred wrote:
> With the osxcross tools, cross-compilation of non-LCL programs from
> Windows to Darwin is now successful.
> 
> When compiling with LCL, one final error keeps popping up:
> Error: linker: Undefined symbols for architecture i386:
> Error: linker:   "FPC_RESSYMBOL", referenced from:
> Debug:   "FPC_RESSYMBOL", referenced from:
> Debug:       FPC_RESLOCATION in project1.o
> ld: symbol(s) not found for architecture i386

FPC_RESSYMBOL is created by the resource writer (fpcres) in the object
file generated from the resources.

You shouldn't need a complete Lazarus program to test this,
tests/test/units/system/tres.pp should be sufficient.

If you compile that test with -va, you should see something like this:

[1.113] Calling resource compiler "/usr/local/bin/fpcres" with "-o
tres.or -a i386 -s all -of mach-o -v '@tres.reslst'" as command line

In particular, the "-of macho-o" is important. There should be a tres.or
file afterwards that defines FPC_RESSYMBOL. If your osxcross tools
include a copy of the nm binary, you can use that to check: "nm tres.or"
should print something like "00000000 S FPC_RESSYMBOL" (otherwise copy
the file to a Mac and run nm there). On a Mac, you can also use "file
tres.or" to verify that it is actually an i386 Mach-O object file.

This tres.or file should also be linked into the generated binary.
Compile with -a -s and check whether tres.or appears in link.res and/or
in the command line when calling the linker from ppas.bat. Run the
generated ppas.bat file to see whether the linker prints any errors that
Lazarus or the compiler hid.


Jonas



More information about the fpc-devel mailing list