Recent

Author Topic: Execution stopped - but why?  (Read 3832 times)

stephanos

  • New Member
  • *
  • Posts: 28
Execution stopped - but why?
« on: December 18, 2021, 01:38:54 pm »
Greetings All

I have installed and use Lazarus 2.0.12 on a Windows 10 PC.  No issues.  I have written graphical programmes and command line programmes.

Recently, I installed the same version of Lazarus on a laptop that has Windows 10.  I copied over the project folders.

But most command line programmes do not work now.  All graphical programmes do not work.

Both types fail in the same way:  They compile (Ctrl + F9).  But after pressing Run (F9) the next event is the pop up message:  "Execution Stopped".  No other helpful messages.

I went looking at some of the settings, not that I understand much about these things, but I like trying.  The laptop had this setting:
  Tools > Options > Files > FPC source directory was: "$(LazarusDir)fpc$(FPCVer)source"
The PC had this setting:
  Tools > Options > Files > FPC source directory was: "C:\lazarus\fpc\3.2.0\source"

I made the laptop the same as the PC.  I also checked both machines and the path/folder was present.  But it did not fix the problem.

There is one other difference.  It is with the Tools > Options > Files > Compiler Executable:
      PC = "fpc.exe"
Laptop = "C:\Lazarus\fpc\3.2.0\bin\x86_64-win64\fpc.exe"
I have checked and the Compiler Executable path/folder/file is present on both machines

But that is it.  I am at the edge of my knowledge

Any help appreciated

Bart

  • Hero Member
  • *****
  • Posts: 4759
    • Bart en Mariska's Webstek
Re: Execution stopped - but why?
« Reply #1 on: December 18, 2021, 02:40:06 pm »
Is your laptop a 64-bit Windows?

Bart

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8260
  • Debugger - SynEdit - and more
    • wiki
Re: Execution stopped - but why?
« Reply #2 on: December 18, 2021, 02:42:30 pm »
First of all: Do they work outside the debugger?
- menu Run > run without debugger.
- or compile, then find the exe, and run outside the IDE.

Also, do they run if compiled with optimization off? (level 0 / -O- )


The difference in files, might be if your desktop was an upgrade from an older version of Lazarus.

The "sources" seem to have resolved to the same real path, since replacing them worked.

About the compiler exe. Here the question is, if you have another fpc somewhere on your desktop
Menu: View > Ide Internals > About FPC
  There will be (somewhere in the middle)
     FPC executable:
     Compiler=C:\lazarus\fpc\3.2.0\bin\x86_64-win64\fpc.exe
or similar.


stephanos

  • New Member
  • *
  • Posts: 28
Re: Execution stopped - but why?
« Reply #3 on: December 18, 2021, 03:58:43 pm »
Dear All

Thanks for the feedback

Both machines are 64 bit

The PC has freepascal on it
  C:\FPC\3.2.2\bin\i386-win32\fpc.exe
the laptop does not

Run without debugging does nothing.  No message of any type are output.

Both were fresh install of Windows 10

I tried to make an executable. Clicked  Run > Build (Shift + F9).  I closed Lazarus and browsed to the executable.  I double clicked it, however, the pop up message was:
   "The application was able to start correctly
    (0x00000007b) Click OK to close the application"

I have no idea what:
  "Also, do they run if compiled with optimization off? (level 0 / -O- )"
means.

Any further help appreciated

wp

  • Hero Member
  • *****
  • Posts: 10063
Re: Execution stopped - but why?
« Reply #4 on: December 18, 2021, 04:28:39 pm »
What about your virus scanner? Virus scanners are evil today in particular when they call themselves "intelligent". I had a similar case with BitDefender which after an update to an "intelligent" feature deleted my entire FPC tool chain. In the end I unstalled BitDefender in spite of my running valid license, and am using the Defender which comes with Windows 10/11. So far, it has been less aggressive, and I never had such issues as with BitDefender. But even with Defender, it is highly recommended to put Lazarus, FPC and project directories on the whitelist of the scanner.

Bart

  • Hero Member
  • *****
  • Posts: 4759
    • Bart en Mariska's Webstek
Re: Execution stopped - but why?
« Reply #5 on: December 18, 2021, 04:46:30 pm »
Back to basics then.
Create a simple HelloWord application.
Create the file hello.pas.
Code: Pascal  [Select][+][-]
  1. begin
  2.   writeln('Hello World');
  3. end.

Compile it from the commandline:
Code: [Select]
fpc hello.pas
If that goes OK then and there exists a hello.exe file:
Code: [Select]
hello
If it does not output "Hello World" and you get no relevant output/error, try running it in the debugger:
Code: [Select]
gdb hello.exe
run

Bart

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8260
  • Debugger - SynEdit - and more
    • wiki
Re: Execution stopped - but why?
« Reply #6 on: December 18, 2021, 04:50:12 pm »
I tried to make an executable. Clicked  Run > Build (Shift + F9).  I closed Lazarus and browsed to the executable.  I double clicked it, however, the pop up message was:
   "The application was able to start correctly
    (0x00000007b) Click OK to close the application"

Well and that is easy to translate, Microsoft provides a list of error codes.
https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
Quote
ERROR_INVALID_NAME

    123 (0x7B)

    The filename, directory name, or volume label syntax is incorrect.

So some file that your exe requires is not there. Or a folder.
This could be a dll.

Also it seems your PC had a 32 bit FPC.
Your laptop has a 64 bit fpc.

So if you relay on a dll, and that dll is 32bit... Well that could be it.

stephanos

  • New Member
  • *
  • Posts: 28
Re: Execution stopped - but why?
« Reply #7 on: December 18, 2021, 10:46:50 pm »
Dear All

Problem solved.  The clues were in the feedback.  Thanks

1)  I wrote a simple GUI on the laptop and was able to run it and make an exe and run it.  So new programmes on the laptop do work.

2)  My PC has 32bit FPC installed.  For reasons I do not understand it is this fpc.exe that is being referred to in Tools Options > Environment > Compiler Executable: "fpc.exe".  I took a gamble and renamed:
   C:\FPC\3.2.2\bin\i386-win32
to:
   C:\OldFPC\3.2.2\bin\i386-win32
and ran the programme again.  It gave me the error.

3)  Next I downloaded and installed Free Pascal Compiler (Free 32/64/16-bit multi-platform Pascal and Object Pascal compiler) onto the laptop.  There was no separate 64 bit version.  I made the path of the Compiler Executable:
   C:\FPC\3.2.2\bin\i386-win32\fpc.exe
 
Everything now works OK, all the existing programmes work

Now I do not fully understand the implications of this.  Have I written a 32 or 64 bit application?

If I want to continue developing my programme as a 64 bit application, do I have to rewrite it?

Thanks to everyone, wait to hear


Bart

  • Hero Member
  • *****
  • Posts: 4759
    • Bart en Mariska's Webstek
Re: Execution stopped - but why?
« Reply #8 on: December 18, 2021, 11:13:58 pm »
In Lazarus you can select for which target to compile in Compiler Options.
Just select Win64 and X86_64.
Then compile.

As long as you have the win32 to win64 crosscompile installed (Iand I guess you have), it will build for 64-bit.
You can do the same on the commandline:
Code: [Select]
fpc -Px86_64 hello.pas
Bart

 

TinyPortal © 2005-2018