You use cthreads in unit where your form is. That is not main project LPR file.
Indeed. In a recent project I implemented a thread and it compiles and runs fine on both Windows 32/64 and Linux 64. In the lpr file the following uses clause is included:
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, umain, LazSerialPort
{ you can add units after this };
As you can see it is placed BEFORE the others. Then in the main form's unit a thread class is defined:
unit umain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
Math, LazSerial, DateUtils, FileUtil, LazSysUtils;
type
TReadDataThread = class(TThread)
private
procedure UpdateList;
protected
procedure Execute; override;
public
constructor Create(CreateSuspended: boolean);
end;
{ TForm1 }
...
Works like a charm, but you have to read some documentation in order to implement it properly. Especially interface related stuff should be done separately (in my example this is done by calling Synchronize(@UpdateList); from the Execute procedure.