When I was at school we have been learning Pascal programming language and I faced one problem. Since it was school they didn't introduce us to compiling and other stuff "behind the scenes". We used poorly supported 4-6 years old IDE which was also used in national exams. So my problem was that as technology progressed, 64-bit Windows 7 came to action and our beloved IDE now didn't compile a code on this new Operating System.
So what to do?
So if you have faced the similar problem or you just want to learn how to compile without IDE here is what you should do. Go to freepascal.org download and install version of free pascal compiler you need. In my case I need to select Windows 64-bit (in AMD64/x86_64 category).
But sadly that is not all you need to do before compiling. Now we must set PATH so that your Windows knows where your compiler is. To do that Right Click on My Computer and select Properties -> Advanced System Settings (in left panel) -> Advanced Tab -> Environment Variables. Now if you don't see PATH variable like in this picture - you should add one by pressing new. And in variable value put something like this:
It depends on where you have installed your FPC and what version it is.This path should lead to the folder containing "fpc.exe" application. This thing is your compiler. If there was already something in the path variable you should separate them with semicolons.
Get this party started!
So now you can start compiling your .pas files. All you need to do is place them somewhere like "C:/pascal" so that the destination to them is short. Open your command line (console) by writing "cmd" in Start menu search (yeah, that Start in your bottom-left corner). To open your pascal files folder now write "cd C:/pascal". To compile something write "fpc yourProgram.pas". And to open your written program just write "yourProgram.exe".
For editing my programs I prefer notepad++, but you can use any simple text editor. So now you have learned basics of compiling your code, using console and setting the paths. Feel free to ask any questions in comments below.
How To Compile Java
- How To Compile With Notepad++
Notepad++ is just a text editor that has syntax highlighting. I personally love using it, but the drawback is that I sometimes want compile and write code with the same tool. As you know Notepad++ has no...
- How To Compile Java Using Console in Windows
To compile .java programs first you need to get compiler. Get to download page here and select Download JDK. Then you'll have to select your Operating System. After downloading file you will have to install it...
Samuel Santos on May 08, 2014:
I have the same problem which Edzus , to solve my problem i did!
in Enviroment System adding a new system variable click add button to create a new variable, name= FPC and value = C:\FPC\2.6.0\bin\i386-win32\ , and works!!!
Colin Tobing on September 14, 2013:
It's helpful... thanks a lot man :D
Mantas Sinkevičius (author) from Vilnius, Lithuania on March 19, 2013:
You must have set an incorrect PATH variable. You can also try to restart your console, which sometimes might be a case.
Edzus on October 07, 2012:
I did all step by step, just changed C:/pascal folder to C:/PASKALS, when i typed fpc myfile.pas, consule said: "'fpc' is not recognized as an internal or external command,
operable program or batch file."
What goes wrong? In system settings i wrote like this C:\FPC\2.6.0\bin\i386-win32\ and named that value to FPC.
Mantas Sinkevičius (author) from Vilnius, Lithuania on January 21, 2012:
You sure your PATH is correct?
someone on December 04, 2011:
I did it just like that and it says no fpc command recognised