Recent

Author Topic: CRT not found when trying to compile for wince  (Read 5467 times)

helpwithfpc

  • Newbie
  • Posts: 5
CRT not found when trying to compile for wince
« on: May 30, 2016, 09:45:34 pm »
If I use fpc on windows 7, with the 'uses crt;' option, the program will compile and I can successfully write to the screen (opens DOS window and writes the text from the writeln statement in the program.

When I use lazarus on windows 7 and compile the program for wince, 'arm' cpu and 'arm4' processor, I get the following message;

testit.pas(3,29)Fatal: Cannot find crt used by testit of the Project Inspector.

I have looked everywhere and as near as I can tell, the crt unit does not work for wince to write to the screen. is there any other option available to write to the screen on wince?

I'm new to free pascal and even newer to lazarus - any help would be appreciated.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: CRT not found when trying to compile for wince
« Reply #1 on: May 31, 2016, 09:17:22 am »
Ask yourself first: do you really need crt unit? writing to stdout does not require any unit other than system unit.

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: CRT not found when trying to compile for wince
« Reply #2 on: May 31, 2016, 11:09:27 am »
Ask yourself first: do you really need crt unit? writing to stdout does not require any unit other than system unit.

Yup, but note that under windows you have to define {$APPTYPE CONSOLE} for writeln/readln to work.
Otherwise you run into an error 105..
Code: Pascal  [Select][+][-]
  1. program testconsole;
  2. {$APPTYPE CONSOLE}
  3. begin
  4.   writeln('console output');
  5.   readln;
  6. end.
  7.  
« Last Edit: May 31, 2016, 11:11:58 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: CRT not found when trying to compile for wince
« Reply #3 on: May 31, 2016, 11:52:19 am »
Yup, but note that under windows you have to define {$APPTYPE CONSOLE} for writeln/readln to work.
Otherwise you run into an error 105..
I think the OP uses pure FPC without Lazarus, which has no -WG set by default. Hence {$APPTYPE CONSOLE} is already the default.

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: CRT not found when trying to compile for wince
« Reply #4 on: May 31, 2016, 01:49:03 pm »
@Leledumbo: Nope. You have to specify it explicitly. Maybe Lazarus defines it for a console app, but normally for Windows and just FPC you actually need to specify {$APPTYPE CONSOLE} otherwise the stdin/out won't get linked in and you'll end up with runerror 105.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: CRT not found when trying to compile for wince
« Reply #5 on: May 31, 2016, 03:33:35 pm »
@Leledumbo: Nope. You have to specify it explicitly. Maybe Lazarus defines it for a console app, but normally for Windows and just FPC you actually need to specify {$APPTYPE CONSOLE} otherwise the stdin/out won't get linked in and you'll end up with runerror 105.
http://www.freepascal.org/docs-html/prog/progsu86.html:
Quote
A console application. A terminal will be created and standard input, output and standard error file descriptors will be initialized. In Windows, a terminal window will be created. This is the default.
Lazarus defines apptype gui by default in the compiler options via -WG, you get it reversed. It doesn't make sense for FPC to set apptype gui by default, as FPC is more widely used and often for GUI-less programs, such as in education and headless servers.

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: CRT not found when trying to compile for wince
« Reply #6 on: May 31, 2016, 03:48:51 pm »
http://www.freepascal.org/docs-html/prog/progsu86.html:
Quote
A console application. A terminal will be created and standard input, output and standard error file descriptors will be initialized. In Windows, a terminal window will be created. This is the default.
That's a bug ;) Not Delphi compatible... :) You are right. Have been wasting typing {$APPTYPE CONSOLE} for many years  >:(  Now I have to start typing {$APPTYPE GUI} to produce Delphi compatible error messages.

Just kidding: I use it anyway to debug between Delphi and FPC code, so it is recommended to do it anyway if you share code between Delphi and FPC (Which I do a lot).
« Last Edit: May 31, 2016, 04:27:46 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

helpwithfpc

  • Newbie
  • Posts: 5
Re: CRT not found when trying to compile for wince
« Reply #7 on: May 31, 2016, 05:28:20 pm »
Okay, I tried both your suggestions with the following results(hopefully I understood your replies correctly).

FYI:
laptop is windows 7 home premium edition
free pascal is version 3.0.0
lazarus is version 1.6

netbook is 7" LanYu
OS: windows ce 6.0
cpu: wm 8505 300mhz
display: 7" TFT 800*480
memory: DDR II 128mb

1st version:
using just fpc 3.0.0  on the laptop;
it opens the dos window, flashes text and immediately closes

On the wince netbook, it does nothing. When I click on the program, it just blinks. Can't even tell if
it's opening the dos window or not.

program testit;

begin
{$appdata console}
end.

begin
writeln('this is a test');
writeln('this is another test);
readln;

end.

2nd version
On windows 7 with lazarus 1.6 and fpc 3.0.0
written this way, the dos box opens,writes the text and stays open until i press a key (which is what i want)

When I compile it and run it on the wince netbook, I get the
following error:

'An unhandled exception occurred at $00011428:
EInOutError: File not open
$00011428

program testit;

uses sysutils;

begin
writeln('this is a test');
writeln('this is another test);
readln;

end.

So on the laptop, it works one way, on the netbook(where I really need it), it doesn't work either way.

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: CRT not found when trying to compile for wince
« Reply #8 on: May 31, 2016, 07:51:48 pm »
Code: Pascal  [Select][+][-]
  1. program testit;
  2. (* all this is WRONG!@@ appdata is some windows directory, has nothing to do with FPC
  3. begin
  4. {$appdata console}
  5. end.
  6. *)
  7. {$APPTYPE CONSOLE} // is how it should be. Just that. And as per @Leledumbo not even necessary.
  8. begin
  9. writeln('this is a test');
  10. writeln('this is another test'); // it is also helpful if you close your string properly
  11. readln;
  12.  
  13. end.

Note that especially on WINCE you DO need to include {$APPTYPE CONSOLE} always.
And have a console installed.... which is not always the case.
« Last Edit: May 31, 2016, 07:56:44 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

helpwithfpc

  • Newbie
  • Posts: 5
Re: CRT not found when trying to compile for wince
« Reply #9 on: May 31, 2016, 08:12:43 pm »
THANK YOU!!!

Using sysutils still doesn't work, but I tried it again with $apptype (I totally misread it in the replies given)and it worked with the 'win32 gui application' option either checked or unchecked - opened dos, wrote to screen and waited for reply.  I'm trying to set something up for my grandson and this has been a real experience trying to learn the wince peculiarities, free pascal and the lazarus interface. Thanks again.

I'm having problems trying to do a clear screen and also change background/foreground colors, but i'll open another item for that since you solved my problem on this - thanks

 

TinyPortal © 2005-2018