Recent

Author Topic: [SOLVED] If I switch to Linux  (Read 8202 times)

Ten_Mile_Hike

  • Jr. Member
  • **
  • Posts: 87
[SOLVED] If I switch to Linux
« on: May 22, 2024, 09:11:04 pm »
So I'm THINKING of switching from windows to Linux. As I have only ever used Windows and Lazarus under Windows, can anyone tell me what code (if any) is different or actually incompatible with my current Lazurus projects?

I KNOW THAT LAZARUS IS SUPPOSED TO BE CROSS PLATFORM, BUT I'M SIMPLY ASKING ABOUT THE LITTLE GOTCHAS AND EDGE CASES THAT HAVE BEEN KNOWN TO EXIST.

 Also; what manual edits (if any) are necessary in my( lpi, lpr,lfm,pas) files to compile and run an old WIN project under a Linux environment.

Thanks.

=========== EDIT May 24===========
Thank you everyone for the answers given. The quality and depth of the answers in this forum generally and to my
question here specifically are a testament to the commitment each and everyone of you have to helping others.

Have those of you that regularly post here ever "REALLY" sat back and thought about the fact that despite from being
from a multitude of different countries, speaking a dozen different primary languages, holding many different political beliefs,
and practicing many different religions (as well as none at all)... put all of those things aside to both ask and to give help
to each other?

In many ways we operate more peacefully, more effectively, and more efficiently than the United Nations.
And if that thought doesn't scare you then nothing will 8-) 8-) 8-)
« Last Edit: May 24, 2024, 08:06:22 pm by Ten_Mile_Hike »
When any government, or any church for that matter, undertakes to say to its subjects, This you may not read, this you
must not see, this you are forbidden to know, the end result is tyranny and oppression no matter how holy the motives.

Robert A. Heinlein

PascalDragon

  • Hero Member
  • *****
  • Posts: 5755
  • Compiler Developer
Re: If I switch to Linux
« Reply #1 on: May 22, 2024, 09:19:16 pm »
As I have only ever used Windows and Lazarus under Windows, can anyone tell me what code (if any) is different or actually incompatible with my current Lazurus projects?

Well, obviously if you use any Windows specific functionality you'll need to find alternatives or disable them. Obviously you'll also have to deal with the differences regarding the file system (drives in Windows, a single root on *nix systems).
And there might be differences in the way the UI behaves or scales compared to Windows.
In general it should indeed be cross platform however.

Thaddy

  • Hero Member
  • *****
  • Posts: 16164
  • Censorship about opinions does not belong here.
Re: If I switch to Linux
« Reply #2 on: May 22, 2024, 09:34:51 pm »
If you are on a decent Windows, 10 or 11 install e.g. Ubuntu on wsl2.
My advice is to try a Linux box first. That can be as cheap as a Raspberry Pi zero W2.
In general, unless you use very specific Windows API calls, FPC and Lazarus will work as advertised.
The only people who get bitten are the ones that think they know better.
If you have old laptops or other boxes around, use those first. Good place to start: Linux is very old hardware friendly.
« Last Edit: May 22, 2024, 09:40:10 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

dsiders

  • Hero Member
  • *****
  • Posts: 1282
Re: If I switch to Linux
« Reply #3 on: May 22, 2024, 10:01:37 pm »
After my two weeks with Linux...

Never install Lazarus from .deb provided by a distro. Install from source or use fpcupdeluxe.

Steer clear of Wayland for the moment. Too many gotchas for comfort. Use X11 instead.

There will be something about your chosen widgetset that doesn't work as expected. File bug reports.

OpenSSL3 and FPC 3.2.2 do not play well together (or at all).

Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 560
Re: If I switch to Linux
« Reply #4 on: May 22, 2024, 11:04:49 pm »
I worked on a moving a Win program to Linux last year.  There are definitely little differences that require work-arounds.  Best example that springs to mind:  Windows uses CR/LF line endings, where Linux uses LF only.  Nothing insurmountable though.

I abandoned Windows and Delphi around Win2000 and have never had any regrets.


dsiders

  • Hero Member
  • *****
  • Posts: 1282
Re: If I switch to Linux
« Reply #5 on: May 23, 2024, 12:14:16 am »
I worked on a moving a Win program to Linux last year.  There are definitely little differences that require work-arounds.  Best example that springs to mind:  Windows uses CR/LF line endings, where Linux uses LF only.  Nothing insurmountable though.

I abandoned Windows and Delphi around Win2000 and have never had any regrets.

Sounds familiar. I dropped Delphi a little later (2001).

I have 71 days until I can finally be free of Windows. Figured to get my feet wet with Linux before then.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

Handoko

  • Hero Member
  • *****
  • Posts: 5376
  • My goal: build my own game engine using Lazarus
Re: If I switch to Linux
« Reply #6 on: May 23, 2024, 06:34:08 am »
Yes, I ever had the CR/LF issue as mentioned by Curt Carpenter. I wrote code to read/save text file in Linux. But it worked 'weird' on Windows.
https://wiki.lazarus.freepascal.org/End_of_Line

Windows and Linux use different directory separator and path separator.
https://www.freepascal.org/docs-html/rtl/system/directoryseparator.html
https://www.freepascal.org/docs-html/rtl/system/pathseparator.html

Windows file system is case insensitive but Linux file system is case sensitive. In Linux, files with the names of unit1.pas and Unit1.pas are 2 different files and can be put together in a same folder.
https://www.freepascal.org/docs-html/rtl/system/filenamecasesensitive.html

Not all code written in Windows can be compiled to run on Linux. Especially if it has Windows in the uses clause. For example this code written by KodeZwerg:
https://forum.lazarus.freepascal.org/index.php/topic,67192.msg516603.html#msg516603

Even the same code that can be compiled both on Windows and Linux, it may behave differently. For example PixelFormat is treated differently by Windows and Linux. The code in the link below shows how I used conditional compilation to make it works the same on both Windows on Linux:
https://forum.lazarus.freepascal.org/index.php/topic,64159.msg488938.html#msg488938
« Last Edit: May 23, 2024, 07:21:44 am by Handoko »

Thaddy

  • Hero Member
  • *****
  • Posts: 16164
  • Censorship about opinions does not belong here.
Re: If I switch to Linux
« Reply #7 on: May 23, 2024, 07:04:39 am »
Windows file system is case insensitive but Linux file system is case sensitive.
This is not true, NTFS is a case sensitive file system. It is just that most of the File handling API's are case insensitive. The following must be run with administator rights:
Code: Bash  [Select][+][-]
  1. fsutil.exe file SetCaseSensitiveInfo C:\folder\path enable
The above command makes the contents of the folder and subfolders case sensitive.
See:
https://www.windowscentral.com/how-enable-ntfs-treat-folders-case-sensitive-windows-10

I use this on part of my development folders that are shared between Windows11 and a Debian on WSL2.
Note that the average Windows user has not enough discipline to work with a case sensitive system  :o

« Last Edit: May 23, 2024, 07:26:15 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Thaddy

  • Hero Member
  • *****
  • Posts: 16164
  • Censorship about opinions does not belong here.
Re: If I switch to Linux
« Reply #8 on: May 23, 2024, 07:43:48 am »
OpenSSL3 and FPC 3.2.2 do not play well together (or at all).
How? What code are you using? Synapse? fcl-net/web? Indy? Because fcl-net supports OpenSSL3 afaik and recent Indy too. In fact all my code uses OpenSSL3.
Problems only arise if you use deprecated protocols that have been removed from OpenSSL in version 3.
(SSL,SL2/3,TLS1.0)
« Last Edit: May 23, 2024, 07:45:19 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: If I switch to Linux
« Reply #9 on: May 23, 2024, 07:44:28 am »
This is not true, NTFS is a case sensitive file system. It is just that most of the File handling API's are case insensitive. The following must be run with administator rights:
You are ofc correct there Thaddy but don't you think that for those 0.0001% of users that knows about that, then do not know about the differences wrt programming between Windows and Linux ?

Most if not all (existing) Windows code is unable to handle filename case sensitivity properly simply because it is out of the ordinary, never had to deal with etc excuses.
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Thaddy

  • Hero Member
  • *****
  • Posts: 16164
  • Censorship about opinions does not belong here.
Re: If I switch to Linux
« Reply #10 on: May 23, 2024, 08:05:24 am »
@TRon
The feature is introduced to be able to share Linux and Windows better.
For developers / cross developers and for system administrators it is a powerful feature and they should know about it.
A similar unkown on NTFS are sparse files, which are very useful,
If I smell bad code it usually is bad code and that includes my own code.

Aistis

  • New Member
  • *
  • Posts: 17
    • Titbits of mind leakage
Re: If I switch to Linux
« Reply #11 on: May 23, 2024, 08:22:42 am »
I hop between Windows 10 and Linux Mint constantly. The basic Lazarus components work fine without much changes need, if any.

However, as I needed to use SDL2 as a form component because CPU rendering was too slow for my needs, I had for the first time to actually use compile time conditionals for GTK2 specific problems to get SDL2 running without issues on Linux.

I'm using the bare minimum of SDL2 just to draw a single texture to screen. SDL2 works auto-magically on Windows, but I needed to do some actual work on Linux to make it work properly.
  • acquiring the pointer needed for SDL_CreateWindowFrom() was more complex and needed GTK2 specific libraries
  • trial and error to discover that TOpenGLControl works best as an SDL2 window (while on Windows a simple TPanel works just fine)
  • OnPaint doesn't work (?) on TOpenGLControl when calling Invalidate(), I only managed to make it work by assigning its Parent an OnPaint event while also being forced to call Invalidate() on said Parent (but both OnPaint and Invalidate() work on TOpenGLControl in Windows, go figure)
  • having to manually call SDL_SetWindowSize() for proper control resizing (happens auto-magically in Windows)

As it was mentioned above, try out Linux in either a VM (just make sure hardware acceleration is actually on as some Windows settings prevented it for me on VirtualBox despite having proper BIOS settings set) or just install it on some other computer. Or you could dual-boot if you're sure you won't mess something up on your Windows install while installing Linux.
« Last Edit: May 23, 2024, 08:34:48 am by Aistis »

cdbc

  • Hero Member
  • *****
  • Posts: 1649
    • http://www.cdbc.dk
Re: If I switch to Linux
« Reply #12 on: May 23, 2024, 08:26:57 am »
Hi
*When* you switch to Linux  ;)
I'd say, the tools to handle said differences, "LF - CR/LF" etc., are pretty much all there in FPC & Lazarus, it's just a matter of using them e.g. "LineEnding".
One top-tip has to be:
Get yourself acquainted with the *nix command-line interface, using it can make so many things easier for you  8-)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: If I switch to Linux
« Reply #13 on: May 23, 2024, 09:41:14 am »
So I'm THINKING of switching from windows to Linux. As I have only ever used Windows and Lazarus under Windows, can anyone tell me what code (if any) is different or actually incompatible with my current Lazurus projects?
If you were a good citizen then you already made your code platform independent.

Quote
I KNOW THAT LAZARUS IS SUPPOSED TO BE CROSS PLATFORM, BUT I'M SIMPLY ASKING ABOUT THE LITTLE GOTCHAS AND EDGE CASES THAT HAVE BEEN KNOWN TO EXIST.
The most important things to take care of were already addressed by others.

Quote
Also; what manual edits (if any) are necessary in my( lpi, lpr,lfm,pas) files to compile and run an old WIN project under a Linux environment.
Again, if you are a good citizen then your code was already platform agnostic.

See also https://wiki.freepascal.org/Multiplatform_Programming_Guide and https://wiki.freepascal.org/Introduction_to_platform-sensitive_development

Also take note of: https://wiki.freepascal.org/Roadmap

Having said that, there are some differences between platforms that will never be solved see also https://wiki.freepascal.org/Lazarus_known_issues_(things_that_will_never_be_fixed)

edit pathetic forum software...
Code: [Select]
https://wiki.freepascal.org/Lazarus_known_issues_(things_that_will_never_be_fixed)

My main issue with switching from Windows to Linux was the fact that I had to miss my trusty tools for which Linux does not have good alternatives (programmers notepad, Olly, PE explorer, Altap etc). There are alternatives but nearly not as good and that takes time to getting used to.

The suggestion to use something like WSL is a good one so that you can profit from both worlds.
« Last Edit: May 23, 2024, 11:01:58 am by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Dzandaa

  • Sr. Member
  • ****
  • Posts: 389
  • From C# to Lazarus
Re: If I switch to Linux
« Reply #14 on: May 23, 2024, 07:28:55 pm »
Hi,

I write my programs to be compatible with Windows, Linux and even MacOS.

Avoid to use specific library like DirectX, etc...

Use the distribution from Lazarus site, not from the repository.

I use Linux Mint, with Cinnamon.

Easy to install, download the 3 files.

Install FPC, the FPC sources, then the GUI just by clicking on it (on Linux Mint).


Most of the time, I just have to modify the look of the Windows, for example, the default text font is different and I have to adjust the size of the buttons.

Many library are compatible with both OS.

For me, just a plus for Linux, the 5DPO library that I use to capture and detect objects for a video source.


B->
Regards,
Dzandaa

 

TinyPortal © 2005-2018