Forum > FPC development

Non-OS dependent way to use fpcres, the FPC resource file converter

(1/3) > >>

Kepsz:
I recently found out that Lazarus contains its own resource converter, so it is no longer necessary to use the old brcc32 compiler, which disappeared from the net and only worked under Windows anyway...
However, I did not find any substantial documentation on its use.


Let see the usage under Windows.

Right now, the first option is to set the file path manually to the pre-compile command, but that will only work till the next Lazarus update. Same is true to adding the ..fpc\3.2.2\bin folder to $PATH.

--- 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";}};} ---D:\Work\Lazarus\fpc\3.2.2\bin\x86_64-win64\fpcres.exe resfile.rc -o resfile.res -of res
The second option is to upgrade that line with IDE macros:

--- 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";}};} ---$(LazarusDir)\fpc\$(FPCVER)\bin\$(TargetCPU)-$(TargetOS)\fpcres.exe resfile.rc -o resfile.res -of res

Option 2 works fine... However, it is not Linux compatible. Under Linux, the entire file browsing process is unnecessary, because the OS already knows the location of the fpcres program by default.
A universal solution for this would be nice, because I sometimes work on the same project from both Linux and Windows using GIT.

paweld:
if you are using rc file then you don't need to convert to res file yourself, when building a project Lazarus will do it automatically. You just attach only the rc file:
--- 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";}};} ---{$R my_resources.rc}

marcov:
Just put it in your .dpr/.lpr like this:


--- 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";}};} ---{$R 'logo.res' 'logo.rc'}
and FPC should auto call the resource compiler.

Note that fpcres is still not the default for third party resource scripts, the current defaults are windres (for 32-bit) or gorc32 for 64-bit resource files.

It is mostly included for testing purposes. When it becomes default the compiler will directly call it.

p.s. brccc32 was never a recommended or supported tool for FPC/Lazarus.

Thaddy:
Marco is right, with the provision that if you change the resource you *must* rebuild your project, otherwise the compiler/linker will use the old resource. The feature Marco described is Delphi compatible, btw.

Kepsz:

--- Quote from: marcov on February 16, 2024, 01:29:32 pm ---Just put it in your .dpr/.lpr like this:


--- 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";}};} ---{$R 'logo.res' 'logo.rc'}
and FPC should auto call the resource compiler.

Note that fpcres is still not the default for third party resource scripts, the current defaults are windres (for 32-bit) or gorc32 for 64-bit resource files.

It is mostly included for testing purposes. When it becomes default the compiler will directly call it.

p.s. brccc32 was never a recommended or supported tool for FPC/Lazarus.

--- End quote ---


Thank you (all) for the suggestions.
On Windows10 x64, I tried this:

{$R resfile.rc} in the .lpr file.
It works, but it tries to use windres instead of gorc, and windres will nor work on 64 bit. I did not installed gorc manualy, but I would like to have some non-OS dependent solution.

So I tried to use fpcres by adding this to fpc.cfg (from https://wiki.lazarus.freepascal.org/Lazarus_Resources):

# Use fpcres as resource compiler
-FF

But the fpc 3.3.2 does not understand the -FF switch.

Navigation

[0] Message Index

[#] Next page

Go to full version