Recent

Author Topic: Lazarus absolutely not working under Windows 10  (Read 11402 times)

steveinalabama

  • New Member
  • *
  • Posts: 40
Lazarus absolutely not working under Windows 10
« on: August 10, 2021, 10:22:57 pm »
I am having great difficulty with running Lazarus programs that worked yesterday,
and now I am unable to run them at all except the most recently written one.

I have created several programs in the last few days, each time doing a save all,
and changing the name of the project file and the pascal file to something more
meaningful than project1 or unit1.

Then I want to look at the code of one of the programs written yesterday.
Initially, I loaded the project file but when I ran it, the form was from the previously opened for and pas file,
nothing to do with the project file I just loaded.

I closed all files, and tried reloading the project file, and tried it with the ".LPR", ".LPI", and ".LPS" files.
Which one should I be opening?
I then opened the .pas file that I know was part of the project, and it still runs a different program.
I then went to the project menu and select "add file in editor to the project" and in one cariation, the
program will  not even compile because units referenced in the "uses" statement cannot find the file.

I am familiar with setting the search path in Delphi, but in Lazarus, it has not been necessary when
I start a new application. I had assumed the project file(s) knew where all the "used" pieces were.

Could someone clarify this to me?
If I want to run a program from a few days ago, which do I open first? The .pas file, or one of the
3 project files? If so, which one?  And how do I get the program to know where it used units are?

This is under Windows 10

Thank you.
- Steve

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: Lazarus absolutely not working under Windows 10
« Reply #1 on: August 10, 2021, 10:35:41 pm »
Could someone clarify this to me?
If I want to run a program from a few days ago, which do I open first? The .pas file, or one of the
3 project files? If so, which one?  And how do I get the program to know where it used units are?

The .LPI, which is he one that has the references to the rest of files along with project options, etc. The paths in it should be relative to the project's folder so if you make sure you've got all the files into the new directory there should be no problem.

That is, unless there are references to files in other locations like, say, a common "utils" unit in some unrelated folder (something like "../library" or something like that, but even then it should have no problem finding it.
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.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12718
  • FPC developer.
Re: Lazarus absolutely not working under Windows 10
« Reply #2 on: August 10, 2021, 10:39:28 pm »
And open the .lpi files via the "project->open project" menu

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Lazarus absolutely not working under Windows 10
« Reply #3 on: August 11, 2021, 12:17:22 am »
And use Project --- "Open Recent Project" menu command

It, by default, saves the last 5 recent projects.

steveinalabama

  • New Member
  • *
  • Posts: 40
Re: Lazarus absolutely not working under Windows 10
« Reply #4 on: August 11, 2021, 02:21:27 am »
Yes I do have 3 different projects and their pas files in the same folder. Nothing got overwritten because the filenames are different.

I went and created a new project and added 2 programs to it, the .as file of my previously working program, and the pas file for the "sub-program" that is used by prev working program. It compile but I get access violations. I went in the "sub-program" and kept commenting things out. There is a variable defined in the public area, and the form onactivate populates the variable. In made to subprogram form auto activate. There is nothing else I can comment out. I have a program that does nothing except populate a variable defined under the Form's Public area. Access Violations, from what?

Assuming I am ready to write at least 2 programs all over, the steps I would take are:
create a new application. add a button to the blank form that comes up and do nothing but set a caption on a tlabel.

I would save everything with names beginning with something unique to my pc, like Mythirdtest as the project name and pascal file name.

I would get completely out of Lazarus, create another new application. make it simple as the previous one, and add a variable of type integer under Public in the form definition. I would save the program and project in a different folder.

Then I would exit and restart Lazarus, open the first project, and presumable F9 will compile and run the program without me even opening the pas file.
I would then open the pas file, and subprogram to its uses clause. I would open the subprogram, use the project menu to
 " add file in editor to project", and change the first program to show message the variable of the global integer in the sub program.

Can anyone spot something I am missing?

If it all works as expected, I would start adding in the code from the 2 programs I am re-writing.
Thanks all, for your input

steveinalabama

  • New Member
  • *
  • Posts: 40
Re: Lazarus absolutely not working under Windows 10
« Reply #5 on: August 11, 2021, 03:26:21 am »
Still having problems.

I created 2 new programs, and coould open up either lpi file and run it, as expected. Then I started with the project that runs the "top" program and add the subprogram to the uses statement. I had to open the subprogram so I could add the file in the editor to the project. I kept getting duplicate resource errors. I renamed the form1  as "form1sub" and its caption tells you it is the sub program. I got it to compile, but when I run it (with code in the top program to set a variable to subunit.form1sub.varname, the subprogram is the one that runs. This is after I added it to the project, did a save all, close all, and got out of Lazarus. I came back in, with nothing showing, and did open recent and selected the pas file of the "top" program. When I hit F9, the subprogram runs. The Top program form never appears. I suspect I overlooked 1 step, but what?

steveinalabama

  • New Member
  • *
  • Posts: 40
Re: Lazarus absolutely not working under Windows 10
« Reply #6 on: August 11, 2021, 04:32:32 am »
The missing step was for me to remove the sub program from the project, and it did not have any problems knowing where to find the sub program.

But the access violations came back. The fix was to take the code out of "on activate", even though I removed it from the project.
I also added the subprogram back to the project, and told it not to activate the sub form when the program runs. Which program I wondered when it asked. I assume ti was the calling program.

I was getting SIGSECV errors when it tried to invoke the sub program, but what works for me is to run without debugging.


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12718
  • FPC developer.
Re: Lazarus absolutely not working under Windows 10
« Reply #7 on: August 11, 2021, 08:33:58 am »
Sounds like you reference that form (with onactiviate) unit in the uses clause of one of the units that are still used.

steveinalabama

  • New Member
  • *
  • Posts: 40
Re: Lazarus absolutely not working under Windows 10
« Reply #8 on: August 14, 2021, 04:40:45 am »
I am having the problems all over again.

I found a .pas file I wanted to run. I loaded it into Lazarus, went to the project menu and clicked on units.
The unit for the program I want to run, and also the...lpr file, with a different name from the .pas file.
I loaded the file named that same as the ...lpr file, but I loaded the "LPI" file. I pressed F(
and the this error message: "syntax error BEGIN expected but end of file found".

I got out of Lazarus after doing a close all. Can back in, and read the ...LPI file first, then reopened the .PAS file
and got the exact same error. Out of desperation, I started again, first loading the .pas file, thenI loaded in the .LPS
project file and it worked.

Several hours later, I started Lazarus again, and am unable to run the program. I tried every combinations of loading the pas file,  then loading either the .LPI, .LPS, and the .LPR file, then loaded the .pas file after each load of one of the project files.
I get the same error "...Begin expected..."

I tried the same 3 project files in 3 more tries, but I loaded the .Pas file first. Still get the same error message.
What is most confusing to me is that in 2 earlier attempts, the program ran, once starting with the LPI file, and once starting with the LPS file. Not none of the combinations work. Can anyone shed some light on this?


trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2032
  • Former Delphi 1-7, 10.2 user
Re: Lazarus absolutely not working under Windows 10
« Reply #9 on: August 14, 2021, 05:05:59 am »
You are supposed to open the project file, not the unit file nor the other files.

Project > Open Project - this will load your project and then you can compile/run it.

egsuh

  • Hero Member
  • *****
  • Posts: 1760
Re: Lazarus absolutely not working under Windows 10
« Reply #10 on: August 14, 2021, 05:54:13 am »
I had similar problems --- not clear whether your case is the same or not, but hope this could be of help to you.

In my case, I saved units under new folder (with same name in the old folder).  But if search path has the older folder, old file is used even though I delete it from project. It's :

        ..\V1\u1.pas
        ..\V2\u1.pas

If u1 is included in the use clause, which one is used depends on the search path order.

Sometimes I change the file name (i.e. unit name), but it is possible that old names remain in uses clause.

I think these are not your case because you said you have renamed all files differently but I think you may look into paths and file names in the uses carefully.

Checking View > unit dependency may be one approach.
« Last Edit: August 14, 2021, 05:57:37 am by egsuh »

MarkMLl

  • Hero Member
  • *****
  • Posts: 8551
Re: Lazarus absolutely not working under Windows 10
« Reply #11 on: August 14, 2021, 09:39:40 am »
I have created several programs in the last few days, each time doing a save all,
and changing the name of the project file and the pascal file to something more
meaningful than project1 or unit1.

Are you saying that you are using the IDE to save the project, then manually changing the names on disc?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

steveinalabama

  • New Member
  • *
  • Posts: 40
Re: Lazarus absolutely not working under Windows 10
« Reply #12 on: August 14, 2021, 10:41:21 pm »
I have not renamed anything in Windows Explorer. I have done as "save project as" after the problems started, but that did not help.

A new error message: I started in Lazarus with nothing open, and did a "New application". Then I loaded in a periously working .pas file, then did a "add file in editor" from the Project menu.
It asked me if I wanted the form to be auto-created and I said "yes". I press F9 and it compiles successfully, but as it tries to run gives me  error: "invalid value for property". It does not tell me the value. It does not tell me which component or which property.

And remember, this unit had previously worked and has not been changed since then.
It seems so obvious to me that something in my environment is hosed, but I already tried uninstalling and reinstalling Lazarus.

About 4 weeks ago I formatted my hard drive and reinstalled Windows 10. An I run daily virus scans with Defender








steveinalabama

  • New Member
  • *
  • Posts: 40
Re: Lazarus absolutely not working under Windows 10
« Reply #13 on: August 15, 2021, 06:03:10 pm »

I have boiled this problem down to its simplest code: create a program, create a second program,
 and try to revise the first program.

I created a new application, with nothing but a button and a label on the form
and all it does is set label1.caption := 'jnk project 1'; I changed the form's caption to
'junk1 form' to allow immediate identification.

It runs, as expected. I did a save all and saved the project as "jnk1project" and
the pascal file as "junk1u1.pas

I did a close all, got out of Lazarus, and started Lazarus again, and repeated above steps
calling the new program 'junproject2' and junk2u1.pas. It runs as expected.

I got out of Lazarus after doing a close all, then came back in. I want to make revisions to junk1.

I did an open recent for junk project 1 and clicked F9 and what ran was junk#2. It seems like it is running the last project,
 so I exited Lazarus, started it again, and loaded in the previous project name, ending in .lpi.
When I ran it, nothing happened....no form shows, but it said "debugging" on the toolbar.
I tried again loading the .lps file, and also the lpr file. I have tried opening the pas file first,
then the project as well as opening the project first, then .pas file.
There was no load recent for the project files, and they exist in 2 different folders: "...\backup"
and "...[backup\backup" I have tried both. I have gotton several different error messages deppending on the
selected project names, one saying it could not fnd the exe file, one saying unexpected end of file, but the error
messages do not say which file.

Could somebody please replicate this and specify which steps you take after the second project is created, saved, and run,
to open the first project and make a simple revision, and run it.
In what order do you open the .pas file and the project file?
And which project file, the .lpi, the ,lpr, or the .lps?

I already have created a post with much more details,but I am entering this as a new topic thinking that so much
details over several days will be ignored.

Thank you.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Lazarus absolutely not working under Windows 10
« Reply #14 on: August 15, 2021, 06:31:11 pm »
When working with projects (as Lazarus does) best practice is to create a new folder for each project, and save the project as soon as it is created.
If you don't explicitly save the project it may be saved to a temporary folder, and the next time you run Lazarus it will by default use a temporary folder for a new project, which may have leftovers from previous use. If you don't save the new project in its own folder you can end up with strange effects.
Always open projects using the .lpi file, not .pas, .pp or .lpr files. That way you let the Lazarus IDE manage the project. It really does integrate everything about the project behind the scenes, and working with individual files outside the IDE ignores that integration and quickly leads to grief unless you are really sure of what you are doing.

 

TinyPortal © 2005-2018