Bookstore

Recent

Author Topic: A Stupid? Question  (Read 494 times)

egsuh

  • Sr. Member
  • ****
  • Posts: 317
A Stupid? Question
« on: February 26, 2020, 03:05:18 am »
Currently I'm writing Lazarus projects on Windows PC. Are my sources compiled on Linux machine with little efforts?  I know this is what Lazarus pursue. Just want  to confirm.

dbannon

  • Hero Member
  • *****
  • Posts: 977
    • tomboy-ng, a rewrite of the classic Tomboy
Re: A Stupid? Question
« Reply #1 on: February 26, 2020, 03:08:51 am »
Most likely they will work fine on Linux and Mac.

In all OSs there are a few obscure things that are platform specific but in the unlikely event of you having used one of them, when the time comes, you work around them with {$ifdef WINDOWS} type of things.

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

af0815

  • Hero Member
  • *****
  • Posts: 502
Re: A Stupid? Question
« Reply #2 on: February 26, 2020, 07:57:35 am »
You have to know the differents of the OS and the widgets. Your Layouts can be different. Not all componnets works on all plattforms. You have to test tghis.

You can also crosscompile from Win to Linux and the other direction.



regards
Andreas

MoCityMM

  • Jr. Member
  • **
  • Posts: 73
Re: A Stupid? Question
« Reply #3 on: February 28, 2020, 11:11:44 am »
Most of my programming (which is limited...) is on *nix distros (so use of available widgets in my programs has been limited to a small subset) - all of them so far have worked fine.

As cautioned you have to know the distro differences, CentOS will use /usr/sbin while Ubuntu will use /usr/bin as generic example.

The only quirky thing I've noticed is widget placement on forms between Gnome/KDE in the design phase, a button on a form may look slightly out of position (just a hair) between the two. I started mocking up the forms on Windows and transferring to my CentOS vmware for coding - handled the issue.

Just my two cent addition.

Regards,
-Mo

wp

  • Hero Member
  • *****
  • Posts: 6830
Re: A Stupid? Question
« Reply #4 on: February 28, 2020, 11:22:44 am »
Some rules from my (small) experience:
  • Do not use OS-specific units. Use LCLIntf, LCLType etc instead.
  • Use the Anchor Editor and AutoSizing to layout forms. This guarantees that controls are not truncated or overlapped when the app runs on a different OS. However, it can be a nightmare sometimes to change an existing layout.
  • Be careful with third-party components. Lazarus recently has introduced some changes regarding high-dpi scaling of forms and images which must be adapted in the components. Otherwise components will not scale property.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

avra

  • Hero Member
  • *****
  • Posts: 1827
    • Additional info
Re: A Stupid? Question
« Reply #5 on: February 28, 2020, 11:51:31 am »
Are my sources compiled on Linux machine with little efforts?
You can go to ct2laz from my signature, take a look at the sources and see it yourself. It is developed on windows and then cross compiled to linux. Native compilation on linux also works. Cross compilation from linux to windows works, too. So you can cross compile or native compile, and target any supported architecture. There are some rules you should follow, but it is not hard at all. If you want a cross compiler you have to build it on your own since it does not come out of the box, or go the easy way with fantastic fpcupdeluxe tool which automates that all for you.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib