Recent

Author Topic: [SOLVED] InstantFPC usage under Windows  (Read 7060 times)

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
[SOLVED] InstantFPC usage under Windows
« on: August 23, 2014, 07:28:05 am »
Hello!

I try to use InstantFPC under Windows (8.1). The documentation says that "this tool allows to run pascal program as scripts under Linux, BSD, OS X and Windows". But the method described is only for Linux:

Code: [Select]
[]$ chmod a+x hello.pas
[]$ ./hello.pas

Is it really possible tu run Pascal programs as scripts under Windows, and how?
« Last Edit: August 24, 2014, 05:05:39 pm by Roland Chastain »
My projects are on Gitlab and on Codeberg.

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
Re: InstantFPC usage under Windows
« Reply #1 on: August 23, 2014, 09:12:58 am »
I tried also to execute a sample (envvars.pas) from Lazarus ("execute as an InstantFPC program"). I got an error message: "program Instant FPC not found". I compiled InstantFPC and pasted the executable 1° to FPC\bin directory 2° to the source code directory: I still get the same error message.
 
My projects are on Gitlab and on Codeberg.

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: InstantFPC usage under Windows
« Reply #2 on: August 23, 2014, 02:51:12 pm »
As instanfpc.exe is now by default in the fpc binary directory, and as you need fpc too for the compilation, you should add the the fpc binary directory to your path, before calling instantfpc.

Add also a path for the cache directory using the INSTANTFPCCACHE environment variable.

For instance, a setup file sample (adapt it to your own needs).

File: ifpcs.bat
Code: [Select]
set path=%path%;c:\lazarus\fpc\2.6.4\bin\i386-win32
set INSTANTFPCCACHE=.\cache

After having run this setup file in a cmd box, you can now compile (and theoretically run) your program in this cmd box:
Code: [Select]
instantfpc mypgm.pas

Anyway, the executable is created, but there is an error when it's copied into the cache directory:
Quote
unable to move "[mycache]\__tmpxxxx\mypgm" to "[mycache]\mypgm"

However, you can still get it from the __tmpxxxx subdirectory, as it's not deleted.

Sorry, I've not been able to solve this error during my quick tests...
« Last Edit: August 23, 2014, 03:08:22 pm by ChrisF »

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
Re: InstantFPC usage under Windows
« Reply #3 on: August 23, 2014, 05:32:26 pm »
@ChrisF

Thank you for your answer and the detailed description.

I tried the commands that you suggested and it did exactly what you said. The problem is half solved.  :)
My projects are on Gitlab and on Codeberg.

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: InstantFPC usage under Windows
« Reply #4 on: August 23, 2014, 06:44:08 pm »
This error is consecutive to the new version of InstantFPC:

Code: [Select]
const
  Version = '1.3';
  // 1.3 compile in a separate directory, so that parallel invocations do not overwrite link.res files


And there are several errors with this new version:

-the '.exe' extension for Windows executable files is not added when moving the output file from this new separate directory to the cache directory (if InstantFPC is running in Windows, of course):
Code: [Select]
      // move from build directory to cache
      if not RenameFile(BuildOutputFilename,OutputFilename) then begin
        writeln('unable to move "',BuildOutputFilename,'" to "',OutputFilename,'"');

-anyhow, this moving is using a rename operation (quicker than a copy), but the former file (if already present in the cache) is not deleted first. Which gives another error during this operation, after the first call,

-and finally the deletion of the whole separate directory (i.e. __tmpxxxx ) is not OK because Windows is returning an ERROR_SHARING_VIOLATION (probably related to the FPC compiler operation, I guess):
Code: [Select]
  if not RemoveDir(Directory) then begin
    writeln('unable to delete directory "'+Directory+'"');


That makes a lot of bugs, and I've still not succeeded to fix the last one (i.e. directory deletion).

You should use the version coming with the 2.6.2 version of FPC instead (i.e. InstantFPC version 1.2). This one is working properly. I've got positive tests with it:
- take the source code of FPC 2.6.2,
- extract the InstantFPC source (found in 'utils'),
- and recompile it: fpc InstantFPC

Note: don't forget to replace the current InstantFPC.exe file present in your FPC binary directory with this one (i.e. version 1.2), if you plan to use it instead.
« Last Edit: August 23, 2014, 07:01:11 pm by ChrisF »

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
Re: InstantFPC usage under Windows
« Reply #5 on: August 23, 2014, 11:16:41 pm »
Thank for your work.

I compiled InstantFPC from 2.6.2.source. Now it works without error. Great!
My projects are on Gitlab and on Codeberg.

 

TinyPortal © 2005-2018