Recent

Author Topic: Setting the fpc path  (Read 1464 times)

cousinp

  • New Member
  • *
  • Posts: 20
Setting the fpc path
« on: August 16, 2024, 08:29:26 pm »
Reading: Getting Started with Lazarus and Free Pascal,  which is several years old. It instructs to set the fpc path as   SET PATH=%PATH%;C:\lazarus\fpc\3.2.2\bin\i386-win32   But when I go to the bin directory it doesn't say i386-win32,    it says x86_64-win64   So what do I enter after the bin\?
Second to set the path in the Environment Variables in the System variables box, when I click on the edit, I get 5 paths and none say 64 as in my bin folder, all say nothing or mention 32. See attachment.
Thanks,
Paul (cousinp)


dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Setting the fpc path
« Reply #1 on: August 17, 2024, 03:23:44 pm »
Paul, you would put the path, as it is on your system. Probably -

Code: Pascal  [Select][+][-]
  1. SET PATH=%PATH%;C:\lazarus\fpc\3.2.2\bin\x86_64-win64

I imagine the docs you are reading assume a 32bit system, yours is obviously 64bit.

As a test, you should be able to type something like -

Code: Pascal  [Select][+][-]
  1. dir  C:\lazarus\fpc\3.2.2\bin\x86_64-win64  <enter>

and see a list of the FPC binary files.  After you have put that PATH statement in place, you should be able to type -

Code: Pascal  [Select][+][-]
  1. fpc -h  <enter>

And see several screens of fpc help.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

cousinp

  • New Member
  • *
  • Posts: 20
Re: Setting the fpc path
« Reply #2 on: August 18, 2024, 08:57:00 pm »
Hi dbannon,
Thank you for your help.
All your instructions worked as you predicted they should, but when I attempt to compile the pas file I get a  message that the file cannot be opened.
I'm running win10 home edition, which is supposed to be 64 bit as my system tells me. see attachments.
Thank you,
cousinp  (Paul)

dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Setting the fpc path
« Reply #3 on: August 19, 2024, 02:14:59 am »
cousinp, firstly, I am not a Windows user ....

But it really looks like there is a problem with your input file, myforstObjPas.pas. Please, from the same place you ran that fpc command, you could type "dir <enter>" so we can see what the file looks like ?  Obviously, it must be present there, readable by you, not zero length.   

You would not get that error message if it contained invalid pascal code, the error would be more explicit.

Just run that dir command, copy and paste the result into a message here.  I am sure all will be revealed then.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

cousinp

  • New Member
  • *
  • Posts: 20
Re: Setting the fpc path
« Reply #4 on: August 19, 2024, 02:49:42 am »
missing before the attached file printout.
C:\>dir
cutoff from the bottom below the '24 files' line:     14 Dir(s)  393,422,475,264 bytes free

Thanks so much for your help
Paul

dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Setting the fpc path
« Reply #5 on: August 19, 2024, 02:55:26 am »
Er, maybe I am missing something here ?  I don't see myfirstObjPas.pas on that list ?   Do you expect it to be there ?

Lots of other files and it does look line you are working in an inappropriate dir but that is your choice.

I'd suggest you should bee starting in a clean, specially made for the purpose, directory, and it should contain myfirstObjPas.pas (and any other pas files your compile might need).

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

TRon

  • Hero Member
  • *****
  • Posts: 3510
Re: Setting the fpc path
« Reply #6 on: August 19, 2024, 06:11:41 am »
Just like dbannon I do not see the source file anywhere in that directory.

On Windows (as a normal restricted user) you are not even allowed to write in the system root directory and If not mistaken then FPC (or one/more of the tools in the toolchain) has issues with root-folders.

A couple of other notes:
Free Pascal and Lazarus both do not need any paths in order to work correctly. You do have to correctly configure both.

To my knowledge the path environment variable on (modern) Windows can only be set as admin and in the registry which is a PITA especially with upgrading.

My suggestion would be to make something like a script directory, add that to your path and create a batch file named fpc.bat (or fpc.cmd) that includes instructions to invoke the actual compiler. You can do that for every fpc related command that you want to run from the command-line (lazbuild, fp, etc.). Takes some time but you never have to meddle with the registry again and as a bonus you can setup things dynamically enough to be able to switch between different compiler versions on the fly.
This tagline is powered by AI

cousinp

  • New Member
  • *
  • Posts: 20
Re: Setting the fpc path
« Reply #7 on: September 18, 2024, 02:50:07 am »
dbannon, you are correct I did the dir command from the wrong directory. Here is the correct result attached.
The first hello.pas file was in notepad file without any program name and directives, the MyfirstObjProj.pas  file had a program name and directives. Could that be why it doesn't compile?  I get an error message, see second attached picture.

All the code was entered exactly as instructed in the book and checked several times. So the question is:  why isn't it compiling?
Thanks,
Paul

TRon

  • Hero Member
  • *****
  • Posts: 3510
Re: Setting the fpc path
« Reply #8 on: September 18, 2024, 03:38:59 am »
All the code was entered exactly as instructed in the book and checked several times. So the question is:  why isn't it compiling?
* TRon steps into his library, looks around to end up finding a playboy from 1953 and sees that the code in there reads something completely different than the code from cousinp.

From that I have to conclude something went wrong somewhere along the line... hard to tell without any actual code and crystal balls are all sold out.
This tagline is powered by AI

PierceNg

  • Sr. Member
  • ****
  • Posts: 393
    • SamadhiWeb
Re: Setting the fpc path
« Reply #9 on: September 18, 2024, 04:20:42 am »
To my knowledge the path environment variable on (modern) Windows can only be set as admin and in the registry which is a PITA especially with upgrading.

On modern Windows you get two options: change your account environment, and change the system's environment. One can set PATH for one's own account with the former option. In cmd.exe, the PATH is concatenation of your account's PATH and the system PATH.

cousinp

  • New Member
  • *
  • Posts: 20
Re: Setting the fpc path
« Reply #10 on: September 18, 2024, 05:16:27 am »
TRon,
My book is:  'Getting Started with Lazarus and Free Pascal' - by Menkaura Abiola-Ellison
The code is attached. The attachment file is .jpg but the code file is .pas
Can you see the error the fpc is giving me?
Thanks

TRon

  • Hero Member
  • *****
  • Posts: 3510
Re: Setting the fpc path
« Reply #11 on: September 18, 2024, 05:30:14 am »
Can you see the error the fpc is giving me?
Everyone is entitled to exactly one chance with me regarding not posting actual text as code (and use pictures instead)  :)

The program name must be an identifier. An identifier has to obey to certain rules. For instance consist of only letters, digits and underscores (where the first character cannot be a digit), see also program header: https://www.freepascal.org/docs-html/ref/refse111.html and identifier: https://www.freepascal.org/docs-html/ref/refse111.html

(now imagine I posted pictures instead of links that contain actual text)  ;D

Your example does not obey these rules and in case the book tells you to do so then it is advising you to do things that are wrong.

edit: see also: how to use the forum
« Last Edit: September 18, 2024, 05:45:18 am by TRon »
This tagline is powered by AI

cousinp

  • New Member
  • *
  • Posts: 20
Re: Setting the fpc path
« Reply #12 on: September 18, 2024, 05:07:17 pm »
TRon,
I don't see my reply from last night, so I will reply again.
TRon, you're the man! Problem on the very first line. After I removed the spaces WHA-LA!, everything worked like a dream. And thanks for the advice on how to post code. I'm new and still learning the forum's protocols.
Thank you to all who helped, I learned something from every response.
Paul

TRon

  • Hero Member
  • *****
  • Posts: 3510
Re: Setting the fpc path
« Reply #13 on: September 18, 2024, 08:02:50 pm »
I don't see my reply from last night, so I will reply again.
Me neither so apparently something  did go wrong there.

Thank you for the (re-)post.

Quote
Problem on the very first line.
From what I gathered you seem new to FPC (or pascal in general).

Note that the compiler is very informative when it comes to encountering (syntax) errors. The compiler explicitly informs at what line/column it encountered an error. You can consider that as being a first hint as of what might be wrong with the code it tries to compile.

Usually pasting that line of code in the forums (use the code tags please if you do) is able to inform us of what might be wrong. Unfortunately programs/code tend to become more complex over time and the compiler is able to confuse itself later on in the compilation process by a mistake in the code made earlier on.

That requires a bigger portion of the source-code to be presented for anyone to be able to understand what might be the culprit.

If the piece of code becomes too large (read hundreds or thousands of lines of code then it also becomes unmanageable for us, and hard to paste between code-tags in a post). In such cases you can zip up your code and attach it to a post.

However, for your own learning experience it might be more fruitful to try and reduce the code into a smaller chunk and that is still able to reproduce the error. The reason for that is that many times when trying to reduce the code people tend to figure out what exactly was wrong with the code to begin with. It is usually the better learning experience.

But what you definitely need to take away from all my rambling is the fact that we cannot see what you are looking at and using pictures/screen-shots is a terrible way to communicate code/errors. Usually pictures are only useful when trying to address a GUI (thus visible) related issue.

Quote
After I removed the spaces WHA-LA!, everything worked like a dream.
Good. Thank you for reporting back and great to see you were able to fix the issue (yourself).

Quote
And thanks for the advice on how to post code. I'm new and still learning the forum's protocols.
No problem, and in case being uncertain or not knowing then just ask if what you do is the right way or ask how you could do things in a better way (if there is any). We all have started where you are at right now but we tend to forget that wee ever have been there as well (so my apologies in case my response sometimes is a bit short/harsh sounding).

Just notice that however frustrating a problem is for you, we are not able to look at your screen or be able to look into your mind. You have to explicitly inform us of what is happening at your side (well, regarding your code that is. I personally do not care if you were listening to the Rolling Stones or was eating a banana at the time the compiler threw an error at you :D )

If there is anything to learn form this all then it is that you need to be as informative as possible and in case possible post your code (sometimes this is not possible because it is company (copyrighted) code but then you are advised to recreate the issue with an example that you are allowed to share).

Thank you for reporting back and good luck with your further endeavors.
This tagline is powered by AI

dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Setting the fpc path
« Reply #14 on: September 19, 2024, 12:43:08 pm »
....
Note that the compiler is very informative when it comes to encountering (syntax) errors. The compiler explicitly informs at what line/column it encountered an error. You can consider that as being a first hint as of what might be wrong with the code it tries to compile.
...

Just to emphasis TRon's point there, actually two of TRon's points.

You posted an image of the error, while much harder to deal with than a text screen scrape, it did say clearly say -
Code: [Select]
myfirstobjproj.pas(1,16) Fatal: Syntax error, ";" expected but "OBJECT" found
Thats line 1 and 16 places to the right. You will soon get used to looking at that error message carefully !

(Hope I am not labouring the point here but important stuff !)

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018