Lazarus absolutely not working under Windows 10 lazarus / 21-General ---------------------------------------------------------------------- steveinalabama · 2021-08-10 20:22 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 · 2021-08-10 20:35 Quote from: steveinalabama on August 10, 2021, 10:22:57 pmCould 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. ---------------------------------------------------------------------- marcov · 2021-08-10 20:39 And open the .lpi files via the "project->open project" menu ---------------------------------------------------------------------- engkin · 2021-08-10 22:17 And use Project --- "Open Recent Project" menu command It, by default, saves the last 5 recent projects. ---------------------------------------------------------------------- steveinalabama · 2021-08-11 00:21 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 · 2021-08-11 01:26 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 · 2021-08-11 02:32 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 · 2021-08-11 06:33 Sounds like you reference that form (with onactiviate) unit in the uses clause of one of the units that are still used. ---------------------------------------------------------------------- steveinalabama · 2021-08-14 02:40 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 · 2021-08-14 03:05 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 · 2021-08-14 03:54 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. ---------------------------------------------------------------------- MarkMLl · 2021-08-14 07:39 Quote from: steveinalabama on August 10, 2021, 10:22:57 pmI 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 ---------------------------------------------------------------------- steveinalabama · 2021-08-14 20:41 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 · 2021-08-15 16:03 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 · 2021-08-15 16:31 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. ---------------------------------------------------------------------- dseligo · 2021-08-15 17:07 What howardpc said is all OK, but I just want to add couple of things. When you want to open some other project, you go to menu Project --> Open Project or Open Recent Project. That way you don't have to worry about extensions. Also, when you opening your project's units and forms, you can use menu Project --> Units (or Forms), or you can use Ctrl + F12 (or Shift + F12 respectively). Your units and forms are already defined in project so you don't have to open them from disk. ---------------------------------------------------------------------- Martin_fr · 2021-08-15 17:28 I am not sure, what is happening... But lets look at details. 1) Make sure each project is stored in its own folder. 2) In menu: Project > Project options => dialog page: Compiler Options > Path ==> Never make any changes. <== ==> Especially "Other Unit Files" must be empty. 3) Save your project via the menu "project". Do this before you save any units. Then the IDE should offer you to save any units into the project folder. About all the files: lpi => your project (an xml file containing info the IDE needs) lps => session info. Like where was your file scrolled to. lpr => pascal code of your project. Maintained by the IDE.     You can look at it via the "project" menu: "view project source" pas or pp => your units lfm => your forms res => created by the IDE. You open a project via the "lpi" file. When you create you 2nd project. Use menu: project => new project   Or Project > close project Do NOT edit the existing project and later "save as". ---------------------------------------------------------------------- engkin · 2021-08-15 18:10 Quote from: steveinalabama on August 15, 2021, 06:03:10 pmI 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, Obviously you used open recent file instead of open recent project. ---------------------------------------------------------------------- MarkMLl · 2021-08-15 18:50 Quote from: Martin_fr on August 15, 2021, 07:28:52 pmAbout all the files: Could I throw in a few extra words here please. > lpi => your project (an xml file containing info the IDE needs) Assume this is "Lazarus Project Information". It is THE file that the IDE needs to work out where everything else is. > lps => session info. Like where was your file scrolled to. Assume this is "Lazarus Project Session", it contains nothing of permanent significance. > lpr => pascal code of your project. Maintained by the IDE. Assume this is "Lazarus Program", it is the main program file which can be edited if you're writing a console mode program but should generally be left to the IDE if you're using forms etc. > pas or pp => your units i.e. they start "unit" not "program" and are ultimately used/imported by the main program. > lfm => your forms Assume this is "Lazarus Form". In general every .lfm will have a matching .pas (but not necessarily the other way round). > res => created by the IDE. Containing icons etc. Leave this to the IDE. MarkMLl ---------------------------------------------------------------------- steveinalabama · 2021-08-15 21:34 Thank you all. I have had success creating 2 programs, and going back and forth revising them. I created brand new folders and put each no program in its own folder. The I used the Project open as described by Dseligo. But I am back to my original problem....trying to run and modify a program that worked a week ago. It already was in its own folder, but not the project files. I was able to find the .lpi file in another folder but it says EXE file not found. I tried Project | new  project from file and it does not work...same error message of EXE file not found. Can anyone help of this? ---------------------------------------------------------------------- Martin_fr · 2021-08-15 22:17 Quote from: steveinalabama on August 15, 2021, 11:34:19 pmThank you all. I have had success creating 2 programs, and going back and forth revising them. I created brand new folders and put each no program in its own folder. The I used the Project open as described by Dseligo. But I am back to my original problem....trying to run and modify a program that worked a week ago. It already was in its own folder, but not the project files. I was able to find the .lpi file in another folder but it says EXE file not found. I tried Project | new  project from file and it does not work...same error message of EXE file not found. Can anyone help of this? Does it try to compile? Does it give an error? If you press run, Lazarus will try to build the exe. Unless you disabled that, but unlikely... It might be that somehow the files you have, if they were saved to wrong folders, may have bad links.... -------------- Try copying the lpr pas pp lfm files into yet another new folder. Do NOT copy the lpi. Then open the lpr. (drag and drop to IDE) Lazarus should ask if you want to create a new project for it. ---------------------------------------------------------------------- steveinalabama · 2021-08-16 13:40 there were several replies to my message, 2 of which were helpful, but I received a different error. I posted a reply describing the new error, but the post has disappeared, and the 2 helpful replies have disappeared. Looks like this website has problems. ---------------------------------------------------------------------- Martin_fr · 2021-08-16 14:10 Quote from: steveinalabama on August 16, 2021, 03:40:39 pmI posted a reply describing the new error, but the post has disappeared, and the 2 helpful replies have disappeared. Looks like this website has problems. You mean this https://forum.lazarus.freepascal.org/index.php/topic,557 70.msg415181.html#msg415181 ? It seems there were 2 threads on the issue, and they got merged together into this thread. (at least from the admin logs). Downside, they get ordered by time.....