Forum > Windows

[SOLVED] InstantFPC usage under Windows

(1/2) > >>

Roland57:
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: ---[]$ chmod a+x hello.pas
[]$ ./hello.pas
--- End code ---

Is it really possible tu run Pascal programs as scripts under Windows, and how?

Roland57:
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.
 

ChrisF:
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: ---set path=%path%;c:\lazarus\fpc\2.6.4\bin\i386-win32
set INSTANTFPCCACHE=.\cache

--- End code ---

After having run this setup file in a cmd box, you can now compile (and theoretically run) your program in this cmd box:

--- Code: ---instantfpc mypgm.pas

--- End code ---

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"
--- End quote ---

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...

Roland57:
@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.  :)

ChrisF:
This error is consecutive to the new version of InstantFPC:


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

--- End code ---


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: ---      // move from build directory to cache
      if not RenameFile(BuildOutputFilename,OutputFilename) then begin
        writeln('unable to move "',BuildOutputFilename,'" to "',OutputFilename,'"');

--- End code ---

-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: ---  if not RemoveDir(Directory) then begin
    writeln('unable to delete directory "'+Directory+'"');

--- End code ---


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.

Navigation

[0] Message Index

[#] Next page

Go to full version