As far as I can tell, Lazarus for Windows installs and runs well under Wine. The problems began when I tried to add the Indy or Lnet packages, when I received the error "componenttreeview.pas not found" and the executable for Lazarus was gone. The solution was to recompile Lazarus from comand line like this:
1. Open Q4wine and run winconsole
2. Go to directory where Lazarus is installed (cd c:\lazarus in my case)
3. Type the following command and hit enter
lazbuild.exe --build-ide=-dKeepInstalledPackages
This should be it
I am using LINUX as OS and Lazarus for programming. Here are some issues I came across and the solutions I have found. I hope someone will find my posts useful... PS: A lot of credit goes to Linux/OpenSUSE/Lazarus community. Any suggestions, questions, observations or comments are welcomed!
duminică, 15 septembrie 2013
FreePascal: Indy - FTP
How to use Indy FTP on FreePascal/Lazarus:
1) Place a TIdFTP component on your form (logic :-) ) from "Indy Client Protocol (am)"
2) Place a TIdAntiFreeze component on your form from "Indy Misc (Core)"
3) Go to Project>Project Options>Compiler Options>Paths and add from Indy Package the directory "Lazarus" (in my case, "Paths" should look like this: ../indy-10.2.0.3/fpc;../indy-10.2.0.3/lazarus), otherwise you will receive the error "AntiFreeze.pas not found"
4) Configure FTP client with at least the following parameters:
- Host (yourftpsite.com or whatever that is)
- Username (your username, like username@yourftpsite.com)
- Password (your pasword)
- TransferType - FtBinary
- Pasive - True
- PasiveUserControlHost - True
Configuration may be different for specific ftp sites, but that's what worked for mine
5) A simple piece of code for upload files:
iftp1.Connect;
iftp1.Put('file1.txt');
iftp1.Put('file2.txt');
iftp1.Disconnect;
6) A simple piece of code for download files
iftp1.Connect;
iftp1.Get('file1.txt','file1.txt',true);
iftp1.Get('file1.txt','file2.txt',true);
iftp1.Disconnect;
Note:
- "true" in GET command is for overwrite
- Linux is case sensitive, so be careful how do you refer to your files
- Your Firewall settings may interfere, so be careful to that too
1) Place a TIdFTP component on your form (logic :-) ) from "Indy Client Protocol (am)"
2) Place a TIdAntiFreeze component on your form from "Indy Misc (Core)"
3) Go to Project>Project Options>Compiler Options>Paths and add from Indy Package the directory "Lazarus" (in my case, "Paths" should look like this: ../indy-10.2.0.3/fpc;../indy-10.2.0.3/lazarus), otherwise you will receive the error "AntiFreeze.pas not found"
4) Configure FTP client with at least the following parameters:
- Host (yourftpsite.com or whatever that is)
- Username (your username, like username@yourftpsite.com)
- Password (your pasword)
- TransferType - FtBinary
- Pasive - True
- PasiveUserControlHost - True
Configuration may be different for specific ftp sites, but that's what worked for mine
5) A simple piece of code for upload files:
iftp1.Connect;
iftp1.Put('file1.txt');
iftp1.Put('file2.txt');
iftp1.Disconnect;
6) A simple piece of code for download files
iftp1.Connect;
iftp1.Get('file1.txt','file1.txt',true);
iftp1.Get('file1.txt','file2.txt',true);
iftp1.Disconnect;
Note:
- "true" in GET command is for overwrite
- Linux is case sensitive, so be careful how do you refer to your files
- Your Firewall settings may interfere, so be careful to that too
miercuri, 22 mai 2013
ZenGL / FPC / OpenSuSE
In order to create a small project (it will have it's own blog or page when or if it will work) I needed an OpenGl package and I selected ZenGL. The problem was that when I tried to compile the ZenGL package I was stuck with "Error while linking". The solution was to install the following packages trough YaST:
Mesa-devellibXrabdr-devel
lxrandr
glu-devel
Everything you may need: zengl.org
sâmbătă, 9 martie 2013
OpenSUSE 12.2 svn / subversion
As far as I can tell, svn is a package used for software developement. It is not installed by default, so if you need a command line that starts with svn, you neef to install these package first. It can be easily obtained here:
http://software.opensuse.org/download.html?project=devel:tools:scm:svn&package=subversion
http://software.opensuse.org/download.html?project=devel:tools:scm:svn&package=subversion
joi, 21 februarie 2013
FreePascal/Lazarus - size of executable file
After compiling with Lazarus, the executable file is VERY large. To reduce it's size, I did the following:
Linux (OpenSUSE)
1) Install upx package if you don't have it (YaST > Software Management > Search for upx and install)
2) Open terminal (in Dolphin, right-click > Actions > Open terminal here)
3) Run the following commands:
strip --strip-all Program (! Linux is case sensitive)
upx -9 Program (! Linux is case sensitive)
The size of "Program" was reduced from 21580 KB to 1276 KB
"Program" is the name of the executable file in my case
And beacause Lazarus is cross-platform...
Windows (W7)
1) Start command prompt
2) Move to the application's directory (in my case: cd c:\Program\)
3) Run the following commands:
strip --strip-all program.exe
upx -9 program.exe
The size of "program.exe" was reduced from 14405 KB to 613 KB
Linux (OpenSUSE)
1) Install upx package if you don't have it (YaST > Software Management > Search for upx and install)
2) Open terminal (in Dolphin, right-click > Actions > Open terminal here)
3) Run the following commands:
strip --strip-all Program (! Linux is case sensitive)
upx -9 Program (! Linux is case sensitive)
The size of "Program" was reduced from 21580 KB to 1276 KB
"Program" is the name of the executable file in my case
And beacause Lazarus is cross-platform...
Windows (W7)
1) Start command prompt
2) Move to the application's directory (in my case: cd c:\Program\)
3) Run the following commands:
strip --strip-all program.exe
upx -9 program.exe
The size of "program.exe" was reduced from 14405 KB to 613 KB
miercuri, 6 februarie 2013
FreePascal: OS detection, system shutdown
I love music. Sometimes I listen to music till I fall asleep, so I need a program that can shut down the computer for me after a while. And because not everybody is using Linux, a cross-platform program would be nice :-)
Problems solved:
- a function that returns the OS
- a way to interact with the OS - in my case, sending a simple command (like shutdown)
Once again, many thanks to the Lazarus/FPC community!
The program was tested on OpenSUSE 12.2 and Windows 7. If someone can give the solution for Mac or other OS, he's welcomed!
You need:
- 1 Form :-)
- 1 SpeedButton
- 2 Labels
- 1 Edit
- 1 Timer
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, ExtCtrls, process;
type
{ TForm1 }
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
SpeedButton1: TSpeedButton;
Timer1: TTimer;
procedure FormShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
timp: integer;
MyOS: string;
Comanda: tprocess;
function OSVersion: String;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
try
timp:=strtoint(edit1.Text);
label2.Caption:=edit1.Text;
timer1.Enabled:=true;
except
showmessage('Eroare!');
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
timp:=timp-1;
label2.Caption:=inttostr(timp);
if timp=0 then
begin
if MyOS='Linux' then comanda.CommandLine:='/sbin/shutdown';
if MyOS='Windows' then comanda.CommandLine:='shutdown -s -t 0';
comanda.Execute;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
MYOS:=osversion;
form1.Caption:=MYOS;
timp:=30;
label1.Caption:='Minute';
Label2.Caption:='30';
edit1.Text:='30';
comanda:=tprocess.Create(nil);
timer1.Interval:=60000;
end;
function OSVersion: String;
var
osErr: integer;
response: longint;
begin
{$IFDEF LCLcarbon}
OSVersion := 'MacOS';
{$ELSE}
{$IFDEF Linux}
OSVersion := 'Linux';
{$ELSE}
{$IFDEF UNIX}
OSVersion := 'Unix';
{$ELSE}
{$IFDEF WINDOWS}
OSVersion:= 'Windows';
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
end;
end.
[UPDATE]
The program worked fine in OpenSUSE 12.2, but 12.3 required root privileges to shutdown the computer. So, a procedure must be rewritten:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
timp:=timp-1;
label2.Caption:=inttostr(timp);
if timp=0 then
begin
if MyOS='Linux' then
begin
comanda.Executable:='/bin/sh';
comanda.Parameters.Add('-c');
comanda.Parameters.Add('echo '+parola+' | sudo -S /sbin/shutdown -h now');
comanda.Execute;
end;
if MyOS='Windows' then
begin
comanda.CommandLine:='shutdown -s -t 0';
comanda.Execute;
end;
end;
end;
'parola' is a variable that can be supplied in different ways (I used a TEdit component)
[UPDATE]
I've made the source code available here:
https://www.dropbox.com/sh/d5bw7h3j33vmu5t/AAARZeUlm4pvHHJwnqUEn4Jqa?dl=0
Problems solved:
- a function that returns the OS
- a way to interact with the OS - in my case, sending a simple command (like shutdown)
Once again, many thanks to the Lazarus/FPC community!
The program was tested on OpenSUSE 12.2 and Windows 7. If someone can give the solution for Mac or other OS, he's welcomed!
You need:
- 1 Form :-)
- 1 SpeedButton
- 2 Labels
- 1 Edit
- 1 Timer
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, ExtCtrls, process;
type
{ TForm1 }
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
SpeedButton1: TSpeedButton;
Timer1: TTimer;
procedure FormShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
timp: integer;
MyOS: string;
Comanda: tprocess;
function OSVersion: String;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
try
timp:=strtoint(edit1.Text);
label2.Caption:=edit1.Text;
timer1.Enabled:=true;
except
showmessage('Eroare!');
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
timp:=timp-1;
label2.Caption:=inttostr(timp);
if timp=0 then
begin
if MyOS='Linux' then comanda.CommandLine:='/sbin/shutdown';
if MyOS='Windows' then comanda.CommandLine:='shutdown -s -t 0';
comanda.Execute;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
MYOS:=osversion;
form1.Caption:=MYOS;
timp:=30;
label1.Caption:='Minute';
Label2.Caption:='30';
edit1.Text:='30';
comanda:=tprocess.Create(nil);
timer1.Interval:=60000;
end;
function OSVersion: String;
var
osErr: integer;
response: longint;
begin
{$IFDEF LCLcarbon}
OSVersion := 'MacOS';
{$ELSE}
{$IFDEF Linux}
OSVersion := 'Linux';
{$ELSE}
{$IFDEF UNIX}
OSVersion := 'Unix';
{$ELSE}
{$IFDEF WINDOWS}
OSVersion:= 'Windows';
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
end;
end.
[UPDATE]
The program worked fine in OpenSUSE 12.2, but 12.3 required root privileges to shutdown the computer. So, a procedure must be rewritten:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
timp:=timp-1;
label2.Caption:=inttostr(timp);
if timp=0 then
begin
if MyOS='Linux' then
begin
comanda.Executable:='/bin/sh';
comanda.Parameters.Add('-c');
comanda.Parameters.Add('echo '+parola+' | sudo -S /sbin/shutdown -h now');
comanda.Execute;
end;
if MyOS='Windows' then
begin
comanda.CommandLine:='shutdown -s -t 0';
comanda.Execute;
end;
end;
end;
'parola' is a variable that can be supplied in different ways (I used a TEdit component)
[UPDATE]
I've made the source code available here:
https://www.dropbox.com/sh/d5bw7h3j33vmu5t/AAARZeUlm4pvHHJwnqUEn4Jqa?dl=0
duminică, 20 ianuarie 2013
Setting the time (OpenSUSE 12.2)
I don't want to set time to UTC. If I let it set to UTC, it is 2 hours in advance. I unchecked the box in YaST - System - Date and Time - "Hardware clock set to UTC", but it works only until restart or until update. For me the solution was the following command written in Terminal (of course, you need root permission, so type "sudo su" first):
sudo echo -e "0.0 0 0.0\n0\nLOCAL" > /etc/adjtime
Google Earth crashes (OpenSUSE 12.2)
Google Earth crashes on OpenSUSE 12.2. For me, the solution was to delete the following files:
/etc/fonts/conf.d/11-suse-hinting.conf
/etc/fonts/conf.d/65-fonts-persian.conf
Of course, you must have root access. OpenSUSE 12.2 has a Super User mode for File Manager (Applications - System - File Manager) which makes things easier
/etc/fonts/conf.d/11-suse-hinting.conf
/etc/fonts/conf.d/65-fonts-persian.conf
Of course, you must have root access. OpenSUSE 12.2 has a Super User mode for File Manager (Applications - System - File Manager) which makes things easier
Abonați-vă la:
Postări (Atom)