Recent

Author Topic: IDE/Project Options ihxutil is called with a leading space in the path, so fails  (Read 849 times)

Cascade

  • Jr. Member
  • **
  • Posts: 86
I’m having difficulty compiling a small project using Lazarus Trunk 4.99 and think I have a glitch my IDE or Project Options.

Compiling itself is OK, but then at the linking stage, ihxutil is called, and fails with:

Code: [Select]
Exception at 0000000102147C98: EInOutError:
File not found.

If I run ihxutil manually from Terminal it completes the linking process successfully.  The difference seems to be, Lazarus calls ihxutil with a command line parameter starting:
Code: [Select]
" /Users/…etc… 
whereas I execute ihxutil manually with a command line parameter starting:
Code: [Select]
"/Users/…etc… (notice no leading space character between the starting quote and /Users).

Sounds easy enough to fix, except I’m not sure where the space is coming from.  I can’t spot anything in Lazarus Settings or Project Options (but I may well have missed something).  I’ve run Find in Files on the entire config_lazarus folder for the string:
Code: [Select]
" / but nothing is found.

Could a $(macro) add a space when expanded?
« Last Edit: March 27, 2026, 09:40:32 pm by Cascade »

n7800

  • Hero Member
  • *****
  • Posts: 693
  • Lazarus IDE contributor
    • GitLab profile
On the "Project Options > Compiler Options > Compiler Commands" page, are there any commands listed in the "Execute Before" and "Execute After" fields?

By "compiling from the terminal", do you mean "lazbuild", "fpc", or just running the utility itself?

n7800

  • Hero Member
  • *****
  • Posts: 693
  • Lazarus IDE contributor
    • GitLab profile
I’ve run Find in Files on the entire config_lazarus folder for the string:
Code: [Select]
" / but nothing is found.

Let's clarify: are you having problems compiling a specific project or the IDE itself? If it's a project, you should search the project files (especially the *.lpi file) rather than the IDE options folder "config_lazarus".

Cascade

  • Jr. Member
  • **
  • Posts: 86
Thanks for the suggestion to search in the project files too. All seems good there (search string " / not found in .lpi file etc.).

Execute Before & Execute After fields are empty. 

The Compiler field is a direct path:
Code: [Select]
...3.3.1/fpc/bin/aarch64-darwin/fpc.sh ...because this particular Target requires FPC 3.3.1

I let Lazarus compile first (i.e. Run > Build).  Then when linking fails, I open Terminal and re-run just ihxutil manually.  That completes the process.

It's a specific project - but my other projects don't use this Target CPU/OS, so maybe they don't call ihxutil (?).

Cascade

  • Jr. Member
  • **
  • Posts: 86
As a quick test I created a new clean empty project with the same Target.  The same error occurs at the linking stage.

I think I've found where ihxutil is called by FPC 3.3.1, in the t_zxspectrum.pas file:

Code: Pascal  [Select][+][-]
  1. function TLinkerZXSpectrum.postprocessexecutable(const fn: string; isdll: boolean): boolean;
  2.   begin
  3.     result:=DoExec(FindUtil(utilsprefix+'ihxutil'),' '+fn,true,false);
  4.   end;

There is a space before the parameter (' '+fn) but that's OK so long as the parameter doesn't get "quoted" later.

Cascade

  • Jr. Member
  • **
  • Posts: 86
I moved the entire project to a path containing no spaces.  It compiled and linked successfully.  🙂

Speculation:  I suspect a small bug, where the path parameter being passed to ihxutil is being "quoted" after the parameter has already been prefixed with a space character.  So ' '+fn works fine for an unquoted path:

Code: [Select]
ihxutil   /mypath
...but might result in:

Code: [Select]
ihxutil "▪️/my path"
...if the path contains spaces so needs quoting at a later stage?  I haven't yet followed up this line of thought though.
« Last Edit: March 28, 2026, 12:44:08 pm by Cascade »

n7800

  • Hero Member
  • *****
  • Posts: 693
  • Lazarus IDE contributor
    • GitLab profile
Great find! I think it's worth create a issue on the FPC bug tracker. Don't forget to add a link to this thread there.

 

TinyPortal © 2005-2018