Recent

Author Topic: [SOLVED] Running program shows Error  (Read 3025 times)

heejit

  • Full Member
  • ***
  • Posts: 249
[SOLVED] Running program shows Error
« on: October 26, 2018, 11:07:28 am »
I am cross compiling application from Linux to win32, win64

In win32 and win64 on writeln function program shows File Not open Error

In compiler option I selected win32 application there is no console running
« Last Edit: October 26, 2018, 12:05:24 pm by jshah »

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: Running program shows Error
« Reply #1 on: October 26, 2018, 11:15:59 am »
Did you remember to add {$APPTYPE CONSOLE} to your program?

Reason: The standard Read(Ln), Write(Ln), etc. are not readily available for GUI apps.
« Last Edit: October 26, 2018, 11:19:46 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Handoko

  • Hero Member
  • *****
  • Posts: 5537
  • My goal: build my own game engine using Lazarus
Re: Running program shows Error
« Reply #2 on: October 26, 2018, 11:19:41 am »
I have no problem cross compiling from Linux 64-bit to Win32 and running the binary even without using {$APPTYPE CONSOLE}. Please provide more info and it's better if you also provide the source code.

-edit-
I forgot a "no"
« Last Edit: October 26, 2018, 11:51:19 am by Handoko »

heejit

  • Full Member
  • ***
  • Posts: 249
Re: Running program shows Error
« Reply #3 on: October 26, 2018, 11:31:49 am »
@lucamar : {$APPTYPE CONSOLE}   not added.

@Handoko : Is not possible to provide full source code

Let me try with lazlogger and see the result


heejit

  • Full Member
  • ***
  • Posts: 249
Re: Running program shows Error
« Reply #4 on: October 26, 2018, 11:33:27 am »
@Handoko

On click of tstringgrid I am printing the selected row's custom data to the console

Handoko

  • Hero Member
  • *****
  • Posts: 5537
  • My goal: build my own game engine using Lazarus
Re: Running program shows Error
« Reply #5 on: October 26, 2018, 11:49:36 am »
Eh, you combine TStringGrid with Writeln? TStringGrid is a visual component for GUI but Writeln is a function for used in console applications. I've never done it, I will need to inspect it later.

heejit

  • Full Member
  • ***
  • Posts: 249
Re: Running program shows Error
« Reply #6 on: October 26, 2018, 12:05:11 pm »
with lazlogger no error in win32 and win64

Thaddy

  • Hero Member
  • *****
  • Posts: 19158
  • Glad to be alive.
Re: [SOLVED] Running program shows Error
« Reply #7 on: October 26, 2018, 12:20:47 pm »
You already got the answer: IF you want to use writeln in a GUI application then you need {$apptype console} but only on Windows. Under linux, it works if your program starts from a console (e.g.: startlazarus). There are ways around it, but that should work for now. Examine the code of lazlogger too.
objects are fine constructs. You can even initialize them with constructors.

 

TinyPortal © 2005-2018