RTC Forums
November 25, 2024, 02:50:06 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Installation issues - FPC/Lazarus on OSX  (Read 7566 times)
Kevin Powick
RTC Expired
*
Posts: 87


« on: April 29, 2010, 05:22:57 PM »

I managed to get the latest version of the RTC SDK installed into Lazarus/FPC for Windows, but have run into a problem with my Mac (OSX 10.6.3).

During compilation of the unit rtcConn, I get several error messages stating
 
Error: Generating PIC, but reference is not PIC-safe

I've searched Google and various sites, but cannot find much information on this error, though it does seem to have something to do with assembler code, as seen in the screenshot below.

Any ideas would be appreciated.

Has anyone got the RtcSDK installed into Lazarus on OSX, or even Linux?

Logged

Linux is only free if your time is worthless
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: April 29, 2010, 05:57:21 PM »

Thanks for your feedback, Kevin.

I've changed a few functions in the rtcConn unit to use ASM instead of critical sections a few versions back and it looks like I will need to revert to the original implementation to keep that code cross-platform. It's only a few very short functions and these are only used to count the number of active connections.

You might be able to get the code to compile if you can find in which unit FPC has "InterlockedIncrement" and "InterlockedDecrement" functions implemented. "LOCK INC" is the equivalent of "InterlockedIncrement" and "LOCK DEC" is the equivalent of "InterlockedDecrement". Otherwise, create a single global critical section object for the rtcConn unit and enclose the functions where LOCK INC or LOCK DEC is used within that critical section, then replace LOCK INC with a simple Inc() function and LOCK DEC with a simple Dec() function.

Let me know if you can get this compiled or if you need more help.

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #2 on: April 29, 2010, 06:07:07 PM »

Ok, here is the solution. First, replace all the lines in the "rtcConn.pas" unit from "implementation" up to  { TRtcConnection } with this code ...

Code:
implementation

type
  TRtcBaseServerClass = class of TRtcServer;

var
  ConnCS:TRtcCritSec;
  ServerConnection_Count:longint=0;
  ClientConnection_Count:longint=0;
  TotalConnection_Count:longint=0;

function ClientConnection_Open(Force:boolean=False):boolean;
  begin
  Result:=False;
  if not assigned(ConnCS) then Exit;

  {$IFDEF MEMCONTROL}
  if Get_MemoryInUse>=RTC_MEMORY_LIMIT then
    begin
    if Force then
      begin
      ConnCS.Acquire;
      try
        Inc(ClientConnection_Count);
        Dec(TotalConnection_Count);
      finally
        ConnCS.Release;
        end;
      end
    else
      raise EClientLimitReached.Create('Memory limit reached.')
    end
  else
  {$ENDIF}
  if TotalConnection_Count>=RTC_CONNECTION_LIMIT then
    begin
    if Force then
      begin
      ConnCS.Acquire;
      try
        Inc(ClientConnection_Count);
        Inc(TotalConnection_Count);
      finally
        ConnCS.Release;
        end;
      end
    else
      raise EClientLimitReached.Create('Total connection limit reached.')
    end
  else if ClientConnection_Count>=RTC_CLIENT_CONNECT_LIMIT then
    begin
    if Force then
      begin
      ConnCS.Acquire;
      try
        Inc(ClientConnection_Count);
        Inc(TotalConnection_Count);
      finally
        ConnCS.Release;
        end;
      end
    else
      raise EClientLimitReached.Create('Client connection limit reached.');
    end
  else
    begin
    ConnCS.Acquire;
    try
      Inc(ClientConnection_Count);
      Inc(TotalConnection_Count);
    finally
      ConnCS.Release;
      end;
    Result:=True;
    end;
  end;

procedure ClientConnection_Close;
  begin
  if not assigned(ConnCS) then Exit;

  ConnCS.Acquire;
  try
    Dec(ClientConnection_Count);
    Dec(TotalConnection_Count);
  finally
    ConnCS.Release;
    end;
  end;

procedure ServerConnection_CanAccept;
  begin
  if not assigned(ConnCS) then
    raise EClientLimitReached.Create('Terminating.');

  {$IFDEF MEMCONTROL}
  if Get_MemoryInUse>=RTC_MEMORY_LIMIT then
    raise EClientLimitReached.Create('Memory limit reached.')
  else
  {$ENDIF}
  if TotalConnection_Count>=RTC_CONNECTION_LIMIT then
    raise EClientLimitReached.Create('Total connection limit reached.')
  else if ServerConnection_Count>=RTC_SERVER_ACCEPT_LIMIT then
    raise EClientLimitReached.Create('Server connection limit reached.');
  end;

procedure ServerConnection_Accept;
  begin
  if not assigned(ConnCS) then
    raise EClientLimitReached.Create('Closing application.');

  ConnCS.Acquire;
  try
    Inc(ServerConnection_Count);
    Inc(TotalConnection_Count);
  finally
    ConnCS.Release;
    end;
  end;

procedure ServerConnection_Close;
  begin
  if not assigned(ConnCS) then
    Exit;

  ConnCS.Acquire;
  try
    Dec(ServerConnection_Count);
    Dec(TotalConnection_Count);
  finally
    ConnCS.Release;
    end;
  end;

{ TRtcConnection }

Then, add the following lines at the end of the "rtcConn.pas" unit ...

Code:
initialization
ConnCS:=TRtcCritSec.Create;
finalization
FreeAndNil(ConnCS);

That should fix the problem.

If you bump into any other issues, please let me know.

Best Regards,
Danijel Tkalcec
Logged
Kevin Powick
RTC Expired
*
Posts: 87


« Reply #3 on: April 29, 2010, 06:25:08 PM »

I've changed a few functions in the rtcConn unit to use ASM instead of critical sections a few versions back and it looks like I will need to revert to the original implementation to keep that code cross-platform.

It's funny that FPC on Windows handles this OK, since I'm compiling the exact same code.  I thought ASM code was processor, not operating system, specific?

Regards,
Logged

Linux is only free if your time is worthless
Kevin Powick
RTC Expired
*
Posts: 87


« Reply #4 on: April 29, 2010, 06:26:36 PM »

Ok, here is the solution

Thanks, Danijel.

I will try it out later tonight, when I have some free time to get back into the project.  I'll report back when I know the results.

Regards,
Logged

Linux is only free if your time is worthless
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #5 on: April 29, 2010, 06:29:54 PM »

ASM is processor-specific. It has nothing to do with the OS. Are you using a new Intel-based Mac or one of the older PowerPC versions?

Regards,
Danijel
Logged
Kevin Powick
RTC Expired
*
Posts: 87


« Reply #6 on: April 29, 2010, 06:43:14 PM »

Are you using a new Intel-based Mac or one of the older PowerPC versions?

I am using an Intel-based Mac.  That's why I thought it was odd that FPC didn't compile the unit's ASM code.  Actually, the Lazarus/FPC install on Windows XP that compiled the RTC SDK without issues is running on the same Mac, but in a VM.

FYI: The code changes you posted above did work, and I now have the RTC SDK installed into Lazarus on my Mac. Grin

Regards,
Logged

Linux is only free if your time is worthless
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #7 on: April 29, 2010, 06:50:06 PM »

FYI: The code changes you posted above did work, and I now have the RTC SDK installed into Lazarus on my Mac. Grin
Great Smiley Thanks for your feedback.

PS. I have included these changes for the next RTC SDK build, but I am in the middle of something else, so I won't be releasing it yet.

Regards,
Danijel
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #8 on: May 05, 2010, 08:30:32 AM »

FYI: RealThinClient SDK *Beta* Build 384 (released as a "nightly build" yesterday) includes the above changes and should compile with FPC/Lazarus on MacOSX without modifications.

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.028 seconds with 17 queries.