компилятор free pascal для линукс

free pascal

Open source compiler for Pascal and Object Pascal

General

Coding

Tools

Search

Introduction

Overview

Free Pascal is a mature, versatile, open source Pascal compiler. It can target many processor architectures: Intel x86 (16 and 32 bit), AMD64/x86-64, PowerPC, PowerPC64, SPARC, SPARC64, ARM, AArch64, MIPS, Motorola 68k, AVR, and the JVM. Supported operating systems include Windows (16/32/64 bit, CE, and native NT), Linux, Mac OS X/iOS/iPhoneSimulator/Darwin, FreeBSD and other BSD flavors, DOS (16 bit, or 32 bit DPMI), OS/2, AIX, Android, Haiku, Nintendo GBA/DS/Wii, AmigaOS, MorphOS, AROS, Atari TOS, and various embedded platforms. Additionally, support for RISC-V (32/64), Xtensa, and Z80 architectures, and for the LLVM compiler infrastructure is available in the development version. Additionally, the Free Pascal team maintains a transpiler for pascal to Javascript called pas2js.

Latest News

All SVN repositories have been converted to git and moved to gitlab. The Mantis bugtracker has also been converted to gitlab.

You can find instructions in the Development page or in the Wiki.

Bugs can be reported here.

This version is a point update to 3.2.0 and contains bugfixes and updated packages, some of which are high priority. In this case a new target was also backported from trunk.

Downloads are available at the download section. Some links might be stale but will be updated in the coming days. If you have trouble using FTP due to recent browser updates, try the sourceforge mirror.

This version is a major new release and contains bugfixes and updates packages, new features and new targets. Due to the age of the FPC 3.0 branch (5 years!) it is recommended to upgrade as soon as possible.

Downloads are available at the download section. Some links might be stale but will be updated in the coming days.

While FPC 3.2.0 will not have support for the above list, it will have its own collection of new features and fixes!

25 years have passed since 8 june 1993, and FPC still does not only exists, but is more alive and kicking than ever!

As required by the European GDPR, we have published a privacy statement

Current Version

Features

The language syntax has excellent compatibility with TP 7.0 as well as with most versions of Delphi (classes, rtti, exceptions, ansistrings, widestrings, interfaces). A Mac Pascal mode, largely compatible with Think Pascal and MetroWerks Pascal, is also available. Furthermore Free Pascal supports function overloading, operator overloading, global properties and several other extra features.

Requirements

For the 80×86 version at least a 386 processor is required, but a 486 is recommended. The Mac OS X version requires Mac OS X 10.4 or later, with the developer tools installed.

Any PowerPC processor will do. 16 MB of RAM is required. The Mac OS classic version is expected to work System 7.5.3 and later. The Mac OS X version requires Mac OS X 10.3 or later (can compile for 10.2.8 or later), with the developer tools installed. On other operating systems Free Pascal runs on any system that can run the operating system.

16 MB of RAM is required. Runs on any ARM Linux installation.

16 MB of RAM is required. Runs on any Sparc Linux installation (solaris is experimental).

License

The packages and runtime library come under a modified Library GNU Public License to allow the use of static libraries when creating applications. The compiler source itself comes under the GNU General Public License. The sources for both the compiler and runtime library are available; the complete compiler is written in Pascal.

Источник

Установка Free Pascal в Ubuntu

Free Pascal Compiler (FPC) — это свободно распространяемый компилятор языка Pascal с открытым исходным кодом. FPC — кроссплатформенный инструмент, поддерживающий огромное количество платформ. Сегодня мы будем устанавливать его на Ubuntu 18.04, но данная инструкция подойдет и для 16.04, 17.04 и 17.10, а также 20.04 LTS.

FPC часто необходим студентам для учебы — ведь Паскаль это достаточно наглядый и не трудный для освоения язык. Но и продвинутые пользователи Ubuntu смогут использовать данный инструмент с пользой для себя. Так, например, с помощью FPC и IDE Lazarus за считанные минуты можно наваять себе небольшое приложение с GUI для выполнения каких-либо тривиальных действий.

Чтобы использовать FPC в Ubuntu необходимо установить сам Free Pascal, в комплект установки с которым войдет консольная среда для разработки приложений — FP. Но в данной статье мы рассмотрим и то, как установить IDE с графическим интерфейсом — Lazarus.

Установка FPC

Процесс будет происходить в терминале и он включает в себя всего одну команду, если не считать стандартной рекомендации проверки обновлений перед установкой пакета (это не обязательно, если твой дистрибутив регулярно обновляется).

Откроем терминал (CTRL+ALT+T) и введем следующую команду:

Данной выше командой помимо самого fpc мы установим также необходимые библиотеки и текстовую среду разработки fp.

Для начала работы с Free Pascal уже можно выполнить команду fp в терминале:

Компиляция программ

Для того, чтобы узнать, как скомпилировать программу в FPC обратись к нашей статье:

Установка Lazarus

Для тех, кому не достаточно консольной версии среды разработки и тех, кому нужно создавать приложения с графическим интерфейсом есть среда разработки Lazarus. Она похожа на Delphi и, если у тебя есть опыт работы с ним, то разобраться с Lazarus’ом не составит труда.

В терминале выполним команду установки:

После установки IDE будет доступно в меню приложений:

На этом этапе установка закончена и можно приступать к работе.

Источник

Компиляция Free Pascal в Linux

Free Pascal Compiler (FPC) — это свободно распространяемый компилятор языка Pascal с открытым исходным кодом. FPC — кроссплатформенный инструмент, поддерживающий огромное количество платформ.

В одной из предыдущих статей мы рассматривали вопрос установки компилятора FPC в Ubuntu. В данной же статье мы узнаем, как скомпилировать свою первую программу после установки данного компилятора.

Материалы, которые могут пригодиться:

Создание программы

Программы на языке FPC можно писать с помощью любого текстового редактора и сохранять в текстовом формате с расширением «.pas». Для примера такой программы я буду использовать утилиту для определения количества кругов итераций необходимых для нахождения случайного числа, равного нулю. Это одна из моих старых практических работ студенческих времен, какую-либо фактическую пользу данная программа скорее всего не несет.

Перейдем к созданию программы. Создадим файл las.pas в домашнем каталоге пользователя:

Откроем данный файл в редакторе nano и запишем в него нижеприведенный код:

Компиляция и запуск

Сохраним данный файл (las.pas) и выполним его компиляцию с помощью FPC:

На выходе получем два файла:

Файл с расширением «.o» нас не интересует — он является объектным файлом. Компилятор создает объектный файл для каждого исходного файла, прежде чем связать их вместе в окончательный исполняемый файл.

Нас же интересует выходной бинарный исполняемый файл las. Именно его мы и попробуем запустить:

Как видно из скриншота выше — программа отработала и случайное число (от 0 до 100 (предела, который мы указали)) равное нулю было получено на 40 раз исполнения команды random();.

Источник

Installing the Free Pascal Compiler

Contents

Overview

There are a number of ways to install the Free Pascal Compiler and its libraries on your system. The current version and trunk, and sometimes beta and release candidates, are available directly from the FPC website (tar, exe, rpm, dmg, pkg files). In addition, versions of FPC are provided (including rpm and deb files) from the Lazarus download site. Linux users can almost certainly find FPC in their distribution’s repositories but may find that it is outdated.

It is possible to build FPC from source, typically each release needs to be built with the previous release. It is possible to install FPC in the application space (often requiring root or administrator access) or in a your own user space. These things depend on your particular operating system.

There is an extensive discussion of how to install and build Free Pascal compilers available here http://www.stack.nl/

Linux

FPC Binary Packages

Note: You have a number of way to install FPC presented here, which one is best for you depends very much on what you are planning to do and if you need a very current version. If you are also planning on installing Lazarus, perhaps a quick look at Installing_Lazarus and Installing_Lazarus_on_Linux is a very good idea.

FPC Tar Balls

Another option is installing from a tar, an easy and possibly even more useful model. These tars are available for a wide range of Unix like systems. You need to download the appropriate binary tar for your OS and CPU and you may also need the source files, common for all OS/CPU. You install FPC this way in your own space, not as root.

Note: A tar install does not resolve dependencies, if they are not already present, first install binutils, make, gcc.

FPC sources

The FPC source files are stored in a Subversion (SVN) repository (https://svn.freepascal.org/svn/fpc/trunk) and mirrored in a Git repository (git://github.com/graemeg/freepascal.git). The repository keeps track of all the changes by developers in the source tree. Once you have the sources, please see Installing from source under BSD/Linux for instructions on how to install them.

Update from the source repository using SVN or Git

The SVN or Git repository has been made accessible for everyone, with read-only access. This means that you can directly access the code, and you will have really the last-minute sources available. It is also a method which requires less bandwidth once you have done the first download (checkout in SVN lingo; clone in Git lingo).

Getting the source

First, you need to have an SVN or Git client installed. Use your package manager, install a tool like TortoiseSVN on Windows, or look at the Subversion web site or the Git webs site for more details and client downloads.

Using command line svn: change directory (cd) to the parent directory of your development area, eg To retrieve the full source repository for the first time into an fpc subdirectory under your home directory, type:

Note: FreeBSD includes the svnlite client in the base system which you can use instead of installing the full Subversion svn client.

Using command line git: change directory (cd) to the parent directory of your development area, eg To retrieve the full source repository for the first time into an fpc subdirectory under your home directory, type:

To update the sources which were downloaded (checked out/cloned) above:

Getting a separate branch

If the current trunk version is in a state of rapid change and unsuitable for much use unless you want to work on the compiler itself, you can stay on a version that is updated with fixes. To do this, you have to find out a stable branch that you want to track instead of the default trunk development version.

The example below shows how you can track the fixes_3_2 version; of course replace as needed depending on what branch you want to track.

Note: There is no Git repository for fixes_3_2.

Documentation sources

The documentation sources are in a separate repository called fpcdocs, so the command to get them is:

If you want to learn more about subversion, read this excellent Subversion book which is also available online in different formats for free.

For more information, see the Free Pascal website.

Compiling the FPC source

Decide about install/to/directory and also add options that you need.

/software/fpc/3.2.0/bin), you have to move the fpc.cfg to

FreeBSD

Note: If you wish to also install Lazarus, you can omit installing FPC with the steps below as the Lazarus port will install it for you. See Installing Lazarus on FreeBSD.

Installing from the ports collection

The FreeBSD ports collection has FPC v3.2.2 version in /usr/ports/lang/fpc. FPC is scattered over 105(!) packages. The FPC source is now installed by default; it previously needed to be copied and uncompressed from /usr/ports/distfiles/freepascal.

This must be done as root.

Also, you can install FPC and units from pkg binaries:

Once FPC is installed you can check if it’s working by simply running as a normal user:

which should produce output similar to this:

Installing from tar

Select the appropriate 32 bit/64 bit tar file based on your system. For x86_64 64-bit FreeBSD, download from x86_64. For i386 32-bit FreeBSD, download from i386.

To install Free Pascal from a terminal:

Replace the desired Free Pascal version (3.0.4, 3.2.0, 3.2.2 or 3.3.1) and architecture (x86_64 or i386) as required.

If you want to install the Free Pascal Compiler globally, for example in /usr/local, run the install.sh script as root. install.sh script uses bash shell syntax. If you get Bad substitution error, make sure you run script with bash.

The executable generated for this program will cause a segmentation fault when run. To fix this issue, you need to install the GNU linker:

OpenBSD

Installing from tar

Select the appropriate 32 bit/64 bit tar file based on your system. For x86_64 64-bit OpenBSD, download from x86_64. For i386 32-bit OpenBSD, download from i386.

To install Free Pascal from a terminal:

Replace the desired Free Pascal version (3.0.4, 3.2.0 or 3.3.1) and architecture (x86_64 or i386) as required.

If you want to install the Free Pascal Compiler globally, for example in /usr/local, run the install.sh script as root. install.sh script uses bash shell syntax. If you get Bad subtitution error, make sure you run script with bash. OpenBSD uses ksh as default shell. You need to install bash manually.

Installing from source on BSD/Linux

Effectively, you need:

2. A starting (bootstrap) FPC compiler. An FPC release can always be built by the previously released FPC version, and FPC trunk can always be built by the current FPC release. You can download a bootstrap Free Pascal Compiler or use your distribution’s package management/software system to install one.

Windows

Installing an FPC release with the Windows installer

Warning: If you are intending to also install Lazarus using the official Windows installer which installs both FPC + Lazarus, please ignore these instructions and instead refer to Installing Lazarus on Windows to avoid having to resolve any resulting conflicts.

Installing from source

Installing from source with a command line Subversion (svn) client is not for novices, since you also need a working bootstrap compiler to be able to compile the Free Pascal Compiler from source. Instructions for obtaining a bootstrap compiler are included below.

Obtaining the source with a command line svn client

Source for a release version of FPC

First create a directory in which you’d like to keep the source. Any normal user can do this. Create a directory for FPC (eg C:\Source) by typing the following at a command prompt:

Now type issue the following command at a command prompt:

Wait while the Subversion repository is downloaded to the fpc-3.2.0 directory in your newly created Source directory. This can take a while. have a look at the helpful Free Pascal Forums while you wait :-) You may also like to read the excellent How to use the Forum Wiki article which explains how to get answers to pesky questions quickly. New Forum users are always welcome.

Source for a non-release version of FPC

There are two current non-release branches of the Free Pascal Compiler: the development (trunk) branch and the Fixes 3.2.0 branch which includes additional fixes to the released 3.2.0 version. Developers, and those who like living on the bleeding edge and testing new features and fixes, will choose the development version; more normal users, who wish to use a stable branch with some additional fixes since the latest release version, will choose the Fixes branch. The instructions below cover both these branches.

If it does not already exist, create a directory in which you’d like to keep the FPC source (eg C:\Source). Any normal user can do this. Now type the following command at a command prompt:

For the Fixes branch of FPC 3.2.0

For the Development (trunk) branch of FPC

Hint: To update your local copy of the repository with subsequent changes, you need only do:

For the Fixes branch of FPC 3.2.0

For the Development (trunk) branch of FPC

Obtaining the source with the GUI TortoiseSVN client

The first thing you will probably need to do is download the GUI TortoiseSVN Subversion client from TortoiseSVN website Download file area if you do not already have it available.

After downloading the appropriate Windows installer and installing it, you are ready to begin. You will notice that TortoiseSVN has added a number of shortcuts to the File Explorer context menu so that you can work easily with svn without needing to use the command prompt.

Source for a release version of FPC

To download the latest release version Free Pascal Compiler source from the Subversion repository, first create the directory in which you’d like to keep the source. Any normal user can do this:

Source for a non-release version of FPC

There are two current non-release branches of the Free Pascal Compiler: the development (trunk) branch and the Fixes 3.2.0 branch which includes additional fixes to the released 3.2.0 version. Developers, and those who like living on the bleeding edge and testing new features and fixes, will choose the development version; more normal users, who wish to use a stable branch with some additional fixes since the latest release version, will choose the Fixes branch. The instructions below cover both these branches.

The instructions are the same as for a release version of the Free Pascal Compiler given above, except that you will need to replace the «URL of the Repository» and «Checkout directory» fields with the appropriate values set out below:

For the Fixes branch of FPC

For the Development (trunk) branch of FPC

Updating your local repository

To update your local copy of the repository with subsequent source changes:

Obtaining a bootstrap compiler

Then restart windows.

Compiling the FPC source

The cross-compiler to compile programs for Windows 64 bit may now be found here: C:\FPC\3.2.0\bin\i386-win32\ppcrossx64.

macOS

Warning: If you are intending to also install Lazarus using the official macOS installation packages which install both FPC + Lazarus, please ignore these instructions and instead refer to Installing Lazarus on macOS to avoid having to resolve any resulting FPC conflicts.

Installing an FPC release from the official macOS packages

Step 1: Download Xcode (optional)

Xcode is a 12GB download which will take up 16GB of disk space. You only need to download and install the full Xcode development environment if you need:

Xcode 11.3.1 for use on macOS 10.14 Mojave must now be installed by downloading it from Apple Developer Connection (ADC), which requires free registration. Xcode 11.4.x for use on macOS 10.15 Catalina can be installed from the Mac App store. Note that you must first move any old Xcode versions from the Applications folder into the trash or rename the Xcode app (eg Xcode.app to Xcode_1014.app). You can select which version of Xcode to use with the command line utility xcode-select.

Step 2: Xcode Command Line Tools

This is shown here as a separate step because it really is a separate step in addition to Step 1. Don’t confuse this with the internal Xcode command line tools that the Xcode GUI will tell you are already installed. FPC does not use those Xcode internal command line tools, so do the following (it is quick and easy)-

You only need to enter the first of the two commands above unless you have also installed the full Xcode package. If you have only installed the command line tools, you should omit entering the xcodebuild command.

Step 3: Download FPC

Download the Free Pascal Compiler (FPC) and FPC source from the Free Pascal website. When you arrive at the download page, select a mirror and then choose the correct version for your operating system.

These installation packages are built by the FPC developers and track formal releases. As these installation packages are not code signed nor notarized by Apple, you need to either control-click on the installation package and choose «Open» or right-click on the installation package and choose «Open» in the contextual menu and confirm you want to install from an Unknown Developer.

Installing from source

There are two current non-release branches of the Free Pascal Compiler: the development (trunk) branch and the Fixes 3.2 branch which includes additional fixes to the released 3.2.2 version. Developers, and those who like living on the bleeding edge and testing new features and fixes, will choose the development version; more normal users, who wish to use a stable branch with some additional fixes since the latest release version, will choose the Fixes branch. The instructions below cover both these branches.

The source code is kept in a version control system called git:

FPC development version

Note that since the development version of FPC (was known as «trunk» in SVN; now known as main in GIT) is by definition still under development, some of the features may still change before they end up in a release version.

Create a directory where you would like to put the source (eg fpc_main in your home directory). You don’t need to be root to do this. Any normal user can do this. Open an Applications > Utilities > Terminal and do the following:

This will create a directory called ‘fpc_main’ and download the FPC main source to it.

To subsequently update your local source repository with the latest source changes you can simply do:

To build and install FPC (the highlighted text should be all on one line):

You will also need to update the links for the compiler in /usr/local/bin which will be pointing to the previous FPC version. For example:

Note that you will need to build a new ppc386 compiler if you want to continue to compile 32 bit applications by replacing these lines (this is not be possible after Xcode 11.3.1 and macOS 10.14.6 Mojave because of Apple’s removal of 32 bit framework):

with these two lines:

FPC Fixes 3.2

Create a directory where you would like to put the source (eg fpc_fixes32 in your home directory). You don’t need to be root to do this. Any normal user can do this. Open an Applications > Utilities > Terminal and do the following:

This will create a directory called fpc_fixes32 and download the FPC source to it.

To subsequently update your local copy of the repository source with the latest source changes you can simply do:

To build and install FPC (the highlighted text should be all on one line):

You will also need to update the links for the compiler in /usr/local/bin which will be pointing to the previous FPC version. For example:

Note that you will need to build a new ppc386 compiler if you want to continue to compile 32 bit applications by replacing these lines (this may not be possible after Xcode 11.3.1 and macOS 10.14.6 Mojave because of Apple’s removal of 32 bit frameworks):

Other installation options

Testing the FPC Install

Now compile this simple code by typing this command and then pressing ↵ Enter :

It should very quickly make an executable called, you guessed it, «helloworld». Run this executable by typing this command and then pressing ↵ Enter :

If that worked, well done!

Useful command-line switches for compiling from source

Installing cross compilers

A cross compiler allows you to create binaries (executables) for a platform different from the platform being used for compilation. For example, working under macOS and creating executables for Win32, FreeBSD or Linux. For details on how to do this, see Cross Compiling.

Источник

Понравилась статья? Поделиться с друзьями:

Не пропустите наши новые статьи:

  • компилятор fortran для windows 10
  • компилятор c для mac os
  • компилятор c linux mint
  • Компилятивная программа что это такое
  • Компилятивная программа в доу что это такое

  • Операционные системы и программное обеспечение
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest
    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии