Delphi – Linux windres cross-compile and crtbegin.so error

Lately I came across very annoying problem with installed Free Pascal  IDE  (CodeTyphon or Lazarus) under Linux Mint 18.1. When you try to compile the project the following error pops up:

 Error: resource compiler "windres.exe" not found, switching to external mode

For compatibility reasons the fpc toolchain uses windres to compile and link the resource files to your project. It uses Delphi compatible RC format. When you are cross-compiling for Windows you need to install mingw to be able to use windres.

You can do it with the following command under debian:

sudo apt-get install mingw-w64

Then create a symlink to allow the IDE find the executable:

sudo ln -s /usr/bin/x86_64-w64-mingw32-windres /usr/bin/windres

This should fix the problem with compiling RC files.

If you get Linker warnings "crtbegin.o" not found" when compiling your project, you have to ensure that latest GNU libraries are added to the fpc.cnf file which is used during linking and compilation of your projects.

In order to fix this warning add this line:
-Fl/usr/lib/gcc/x86_64-linux-gnu/version

to your fpc.cnf file, #searchpath for libraries section, which looks like this:

# searchpath for libraries

-Fl/usr/lib64
-Fl/usr/lib/x86_64-linux-gnu
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.9
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.8
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.7
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.6
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.2.3
-Fl/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.7.4
-Fl/usr/lib/gcc/x86_64-redhat-linux/4.8.2
-Fl/usr/lib64/gcc/x86_64-suse-linux/4.8/
-Fl/usr/lib/gcc/x86_64-redhat-linux/4.8.3
-Fl/usr/lib/gcc/x86_64-linux-gnu/6
-Fl/usr/lib/gcc/x86_64-redhat-linux/7
-Fl/usr/lib/gcc/x86_64-linux-gnu/7
-Fl/usr/lib/gcc/x86_64-linux-gnu/8
-Fl/usr/lib/gcc/x86_64-linux-gnu/version*

version*  is the latest GNU compiler version installed to your system.

Tell us about your thoughtsWrite message

Your email address will not be published. Required fields are marked *