Recent

Author Topic: [SOLVED] Stuck in Debugging Mode  (Read 12677 times)

bzman24

  • Jr. Member
  • **
  • Posts: 71
[SOLVED] Stuck in Debugging Mode
« on: January 18, 2017, 03:08:40 am »
HELP!!!  I just finished my project and now it is stuck in debugging mode and will not run.  I went in and created a debug and release mode as found on this forum.  Checked the release mode and now it gives me these errors:

Compile Project, Mode: Default, Target: AgeCalcJT.exe: Exit code 1, Errors: 2
AgeCalcJT.lpr(18,1) Error: Can't create object file: AgeCalcJT.exe (error code: 5)
AgeCalcJT.lpr(18,1) Error: Can't create executable AgeCalcJT.exe

it also brings up the *.lpr file.  That is shown below.  Thanks for any and all assistance.

BZMan24 :o :o :o :o

Code: Pascal  [Select][+][-]
  1. program AgeCalcJT;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Interfaces, // this includes the LCL widgetset
  10.   Forms;
  11.  
  12. {$R *.res}
  13.  
  14. begin
  15.   RequireDerivedFormResource := True;
  16.   Application.Initialize;
  17.   Application.Run;
  18. end.                          
  19.  
« Last Edit: January 22, 2017, 10:05:55 pm by bzman24 »
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

bzman24

  • Jr. Member
  • **
  • Posts: 71
Re: Stuck in Debugging Mode
« Reply #1 on: January 18, 2017, 03:50:30 am »
Found that I was missing a line in the *.lpr file.  Now I get the following errors:

Compile Project, Mode: Default, Target: AgeCalcJT.exe: Exit code 1, Errors: 2
AgeCalcJT.lpr(16,26) Error: Identifier not found "TForm1"
AgeCalcJT.lpr(16,34) Error: Identifier not found "Form1"

This makes no sense because I'm looking at the project files and Form1 is referenced everywhere!  Still lost and won't run!  HELP.

Thanks,  BzMan24

Code: Pascal  [Select][+][-]
  1. Application.CreateForm(TForm1, Form1);
  2.  
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

bzman24

  • Jr. Member
  • **
  • Posts: 71
Re: Stuck in Debugging Mode
« Reply #2 on: January 18, 2017, 03:56:47 am »
Found the 'View Project Forms' list is empty.  How to I add an existing form to the project?
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Stuck in Debugging Mode
« Reply #3 on: January 18, 2017, 03:58:29 am »
In your first code block you are missing the form's unit in uses list. This is what empty project source looks like:
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Interfaces, // this includes the LCL widgetset
  10.   Forms, unit1
  11.   { you can add units after this };
  12.  
  13. {$R *.res}
  14.  
  15. begin
  16.   RequireDerivedFormResource:=True;
  17.   Application.Initialize;
  18.   Application.CreateForm(TForm1, Form1);
  19.   Application.Run;
  20. end.

bzman24

  • Jr. Member
  • **
  • Posts: 71
Re: Stuck in Debugging Mode
« Reply #4 on: January 18, 2017, 04:10:55 am »
Thanks, I added the Unit as shown but it still won't run.  Error msg below:

Compile Project, Mode: Default, Target: AgeCalcJT.exe: Exit code 1, Errors: 2
AgeCalcJT.lpr(19,1) Error: Can't create object file: AgeCalcJT.exe (error code: 5)
AgeCalcJT.lpr(19,1) Error: Can't create executable AgeCalcJT.exe
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Stuck in Debugging Mode
« Reply #5 on: January 18, 2017, 09:39:34 am »
How is this related to build modes? Are you saying it works with Release mode but not with Debug mode?

Anyway, create a new application and make sure it runs. Then add things to it and run again. See what you did differently in the first application and where it went wrong.
« Last Edit: January 18, 2017, 09:43:23 am by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

bzman24

  • Jr. Member
  • **
  • Posts: 71
Re: Stuck in Debugging Mode
« Reply #6 on: January 18, 2017, 12:12:10 pm »
I guess you don't understand my situation.  It would only run in debug mode!  After doing the steps I mentioned above and finding more info here on this forum, I found that it builds and compiles with no error messages after I renamed the exe file.  The problem I have now is that it compiles, the screen blinks like it is going to show the application and then it is back into the Lazarus environment again.  The application compiles but won't run.  If I try to run the application outside of the Lazarus environment nothing happens.  The cursor spins for about 5 sec and nothing else.  Really puzzled about this because it was running fine before something happened.  Anybody else have any info on how to fix this? %) %) %) %)

If I go to other projects they all compile and run fine.

Thanks, BZMan24
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: Stuck in Debugging Mode
« Reply #7 on: January 18, 2017, 02:19:08 pm »
Anybody else have any info on how to fix this?

1. Make Clean up  + rebuild
2. If there is build error like "Can't create executable AgeCalcJT.exe" look if the old executable can be deleted (if on Windows, sometimes the old executable is locked, still runs, etc.). If it can't look into process explorer, restart computer etc.
3. If the app builds fine and won't run in Release mode turn off optimization and see!
4. Compare your debug and release modes by viewing the lpi file as text file, I often use this to check the differences.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Stuck in Debugging Mode
« Reply #8 on: January 18, 2017, 04:23:46 pm »
As already expressed by tk, in case the executable can't be created then you already got the application running (be it visible or not). Always make sure the curent invoked instance is removed from your task manager.

the case where your application doesn't run outside the IDE can be caused by the same reason. Other then that if your application does not output anything at all on startup then you should make that happen first. You can accomplish such thing with using simple writeln's to see where exactly your program "gets stuck" (in case of running a application on Windows platform, then make sure you uncheck the option "WIN32 GUI Application" in your project options, otherwise you get errors"

bzman24

  • Jr. Member
  • **
  • Posts: 71
Re: Stuck in Debugging Mode
« Reply #9 on: January 18, 2017, 11:54:47 pm »
tk,  I did what you suggested but nothing found.  Step 1 builds fine.  No errors reported except several line that show a 'xxxxxx is deprecated' message.  Step 2 no difference deleting the old exe file and restarting.  Step 3 Optimization off and nothing different.  Step 4 no differences in a release mode or debug mode .lpi file.  Files were identical.  Maybe I did something wrong?

When I run debug mode I do get the following error:

Debugger Exception Notification
Project AgeCalcJT raised exception class 'Exception' with message:
Failed to create win32 control, error: 1407: Cannot find window class

At address 52A859
=============
Molly, App not still running in task manager.  Turning off 'WIN32 GUI Application' gives me a command window that blinks on then off right away.

Anything else?  Builds and compiles fine, just creates an exe file that doesn't run.   %) %) %)

Thanks, BZMan24
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Stuck in Debugging Mode
« Reply #10 on: January 19, 2017, 12:44:14 am »
Debugger Exception Notification
Project AgeCalcJT raised exception class 'Exception' with message:
Failed to create win32 control, error: 1407: Cannot find window class
ok, complete (minimal) example project required that expresses this failure.

Quote
Molly, App not still running in task manager.  Turning off 'WIN32 GUI Application' gives me a command window that blinks on then off right away.

Anything else?  Builds and compiles fine, just creates an exe file that doesn't run.   %) %) %)
As said. Make some output noise, using writeln in your code. Not doing so let the console output window show and hides itself without showing anything (strange isn't it  :P).

It is like a poor man's debugger for those who can't figure out how to use the debugger. Each line shown on the console means previous executed code-lines executed correctly. This let you analyze your code and make it possible to pinpiont where exactly your code goes wrong (might require quite a bit of writeln's though).

bzman24

  • Jr. Member
  • **
  • Posts: 71
Re: Stuck in Debugging Mode
« Reply #11 on: January 19, 2017, 01:06:32 am »
OK.  Did that put 1 writeln at end of 'TForm1.FormCreate' procedure.  Got the message I put in to display, showed along with the previous error message as noted above.  Hit continue and got a large window full of things I don't understand.  Do I zip up the project so others can try it and see what I have?  Don't get me wrong, I really appreciate your help but I'm not sure where running the debugger is going to help me.  This is what happened originally.  It was running and something happened and the next time I compiled it no running executable and debug mode hell.  I know what is in the output log of the debugger is nice to some but to me is is all Greek.  Sometimes you have to have some pain to get the gain. Thanks again.  BZMan24 :'( :'( :'(

p.s. - where else can I put writelns so it will help.  None of the other procedures come into play if the application won't run??
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Stuck in Debugging Mode
« Reply #12 on: January 19, 2017, 02:18:00 am »
Do I zip up the project so others can try it and see what I have?
in case it is not a project containing hundreds of lines of code and zillions of components put on the form, depend on 3th party installed components (unless the problem is specific to that component) then yes. Use the publish project option to only publish the sources that are required to compile your project and zip up the directory in which you published and attach that to a post.

In case it is a big project, then publish your project locally and put the generated files into another directory, load that project into lazarus and keep stripping things down to a minimum amount of code/components but still showing the error.

Quote
Don't get me wrong, I really appreciate your help but I'm not sure where running the debugger is going to help me.
If you run your application inside the IDE and something goes wrong, then the debugger kicks in automatically. Depending on your project settings something good can come from that (or not). Usually you step through your source code until the debugger catches a (severe) error and lets you know that by popping up a requester (with error description, e.g. division by zero). That way you know which line is responsible for actually generating the error.

In case of a division by zero error, things are pretty conclusive, but your error is a bit different and requires a bit more knowledge. hence why i wrote to attahc the project so that someone more knowledable is able to see if he/she is able to generate the same error.

Quote
p.s. - where else can I put writelns so it will help.  None of the other procedures come into play if the application won't run??
That depends completely on your project. In case you have many methods/events implemented then you can put it everywhere that you like, even implement events to see how far f.e. creation of your main form went, e.g. onformactivate, onformshow etc can be used for that as well.

But, my first hunch would probably be that you created/generated a class that wasn't registered properly. Either that or you have a messed up form with some remnants of experiments that you did.

The problem right now is that you only describe the error to the best of your ability but, nobody is able to help you with that as it is your interpretation of things. No code means nobody is able to reproduce.

bzman24

  • Jr. Member
  • **
  • Posts: 71
Re: Stuck in Debugging Mode
« Reply #13 on: January 19, 2017, 04:16:26 am »
OK.  Small project. Only 150 lines & 5 procedures.  Thanks, BZMan24
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

bzman24

  • Jr. Member
  • **
  • Posts: 71
Re: Stuck in Debugging Mode
« Reply #14 on: January 19, 2017, 04:34:06 am »
Before we go to far here, I just found something that is intriguing.  I copied the project files to a different folder, renamed them, saved them from the Lazarus environment to the new folder and now the project compiles, creates the exe and runs.  Is my project name the issue?? :-\ :-\ :-\  Does the name AgeCalc or AgeCalcJT mean something to Lazarus internally?  Just wondering.
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

 

TinyPortal © 2005-2018