Lazarus for Cross-Platform Development
Lazarus provides an outstanding native code solution. The compiler and most libraries are written with cross-platform in mind. That is why programs written in Free Pascal do not need to run a configure script before compilation. The base types, like char, byte, integer and string, work the same on all platforms. An integer always is a signed 32-bit value. The 64-bit integer is called int64. The native integer for a processor is called PtrInt for signed and PtrUInt for unsigned values. Lazarus itself can be compiled with a simple make or graphically in the IDE itself. And, of course, Lazarus is developed with Lazarus.
FPC's runtime library does not use libc; rather, it uses kernel functions, which change less often. Therefore, the created executables normally work on various Linux distributions and do not need to be recompiled for each new glibc version.
With Lazarus, you can write and debug the biggest part under Linux. But eventually, you'll need to test it on the other targets. However, you do not need to install Lazarus and all the development tools on all your target platforms. Cross compiling can be used to develop under Linux and target another operating system or processor. For example, you could develop under Linux and create Windows executables, and then test them with Wine or in a virtual machine running Windows, or on an actual Windows system. Cross compiling is a big time-saver, because it allows you to test on several platforms quickly and to use your favorite programs while developing.
Note, however, that cross compiling does require you to install the cross-compile tools and libraries, which can be tricky. Precompiled versions do not yet exist for all possible hosts and targets. Easy directions are provided for Linux to Windows, because of Wine, and for Windows to Windows CE, because there are installers with all needed tools.
First, you need to cross compile and install the GNU binutils. This is well documented on several sites, including the Lazarus Wiki (see Resources). For many targets, this is as simple as downloading a single tar.gz and running a script with some parameters.
The next step is to cross compile the Free Pascal libraries. If you want to cross compile to another processor type, you need to cross compile the compiler too. Again, for many targets, complete scripts are available.
If your program requires third-party libraries, these must be cross compiled too. If they are written completely in Object Pascal, normally you can just compile them. Lazarus will do that automatically for you. If they use system libraries, it can become difficult. The problems are then the same as for C/C++ compilers.
Once you've installed the cross compiler and libraries, cross compiling becomes easy in Lazarus. Simply pass the -T option to the compiler. For example, pass -Twin32 to compile a 32-bit Windows executable instead of a Linux binary. The -P option defines the target processor. Normally, you don't even need to pass special search paths, because of the path scheme used. For instance, the Pascal units for the fpc 2.3.1 compiler, for the processor type i386, and for target operating system Linux are installed under /usr/lib/fpc/2.3.1/units/i386-linux/. All filenames and search paths of the compiler and the IDE support macros, which greatly reduces the amount of command-line parameters and configuration settings.
Lazarus reduces the amount of platform-specific settings even further. The IDE allows you to combine several source directories into a Lazarus package. A Lazarus package can be a library or just a logical module of a big project. A package has its own search paths, its own compiler settings and its own macros. All filenames and search paths are stored relative to the configuration file (.lpk file). A package can use other packages and inherit search paths and compiler settings. You can store a package anywhere on the disk. All search paths are adapted automatically on the fly. And, because every source has its own namespace, there is seldom a name conflict. You can switch to another version simply by opening the .lpk file. Each package also has its own output directories, normally one for each platform, which are created automatically.
When a package's source file is changed, the IDE automatically compiles the package and all packages in the current project that depend on it. You can fine-tune this automation for each package.
When you switch the target platform in the IDE, all packages' output directories are switched. The compiler options dialog is shown in Figure 2.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- Designing Electronics with Linux
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Dynamic DNS—an Object Lesson in Problem Solving
- Using Salt Stack and Vagrant for Drupal Development
- Build a Skype Server for Your Home Phone System
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- Why Python?
- Validate an E-Mail Address with PHP, the Right Way
- Tech Tip: Really Simple HTTP Server with Python
- Great
1 min 8 sec ago - Reply to comment | Linux Journal
9 min 9 sec ago - Understanding the Linux Kernel
2 hours 23 min ago - General
4 hours 53 min ago - Kernel Problem
14 hours 56 min ago - BASH script to log IPs on public web server
19 hours 23 min ago - DynDNS
22 hours 59 min ago - Reply to comment | Linux Journal
23 hours 31 min ago - All the articles you talked
1 day 1 hour ago - All the articles you talked
1 day 1 hour ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?





Comments
Finnally, I have made a Puppy Linux remastered with Lazarus.
I have tried months to install Lazarus 0.9.28.2 in Puppy Linux 4.3.1, and I finally have success!
The result is a .iso file , 330MB : just burn to CD , reboot your PC and start developing in Lazarus!!
The MD5 sum is fa94102ecf1bf5c29f629148667399fc , and you can download from one of these locations:
1)http://www.megaupload.com/?d=10836C0B
2) http://www.puppyisos.org/isos/2009-07-to-12/
(user: puppy , password: linux)
You need a PC with at least 480MB of RAM, because all is loaded in memory; yes, I know, it is a disadvantage.
Another way is to install plain Puppy 4.3.1 (Frugal installation on disk), with devx_431.sfs and this .sfs created by gposil,
http://gposil.com/dpup/lazarus-0.9.28.2-complete.sfs
In this way, you can run Lazarus in a PC with 128MB of RAM.
I hope this will help people that have trouble installing Lazarus in Linux.
No garbage collection
Free Pascal lacks garbage collection and you can't even have smart pointers like in C++. Manual memory reclamation is not a feature of a modern language.
Oh please
garbage collection is only making mess. Who cares if you get a memory leak due to unhandled exception? Nobody. Good programmers know how to manage memory and don't need anything else thats only slowing app down...
Why is so difficult to install Lazarus in Puppy Linux?
I am a electronic technician and have used Borland Pascal for controlling devices. When Windows 95 becomes popular, I cant obtain Delphi, and have programmed in Visual Basic. Now, I am interested in programming in Lazarus. I am using the Puppy Linux distro, but I am tired to trying to make Lazarus work. Please, anybody can make a .pet or a .sfs or a Puppy remastered with Lazarus working?
Another question: why the Lazarus installer do not contain ALL the stuff? In Windows, Lazarus installs without problems. But I am disappointed with Linux, because each distro neeeds different installation procedures. This is a great Linux failure.
> why the Lazarus installer
> why the Lazarus installer do not contain ALL the stuff?
Because the dependencies can be obtained easily from distro's repository, and it's of course a waste of space to include the installer along with them. Another problem, those dependencies depends on installed libc version which can't be predicted easily. Free Pascal (and therefore, Lazarus) itself is OK since they're not linked againts libc.
Every Linux distro is a separate world
I see .deb and .rpm installers for Lazarus.
It is a shame that every Linux distro has different installer packages.
For end user, each distro is equal to a different operating system.
Writing components
I'm using Delphi for more than 10 years, and following Lazarus for many years. Thanks to Lazarus, I discovered a new area of developments, which is component development. Lazarus is needing a lot of components and packages. It is very easy in Object Pascal language to write a package.
Now I'm doing a web development components similar to Delphi's WebBroker. Now CGI part is working. I'm developing this component under Linux and it works just fine under Windows without any modification.
They only problem that I faced in Linux is Arabic language support in linux. Current stable version is still using GTK 1, and Unicode support is exist in GTK+2 which supported by not-stable daily snapshots.
Fortunately I can use Arabic with my web applications under linux, because no need for GTK1 or 2 :)
> Current stable version is
> Current stable version is still using GTK 1, and Unicode support > is exist in GTK+2 which supported by not-stable daily snapshots.
AFAIK since version 0.9.26.2 GTK2 is already set as default widgetset on linux, marking its stability has reached a suitable point for development. Either you're using an older version or you take a conslusion from the wiki (which is often not up to date).
I'm using 0.9.26.2 and the
I'm using 0.9.26.2 and the default is set to GTK, GTK2 is marked as beta still.
Pascal as language has been
Pascal as language has been understimated too much, but it features many important things since its creation. And more: it has evolved really well, in many ways in many of its dialects. I think it has what it takes to be the next king of strongly typed languages.
Compiler speed is important
Many programmers state that compiler speed isn't that important compared to generated code quality. Imaging you're working on a big project that gets changed very often, how long do you spend time watching your compiler compiling your code?
My experience in building large projects, such as QT and GCC, shows that compiler speed is important. QT took 6 hours to build (even with make -j 256!), GCC bootstraps itself (compiler, binutils, standard libs) in more than an hour.
FPC and Lazarus are also big complex project. But do you know how long does it take to build both (for FPC, it includes compiler, helper tools, IDE, standard libs, and tons of extra libs)? 10 minutes! This is a great time saver everybody!
My First project with lazarus is done!
About 2 years ago, I porting a win32 application writing in delphi to linux.The first choice is kylinx, But it is too old for most linux, very hard to use on Centos 5. But I found lazarus, It help me complete that. And the application had sucessed runing on Centos and ubuntu, is cost down about 1,000RMB for me/PC!
A great project!
We do Delphi development so
We do Delphi development so when the time came to start developing applications for use on Linux systems, Free Pascal and Lazarus seemed like the natural choice. Free Pascal is really quite nice, but unfortunately Lazarus isn't quite as nice. After using Lazarus on a number of projects we found it still had too many problems to make it worth while to continue using it. There were always large regressions between major Lazarus releases. Every time we upgraded we had to spend time figuring out why the applications that used to work just fine in the previous release suddenly no longer worked the same in the current release.
Eventually we abandoned Lazarus and moved to just building Win32 applications and running them with Wine. This approach, of course, had issues of its own but once the teething problems were sorted out our applications ended up working better and with more features than their Lazarus-based ancestors. This is partly because there is simply more choice of components and libraries for Delphi than there is for Lazarus, partly because there was a lot of code we could reuse between the "Linux" applications and the "Windows" applications, partly because the Delphi development environment is stronger than Lazarus with more and better integrated tools, and partly because the Delphi + Wine platform has by and large turned out to be more stable.
Back to Pascal? I Can Hope!
Like Paulo Pinto, I cut my teeth on Pascal in the MS-DOS days and was sad to see it disappear under the weight of C and, particularly, C++.
The object-oriented versions that limped along simply seemed to be half-baked hotch-potches.
Perhaps this will give me a way back to multi-platform Pascal. Goodness knows, it would make my life much easier!
Thanks for the review :-)
Lazarus vs Delphi
Lazarus has still a long way to go comparing it with its commercial competitor Delphi.
Don't get me wrong: I would love using Lazarus if it would compile faster and create smaller binaries, but most important, it has to be rock stable.
I'm a using Delphi as a professional developer for about 10 years now.
Oh come on!!!
When did Pascal become "an easy to learn language"? It shouldn't come as a surprise that it is not in widespread use since it works only with Pascal which..... need I say isn't much used these days. Extending the IDE is always nice but there aren't too many third-party plugins available for it.
Nice review of Lazarus though.
Pascal was always a nice
Pascal was always a nice language. Did you know that the first versions of MacOS were written in a mixture of Pascal and Assembly?
I remember the days were most of my MS-DOS coding was done in Turbo Pascal, and even my first coding attempts in Windows 3.x were done in Pascal.
But C got more widespread, mainly thanks to C and having a language standard defined more tailored for doing systems programming.
The Pascal standard was only suited for teaching and we had to rely on manufacturer extensions to be able to do real life applications. When the second revision of the standard came out, it was already to late.
For me, Pascal will always have a place on my heart.
I'm working with lazarus for
I'm working with lazarus for years and it is amazing!
It is great to compile it in linux and windows with excactly the same code!
Cross-platform is a breeze
Excellent article Mattias! Our company moved over to the Free Pascal Compiler and Lazarus IDE four and a half years ago. The support is fantastic, the products are very stable and development is continuous.
The Object Pascal language is also very nice - miles ahead of the old Pascal from the 80's. A clean and strongly typed language that you can learn very easily. It supports full object oriented programming and combined with a very fast compiler and excellent component libraries, this is a win-win situation for any developer or company. Object Pascal deserves a lot more attention in the developer circles.