duminică, 15 septembrie 2013

Lazarus and Wine

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

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