Recent

Author Topic: no output using instantfpc  (Read 4353 times)

segfault

  • Full Member
  • ***
  • Posts: 107
no output using instantfpc
« on: June 25, 2017, 04:26:43 pm »
I'm using FP 3.02 on a Linux 32 bit distro and I'm not getting any output when using instantfpc.

Code: Pascal  [Select][+][-]
  1. begin
  2.   writeln('hello, world');
  3. end.

When I do "instantfpc hello.pas" after making the file executable, I get no errors but there is no output on the command line, although there is a line feed and carriage return before the prompt comes back (not sure if that's significant).

Any suggestions? Thanks.


Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: no output using instantfpc
« Reply #1 on: June 25, 2017, 04:44:54 pm »
I'm using FP 3.02 on a Linux 32 bit distro and I'm not getting any output when using instantfpc.

Code: Pascal  [Select][+][-]
  1. begin
  2.   writeln('hello, world');
  3. end.

When I do "instantfpc hello.pas" after making the file executable, I get no errors but there is no output on the command line, although there is a line feed and carriage return before the prompt comes back (not sure if that's significant).

Any suggestions? Thanks.
Yes. InstantFpc on Windows will need
Code: Pascal  [Select][+][-]
  1. {$apptype console}
That's because instantfpc actually compiles the code: it is not an interpreter, but more like a JIT thingy that calls fpc.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

segfault

  • Full Member
  • ***
  • Posts: 107
Re: no output using instantfpc
« Reply #2 on: June 25, 2017, 04:55:49 pm »
Hi Thaddy,

A bit confused because you say "on Windows", but I'm using Linux. Anyway it makes no difference when I insert {$apptype console}. I'm still not getting any output.

BTW, don't know if it makes any difference but I'm not using Lazarus, just a plain text editor.
« Last Edit: June 25, 2017, 04:59:36 pm by segfault »

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: no output using instantfpc
« Reply #3 on: June 25, 2017, 05:22:47 pm »
Yup I overlooked the Linux part in your question. But on windows this is necessary.
I will test a linux box later.
[edit]
I just did on linux-armhf debian: works perfectly.
Maybe  there's something else wrong, like that instanfpc can't find fpc or ppci386?
« Last Edit: June 25, 2017, 05:31:57 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: no output using instantfpc
« Reply #4 on: June 25, 2017, 05:30:24 pm »
You need a "shebang" as the first line.
Try this for your hello.pas
Code: Pascal  [Select][+][-]
  1. #!/usr/bin/env instantfpc
  2. begin
  3.   WriteLn('Hello world');
  4. end.

« Last Edit: June 25, 2017, 05:33:38 pm by howardpc »

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: no output using instantfpc
« Reply #5 on: June 25, 2017, 05:34:13 pm »
Are you sure Howard? Because I did not use this and it works w/o the shebang. I am using trunk and instantfpc is installed in /usr/local/bin
I thought this was only necessary with a frugal install in some obscure directory where the OS can not find it.
Ah, I see:
- If you run the pas source directly like so: instantfpc helloworld.pas it runs immediately.
- If you want to run the output as a script you need the shebang.
« Last Edit: June 25, 2017, 05:39:55 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: no output using instantfpc
« Reply #6 on: June 25, 2017, 05:40:04 pm »
Yes you're right - it works with and without the shebang if instantfpc is installed correctly.

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: no output using instantfpc
« Reply #7 on: June 25, 2017, 05:47:48 pm »
Yes you're right - it works with and without the shebang if instantfpc is installed correctly.
Yes. I just added the shebang like you did, chmod +x helloworld.pas and ./helloworld.pas executed as intended.
For execution as script it needs the shebang, otherwise not.
« Last Edit: June 25, 2017, 05:50:09 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

segfault

  • Full Member
  • ***
  • Posts: 107
Re: no output using instantfpc
« Reply #8 on: June 25, 2017, 07:10:59 pm »
instantfpc is in /usr/local/bin, as is fpc and a symlink to ppc386 (which is in /usr/local/lib/fpc/3.0.2/) so there shouldn't be any issues of instantfpc finding them?

I tried using the shebang and got the same result (no output).

The strange thing is I have fpc installed on my netbook too, and instantfpc works fine there. It's the same OS and was installed using the standard fpc install script (same as on my desktop), but there must be some difference in the setup because why does it work in one but not the other?

I notice on the wiki that it says:

Quote
Changes to the compiler or installed units are not checked. If you install a new compiler you should clean the cache (e.g. delete the directory ~/.cache/instantfpc).

And since I have recently upgraded from 3.0 to 3.02 maybe that has something to do with the problem? I'll try deleting the cache.

segfault

  • Full Member
  • ***
  • Posts: 107
Re: no output using instantfpc
« Reply #9 on: June 25, 2017, 07:34:33 pm »
Ok I checked the ~/.cache/instantfpc folder and there is no binary there, only the source file, so it seems that instantfpc isn't finding the compiler, but why not?

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: no output using instantfpc
« Reply #10 on: June 25, 2017, 07:56:48 pm »
Because that's the place that instantfpc stores the compiled "scripts".  instantfpc itself should be elsewhere. preferably in (or symlinked ) /usr/bin or /usr/local/bin
It is just temporary storage and gets emptied on system shutdown or clean up.
« Last Edit: June 25, 2017, 08:13:14 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

segfault

  • Full Member
  • ***
  • Posts: 107
Re: no output using instantfpc
« Reply #11 on: June 25, 2017, 08:19:47 pm »
But on my system instantfpc IS in /usr/local/bin.

Maybe I wasn't clear. On my netbook, where instantfpc works fine, there is a binary + source file in .cache/instantfpc, but on my desktop, where instantfpc doesn't work, there is only the source file.

And I still haven't solved the problem.  :(

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: no output using instantfpc
« Reply #12 on: June 25, 2017, 10:24:11 pm »
Then there must be something different between your netbook and your pc.
I can't reproduce it on: Windows 10, Debian64 Intel, Raspbian (arm-eabihf)....  FPC is ok, instantfpc is ok on all systems.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018