31 October 2010

Dynamic libraries can be found: libpq.so.4, libpq.so

I'm investigating the use of lazarus/postgresql for a linux desktop application.

Fresh Linux installation produce this error, when starting application

Exception=None of the dynamic libraries can be found: libpq.so.4, libpq.so

Fix is

ln -s /usr/lib/libpq.so.5 /usr/lib/libpq.so

18 October 2010

Lazarus Report Preview

This is a main logic of sample code to produce Preview of LazReport :

procedure T_f_main._ButtonClick(Sender: TObject);

Lazarus ZeosDBO Stored Procedure Call for PostgreSQL functions

This is main logic in some Lazarus database form, powered by ZeosDBO, to call stored procedure (postgresql function), who is placed in ZSQLReadOnly SQL property, like

SELECT * FROM Name_Of_Function()

Then In ZTable BeforePost event, you reopen that ZSQL to retrieve default value of primary key, like this code :

procedure T_f_main._ZTableBeforePost(DataSet: TDataSet);
if _DataSource.State in [dsInsert] then
with _ZSQL_readonly_procedure do
Open ;
_ZTableID.Value := Fields[0].asInteger;
Close ;

16 October 2010

postgresql on OpenSuse default login error (solved)

On terminal test : psql -h -p 5432 postgres postgres

If you receive error:
psql: FATAL: Ident authentication failed for user "postgres"

Edit /var/lib/pgsql/data/pg_hba.conf, and write


instead of "ident"

then reload PostgreSQL

As root: service postgresql reload
or as postgres user: pg_ctl reload

Ownership of pg_hba.conf has nothing to do with the authentication.

14 October 2010

Is Lazarus ready for writing commercial applications ?

(this is one software developer experience from Blaise Pascal Newsletter , that proves that Delphi multiplatform magic is possible, but in Open Source world through Lazarus project, so I simply must share it on my blog...)

"This article illustrates the enormous progress Lazarus has made because of the dedicated work of the core developer team: it shows Nowadays Lazarus is in many ways on a par with Delphi. In several key areas it is way ahead of Delphi (64 bit compiled executables, multi-platform and multi-OS, allows development on mobile and embedded systems).

Of course it is not the same as Delphi, but very cheap - see the price of the Lazarus USB stick in the Advertisement. So affordable for anyone and you get started immediately with no installation required. You can create any application you ever wanted and the number of components available is grows steadily. So the answer is YES. Perfect for commercial applications!

I started my job in 2001 at a Croatian company called Holobit...

At that time Holobit was a pretty small company with a few dozen customers. My primary task was to make the company's current C++ business applications run on Linux and Windows by using Delphi and Kylix and Borland's CLX technology. After years of C/C++ coding on linux OOP looked very simple and well organized. Two months later I concluded that Borland had great products, and the coding time is much shorter than it was with C/C++ (gtk+,qt) using vi editor. Anyway, within 3 months our business applications were converted to CLX and the company started selling for Linux & Win32. All was done with Kylix 2 and Delphi 6 (later upgraded to K3 & D7).

Creating native Linux apps was a good decision, so the number of customers started growing rapidly. Our customers were happy with the ability to choose between Linux and Windows client apps for dekstop PC’s, because it saves some money and creates a better and more secure environment. The second conversion issue that looked rather complicated - at that time - were databases. When I started to convert our applications, all of them used Foxpro, and I was very disapointed with it, because I already used Postgresql on Linux. So your guess that we moved all of our applications to Postgresql is quite correct.

At that time I didn't know third party components like Zeos etc..., so I wrote my own Postgresql driver and used it for several years. Later when I found Zeos - a nice surprise – I immediately started to use that. So it went on until 2004, there were rumors that Kylix was Exit, no news from Borland – just silence ... Yes it was Exited: shame on you Borland, not because you put Kylix into grave, but because you cheated your customers. For years, then, we were fighting with Borland products. (In the meantime Kylix could not run on any distributions based on Glibc higher than 2.4.X) then, until I saw someone had started a qt-widgetset in a Lazarus project, and that guy was Felipe, and thanks to Den Jean for Qt C bindings, because without C bindings we could not have a Qtwidgetset inside Lazarus.

I had looked into Lazarus just a few times before, but I was not attracted previously, because it supported only the Gtk1 widgetset which looked awful compared to the Qt2 used by Kylix, so now I got motivated to download the lazarus trunk and find out to see the way how it worked with Qt. (I already tried Gtk before). Well, as IG mentioned already, work on the Qt widgetset having only just started, the result needed a lot of improvements, so it does not work.

After a quick scan of Lazarus principles, the Lazarus component library (LCL) and widgetset connections to the LCL I began to contribute to the Lazarus project with a primary goal to get Qt widgetset up and running. My first patches then were sent to Felipe. He argued about my coding standards (hey, hey), but I fixed that and changed my coding standards to the Lazarus coding standard. Anyway, after a year or so the Qt widgetset became useable - in the meantime Lazarus developers granted me svn write access - so no more need to wait for Felipe and others to commit my patches. At the same time – business problems arose with Kylix & Delphi programming and the company management considered moving our thought about to move the complete codebase to Java or .Net . When the management decided this change must be made quickly I objected.

I was not very happy with that. Not because of the applications, but because of all the third party components used in our applications (ZeosLib, FastReports, TMS grids, VirtualTrees etc). I said that we would need a lot of time and resources to move our code to Java or .Net and the result of that operation was not reassuring. I was disturbed by these business decisions (and already had in mind to change the job), so at one day I asked the chief if they could agree to let me spend some time developing code using Lazarus, and in the next few months I showed some of our apps running on Qt4.

I had started a race against time, I had to fix the Qt-LCL and convert one of our applications to LCL (only a small one). That wasn't an easy task since qt-lcl is still not finished and lot of things were not working. Zeos for Lazarus already existed, but for this simple applications I had to have FastReports and TMS grids. So I had three months to make Qt under Lazarus useable, convert FastReports and TMS grids (both CLX licensed)...

After hundreds of hours of coding, the day of reckoning came. I had to show my work at the end of February 2008. I made a presentation on Linux, 32 bit Windows and on Mac OSX and the company management was pleased and satisfied with it. Of course there were still bugs and features not yet implemented, but they appreciated my main argument. If we moved to Lazarus we would be able to work on other (even more) supported platforms, and also because Lazarus is an open source project, we would not be at the mercy of decisions made by other companies (such as Borland) that had harmed us in the past. That became the happiest day in the last few years of my working life. I was given the budget and time required to move our applications to Lazarus. Now I had a reasonable time (15 months) to improve Lazarus and re-write our applications for Lazarus (and deal with other everyday tasks). During 2008/2009 I converted all the third party components and all of our applications to FPC/Lazarus, and therefore also contributed a lot of patches to the Lazarus project. The Goal is reached – Lazarus is better now than Kylix 3 and we started to deploy Lcl LCL applications over more than 3,500 at customers’ sites.

User impressions were positive since our apps looks native on all platforms. A few dozen of Mac OSX users were also happy since we give them native apps for the first time (they used Parallels + linux VM). WOW, what a glorious day. We just did not need the Borland products anymore.

Now our complete range of software is developed using FPC/Lazarus and uses PostgreSQL RDBMS:
1. HoloERP – ERP system with > 400 modules (forms)
2. Cafeman – Caffe bars & restaurants backoffice and POS system
3. TSuS – small shops backoffice & POS system
4. Cinema – software for cinemas (reservations, tickets etc)
5. ArhStudio – architects documentation database.

All of those these applications use the following 3rd party components:
· ZeosLib
· FastReports (ported CLX)
· TMS Grids (ported CLX, but also we licensed the newest VCL
and ported it also)
· TMS Planner (ported CLX, later VCL)
· FlexCell (licensed LCL , yes there's LCL version)
· Our custom components

Lazarus is ready for commercial usage especially for people with legacy Kylix3 / Delphi7 codebases.
My personal opinion is that Lazarus Qt is much better than K3/D7 at this time (0.9.29 trunk), and developers will be happy with it's new 0.9.30 version.
· The only OOP RAD which supports so many platforms.
· Constantly developed by volunteers, it does not depend on commercial decisions so you can avoid bankrupcy etc.
· Costs almost nothing except energy and time.
· If it doesn't fit your needs, you can change it and contribute.
· If there's a bug - you can fix it and contribute it, but at least you can open an issue at lazarus mantis issue tracker."

Author of this blog text is Lazarus forum member Zeljan and software case is from http://www.holobit.net

02 October 2010

MS Windows Mobile 6.5 - How to return default lock screen

To return default lock screen in MS Windows Mobile 6.5 in some cooked ROM (NRG, TAEL and other), you should remove these registry keys :