Compiling Lazarus

Michael A. Hess mhess at miraclec.com
Sat May 8 16:04:32 EDT 1999


Cliff Baeseman wrote:
> 
> I am working a major revamping of some of the lazarus code right now.
> 
> Hey got a question for you ? Do you have a copy of the sybil classes?
> I need to see exactly how TApplication is put together...

Yeah I do. The TApplication is in the form.pas file do you want that
one?
 
> How does a normal  delphi app go about firing up? I think the project
> unit creates TApplication and passes the forms to be created to it and
> then calls run or something... In lazarus I wish to load the forms to
> a list in TAppplicaiton but how do I actually implement this
> "cleanly".

Here is a simple project file which is for the fpide help system. You
tell it which units (aka forms) it needs to use.

First call Application.Initialize is not really used in Delphi and could
be ignored but you might want to use it as indicated below.

Application.CreateForm of course just calls the .Create for the TForm
being passed to it and depending on which one is first in line
establishes it as the main form that controls termination and whether it
is visible or not.

Application.Run is just a repeat until loop that keeps calling
HandleMessage until it sees Terminated set true.

++++++++++++++ Sample ++++++++++++++++++++

program fpidehelp;

uses
  Forms,
  help in 'help.pas' {BrowserForm},
  IDKSMdlg in 'IDKSMdlg.pas' {IDKSMDialog};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TBrowserForm, BrowserForm);
  Application.CreateForm(TIDKSMDialog, IDKSMDialog);
  Application.Run;
end.

++++++++++++++++++++++++++++++++++++++++++++
 
> in app.run I will start the gtk engine and load the forms then pass
> control to GTK main

I would be consistent with Delphi and have the project file actually
load the forms. I would suggest you turn on the gtk engine in
TApplication.Initialize. This again separates the graphics API from the
application. If you want to use a different engine you would just have
the Initalization routine point to a different engine to start.
 
> in app.halt I will just free the forms and give the kill signal to 
> gtk...

Actually you shouldn't need to call this. You will set the Terminate
variable to true which will stop the repeat loop in .Run. This will make
the application drop out of the program since the .Run call is followed
by "end.".

To get it to clean things up you use a finalize section in the
controls.pas unit that will call the clean up routines for the
application. This means no matter how the program is stopped the
finalization section should be called to clean up memory and what not.

In fact this is how Application gets created in the first place. You
create the Application object by call TApplication.Create in the
initialization section of the forms.pas unit.
 
> BTW can you pass me your make file and I will include it in the next
> upload..

It is attached.    :-)

I really didn't change much from what Peter submitted. I just added the
ifdef for XLIBDIR and GTKLIBDIR.

-- 
==== Programming my first best destiny! ====

Michael A. Hess      Miracle Concepts, Inc.
mhess at miraclec.com   http://www.miraclec.com

#
#   $Id: Makefile,v 1.1 1999/04/29 15:52:22 peter Exp $
#   Copyright (c) 1998 by the Free Pascal Development Team
#
#   Makefile for Lazarus
#
#   See the file COPYING.FPC, included in this distribution,
#   for details about the copyright.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#


#####################################################################
# Defaults
#####################################################################

# Default place of the makefile.fpc
DEFAULTFPCDIR=..

# Default unit dirs
NEEDUNITDIR=../fcl/$(OS_TARGET) ../gtk

# Where need we to place the executables/ppu/objects
TARGETDIR=.

# As default make only the units
#DEFAULTUNITS=1

# Linux only:
# Where are the X11 libraries ? 
XLIBDIR = /usr/X11/lib
# Where are the GTK libraries (if different from the X11 dir)
 GTKLIBDIR = /usr/local/lib

# add GCC directory to list of needed dirs.
NEEDGCCLIB=YES


#####################################################################
# Real targets
#####################################################################

UNITOBJECTS=
EXEOBJECTS=lazarus

ifdef XLIBDIR
override NEEDLIBDIR := $(NEEDLIBDIR) $(XLIBDIR)
endif
ifdef GTKLIBDIR
override NEEDLIBDIR := $(NEEDLIBDIR) $(GTKLIBDIR)
endif

#####################################################################
# Common targets
#####################################################################

.PHONY: all clean install info \
        staticlib sharedlib libsclean \
        staticinstall sharedinstall libinstall \
        
all: testfpcmake fpc_all

clean: testfpcmake fpc_cleanall

install: testfpcmake fpc_install

info: testfpcmake fpc_info

staticlib: testfpcmake fpc_staticlib

sharedlib: testfpcmake fpc_sharedlib

libsclean: testfpcmake fpc_libsclean

staticinstall: testfpcmake fpc_staticinstall

sharedinstall: testfpcmake fpc_sharedinstall

libinstall: testfpcmake fpc_libinstall


#####################################################################
# Include default makefile
#####################################################################

# test if FPCMAKE is still valid
ifdef FPCMAKE
ifeq ($(strip $(wildcard $(FPCMAKE))),)
FPCDIR=
FPCMAKE=
endif
endif

ifndef FPCDIR
ifdef DEFAULTFPCDIR
FPCDIR=$(DEFAULTFPCDIR)
endif
endif

ifndef FPCMAKE
ifdef FPCDIR
FPCMAKE=$(FPCDIR)/makefile.fpc
else
FPCMAKE=makefile.fpc
endif
endif

override FPCMAKE:=$(strip $(wildcard $(FPCMAKE)))
ifeq ($(FPCMAKE),)
testfpcmake:
	@echo makefile.fpc not found!
	@echo Check the FPCMAKE and FPCDIR environment variables.
	@exit
else
include $(FPCMAKE)
testfpcmake:
endif


#####################################################################
# Dependencies
#####################################################################

lazarus$(EXEEXT): $(wildcard *$(PASEXT))

#
# $Log: Makefile,v $
# Revision 1.1  1999/04/29 15:52:22  peter
#   + init
#
#





More information about the Lazarus mailing list