Recent

Author Topic: 64 bit Windows/Linux Compilation  (Read 12013 times)

egrobler

  • New Member
  • *
  • Posts: 17
64 bit Windows/Linux Compilation
« on: September 22, 2009, 11:35:41 am »
Hallo Lazarus community,

I am new to Lazarus and I want to create a 64-bit search engine that will run either in windows or linux.
I just compiled my first win64 "hallo world" application and it reports the SizeOf(Pointer) as 8 bytes, so I am happy!

I would just like some pointers regarding the following:
- I assume that I need to compile the same code in a 64 bit linux OS to compile "cross platform"?
- What tcp/ip library should I use with Lazarus (I just need basic functionality)
- Is there a good guide on how to write portable code (linux/windows) in Free Pascal?

Thanks in advance
Eric

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2268
    • havefunsoft.com
Re: 64 bit Windows/Linux Compilation
« Reply #1 on: September 22, 2009, 12:27:18 pm »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

egrobler

  • New Member
  • *
  • Posts: 17
Re: 64 bit Windows/Linux Compilation
« Reply #2 on: September 22, 2009, 12:41:03 pm »
- Is there a good guide on how to write portable code (linux/windows) in Free Pascal?
http://wiki.lazarus.freepascal.org/Writing_portable_code_regarding_the_processor_architecture

Thanks skalogryyz,

I actually did come across that article.
If that is all I need to be concerned about then I am impressed - seems very easy!

But are all lazarus libraries 64-bit aware and works under all platforms?
What about visual controls?

Thanks and regards
Eric

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2268
    • havefunsoft.com
Re: 64 bit Windows/Linux Compilation
« Reply #3 on: September 22, 2009, 12:44:08 pm »
But are all lazarus libraries 64-bit aware and works under all platforms?
What about visual controls?
If you find any library or control, that doesn't work under 64-bit, then you need to report it as a bug at the mantis: bugs.freepascal.org

There were some 64-bit compatibility issues, but most of them have been fixed, in the mean time.

Carbon (MacOSX) library is 32-bit only, because of Apple limitations.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

egrobler

  • New Member
  • *
  • Posts: 17
Re: 64 bit Windows/Linux Compilation
« Reply #4 on: September 22, 2009, 12:51:31 pm »
But are all lazarus libraries 64-bit aware and works under all platforms?
What about visual controls?
If you find any library or control, that doesn't work under 64-bit, then you need to report it as a bug at the mantis: bugs.freepascal.org

There were some 64-bit compatibility issues, but most of them have been fixed, in the mean time.

Carbon (MacOSX) library is 32-bit only, because of Apple limitations.

Ok, thanks for the fast feedback.

Have a nice day
Eric

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: 64 bit Windows/Linux Compilation
« Reply #5 on: September 22, 2009, 03:52:15 pm »
- I assume that I need to compile the same code in a 64 bit linux OS to compile "cross platform"?
It's not that simple. Or actually it is if you remember about some differences in those systems. For instance Windows uses "\" in file paths while Linux uses "/". Neither Lazarus nor fpc will handle this so it is developer who must do that.
- What tcp/ip library should I use with Lazarus (I just need basic functionality)
Synapse or Indy. Both are working with Linux

egrobler

  • New Member
  • *
  • Posts: 17
Re: 64 bit Windows/Linux Compilation
« Reply #6 on: September 22, 2009, 04:12:43 pm »
Quote
It's not that simple. Or actually it is if you remember about some differences in those systems. For instance Windows uses "\" in file paths while Linux uses "/". Neither Lazarus nor fpc will handle this so it is developer who must do that.

Thanks for the feedback, is there a compiler directive I can use to determine if it is linux or windows?

Regards
Eric


Edit: fixed quote tag.
« Last Edit: September 23, 2009, 09:59:46 am by Vincent Snijders »

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: 64 bit Windows/Linux Compilation
« Reply #7 on: September 22, 2009, 04:59:14 pm »

It's not that simple. Or actually it is if you remember about some differences in those systems. For instance Windows uses "\" in file paths while Linux uses "/". Neither Lazarus nor fpc will handle this so it is developer who must do that.

Thanks for the feedback, is there a compiler directive I can use to determine if it is linux or windows?

Regards
Eric
[/quote]
{$IFDEF WINDOWS}
your Windows code
{$ELSE}
code for Linux
{$ENDIF}

instead of WINDOWS you can also use LINUX of course

egrobler

  • New Member
  • *
  • Posts: 17
Re: 64 bit Windows/Linux Compilation
« Reply #8 on: September 22, 2009, 05:04:56 pm »
Quote
{$IFDEF WINDOWS}
your Windows code
{$ELSE}
code for Linux
{$ENDIF}

instead of WINDOWS you can also use LINUX of course

Thanks!
« Last Edit: September 23, 2009, 10:00:08 am by Vincent Snijders »

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: 64 bit Windows/Linux Compilation
« Reply #9 on: September 22, 2009, 05:34:48 pm »
It's not that simple. Or actually it is if you remember about some differences in those systems. For instance Windows uses "\" in file paths while Linux uses "/". Neither Lazarus nor fpc will handle this so it is developer who must do that.
But you can use the consts "PathDelim" or "LineEnding" instead which are OS aware.

egrobler

  • New Member
  • *
  • Posts: 17
Re: 64 bit Windows/Linux Compilation
« Reply #10 on: September 22, 2009, 05:45:40 pm »
Quote
But you can use the consts "PathDelim" or "LineEnding" instead which are OS aware.

Thanks Theo, that is good to know...

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: 64 bit Windows/Linux Compilation
« Reply #11 on: September 22, 2009, 07:50:13 pm »
It's not that simple. Or actually it is if you remember about some differences in those systems. For instance Windows uses "\" in file paths while Linux uses "/". Neither Lazarus nor fpc will handle this so it is developer who must do that.
But you can use the consts "PathDelim" or "LineEnding" instead which are OS aware.
Those are constants. What with situation that for example someone generates some file path using Windows version (that is supposed to contain"/" so Windows version can process it properly) and then you export this string for example to file. Later you need to process it with Linux version so you can access some file with Linux version. Of course if given string we are talking about contains absolute path then there is no point but if it contains relative one it must be handled. And here is where platform specific code comes.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: 64 bit Windows/Linux Compilation
« Reply #12 on: September 23, 2009, 10:02:54 am »
And then it can be handled Platform independent using several SysUtils functions, for example SetDirSeparators.

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: 64 bit Windows/Linux Compilation
« Reply #13 on: September 23, 2009, 02:17:22 pm »
And since for example TFileStream doesn't call it you must call it manually before providing file path to TFileStream or actually at least most common classes using it such as TStringList for example