[SOLVED] If I switch to Linux lazarus / 66-Unix ---------------------------------------------------------------------- Ten_Mile_Hike · 2024-05-22 19:11 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 ---------------------------------------------------------------------- PascalDragon · 2024-05-22 19:19 Quote from: Ten_Mile_Hike on May 22, 2024, 09:11:04 pmAs 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 · 2024-05-22 19:34 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. ---------------------------------------------------------------------- dsiders · 2024-05-22 20:01 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). ---------------------------------------------------------------------- Curt Carpenter · 2024-05-22 21:04 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 · 2024-05-22 22:14 Quote from: Curt Carpenter on May 22, 2024, 11:04:49 pmI 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. ---------------------------------------------------------------------- Handoko · 2024-05-23 04:34 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.h tml#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.h tml#msg488938 ---------------------------------------------------------------------- Thaddy · 2024-05-23 05:04 Quote from: Handoko on May 23, 2024, 06:34:08 amWindows 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fsutil.exe file SetCaseSensitiveInfo C:\folder\path enableThe 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 ---------------------------------------------------------------------- Thaddy · 2024-05-23 05:43 Quote from: dsiders on May 22, 2024, 10:01:37 pmOpenSSL3 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) ---------------------------------------------------------------------- TRon · 2024-05-23 05:44 Quote from: Thaddy on May 23, 2024, 07:04:39 amThis 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. ---------------------------------------------------------------------- Thaddy · 2024-05-23 06:05 @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, ---------------------------------------------------------------------- Aistis · 2024-05-23 06:22 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 librariestrial 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. ---------------------------------------------------------------------- cdbc · 2024-05-23 06:26 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  Regards Benny ---------------------------------------------------------------------- TRon · 2024-05-23 07:41 Quote from: Ten_Mile_Hike on May 22, 2024, 09:11:04 pmSo 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. QuoteI 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. QuoteAlso; 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_know n_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. ---------------------------------------------------------------------- Dzandaa · 2024-05-23 17:28 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-> ---------------------------------------------------------------------- Handoko · 2024-05-23 17:55 Quote from: Thaddy on May 23, 2024, 07:04:39 amQuote from: Handoko on May 23, 2024, 06:34:08 amWindows 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fsutil.exe file SetCaseSensitiveInfo C:\folder\path enableThe 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 never knew about it. Thank you for the correction. ---------------------------------------------------------------------- dsiders · 2024-05-23 18:09 Quote from: Thaddy on May 23, 2024, 07:43:48 amQuote from: dsiders on May 22, 2024, 10:01:37 pmOpenSSL3 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) That's the only thing that hasn't been a simple recompile. I'm not using anything other than the http client in fcl-net to do https: requests. So far, all it does is raise an exception on linux. Works fine on Windows. And yes, my linux box has OpenSSL installed. When I get a chance to tinker some more this weekend, I'll figure it out. But so far... no go. ---------------------------------------------------------------------- dsiders · 2024-05-23 19:16 I didn't have to wait for the weekend. OpenSSL3 support is not available in FPC 3.2.2. It is enabled in 3.3.X though. See openssl.pas DLLVersions constant. ---------------------------------------------------------------------- Thaddy · 2024-05-23 19:21 Yeah, I might have used my own code indeed. But trunk supports it and I hope it is a candidate for back-porting. This is really an issue and it did not come up for the first time. Then again: programmers that write out of date code are plainly ready to get fired. (when was the last time I used so many? can't remember) It is not for nothing that I write so many comments when it is about security: it was my job and I care for it. Pensionado or not. ---------------------------------------------------------------------- Thaddy · 2024-05-23 19:57 Quote from: Dzandaa on May 23, 2024, 07:28:55 pmfor example, the default text font is different and I have to adjust the size of the buttons. That would be also the case on Windows if the font is not installed..... That is lame and ill informed. Simply copy your Windows fonts to the Linux font directory.  (/usr/share/fonts usually, make sure you know the font format and copy to the correct subdir. This is not necessary, but keeps the lot clean) ---------------------------------------------------------------------- Thaddy · 2024-05-24 04:44 Forgot that the better option is probably to simply include the font as a resource. Then it always works. ---------------------------------------------------------------------- dbannon · 2024-05-24 07:36 So Ten_Mile_Hike, a summary - If your code is currently written using Lazarus's excellent cross platform approach, no problems. But look for - Units that have "windows" in the uses clause, comment out that unit name and see what does not compile. Code that assumes use of cr/lf at the end of a line, use the correct LineEnding, AppendPathDelim() etc.  The various file handling methods don't particularly care but you probably play with a file's content at some stage. If your code is careless with case of filename, eg assuming MyFile.txt is the same as myfile.txt, that could well be a issue. There will possible be some low level (graphics) things that only testing will reveal. When choosing a Linux to install, avoid a distro / desktop combo that uses Wayland (its not ready yet). That means don't use Gnome of KDE at present, sadly they are the default for many distros. Use a desktop such as Mate, Cinnamon, Xfce if possible. That said, Gnome and KDE will work OK for many users. Sadly, if you use openssl (eg https downloads etc) you will need to use a FPC Fixes, not the official release version.Quote from: Thaddy on May 23, 2024, 09:21:51 pmIt is not for nothing that I write so many comments when it is about security: it was my job and I care for it. Pensionado or not. And you did not know that the official release version of FPC does not work with OpenSSL3 on Linux (*) ? Make you think ..... Quote from: TRonQuote from: Thaddy    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 ? I enjoyed that one ! Davo * OpenSSL 3.0 and FPC322 Will work on your own system if you have the OpenSSL Dev package installed, thats because FPC looks for the the unversioned version (symlink) if it cannot find one of the versions hard wired in. So far, my app seems to work like that, yours may not. Further, no one wants to ship an application that requires the end user to install a dev library. And none (?) of the Linux distros will ship (or build with) a non-release compiler. EDIT: Typo ---------------------------------------------------------------------- dsiders · 2024-05-24 14:31 Quote from: dbannon on May 24, 2024, 09:36:16 am When choosing a Linux to install, avoid a distro / desktop combo that uses Wayland (its not ready yet). That means don't use Gnome of KDE at present, sadly they are the default for many distros. Use a desktop such as Mate, Cinnamon, Xfce if possible. That said, Gnome and KDE will work OK for many users.I would not discourage use of Gnome or KDE... just use them with X11 instead of Wayland. In fact, I would avoid Mate, Cinnamon, and XFCE IMO. Quote from: dbannon on May 24, 2024, 09:36:16 am Sadly, if you use openssl (eg https downloads etc) you will need to use a FPC Fixes, not the official release version.* OpenSSL 3.0 and FPC322 Will work on your own system if you have the OpenSSL Dev package installed, thats because FPC looks for the the unversioned version (symlink) if it cannot find one of the versions hard wired in. So far, my app seems to work like that, yours may not. Further, no one wants to ship an application that requires the end user to install a dev library. And none (?) of the Linux distros will ship (or build with) a non-release compiler. Newer distros are shipping with OpenSSL3, so it's not a dev library any more (at least not with OpenSUSE). Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // HACK!!! until FPC 3.2.X is updated// use openssl version command to get your installed version number... mine is 3.1.4openssl.DLLVersions[1] := '.3';openssl.DLLVersions[2] := '.3.1';openssl.DLLVersions[3] := '.3.1.4';  [Edit] Added missing 's'es. ---------------------------------------------------------------------- dsiders · 2024-05-24 14:41 QuoteAnd you did not know that the official release version of FPC does not work with OpenSSL3 on Linux (*) ? Actually, FPC 3.2.X doesn't support OpenSSL3 out-of-the-box anywhere... it's not just Linux. ---------------------------------------------------------------------- Thaddy · 2024-05-24 17:38 That is correct, but fixed. Iif you need it in 3.2.X I can give you a patch. Mind you, before asking, that a lot of code which uses out-of-date protocols will NOT work anymore. So if the protocol in your code is hardcoded as SSL/TLS1.0.... You are a moron. Don't complain about that: it is not an opinion but fact. ---------------------------------------------------------------------- dsiders · 2024-05-24 17:57 Quote from: Thaddy on May 24, 2024, 07:38:14 pmThat is correct, but fixed. Iif you need it in 3.2.X I can give you a patch. Mind you, before asking, that a lot of code which uses out-of-date protocols will NOT work anymore. So if the protocol in your code is hardcoded as SSL/TLS1.0.... You are a moron. Don't complain about that: it is not an opinion but fact. I don't need (or want) a patch for 3.2.2. I want a 3.2.4 release. ---------------------------------------------------------------------- Thaddy · 2024-05-24 19:11 Me too  , but if I can help you out, just ask. AFAIK the commits for OpenSSL3 do not rely on new features in trunk. ---------------------------------------------------------------------- dbannon · 2024-05-25 01:12 Quote from: dsiders on May 24, 2024, 04:31:51 pm Quote from: dbannon on May 24, 2024, 09:36:16 amWill work on your own system if you have the OpenSSL Dev package installed, .... Newer distros are shipping with OpenSSL3, so it's not a dev library any more (at least not with OpenSUSE). Sorry Don, I did not make myself clear. Linux systems have dev library packages that corresponds to library packages, they include extra things useful for developers, in practice, the important thing they provide is an unversioned  symlink to the actual library file. See - Code: [Select]$> sudo apt install openssl-dev .... ls -la /usr/lib/x86_64-linux-gnu/libssl.so* lrwxrwxrwx 1 root root     11 Oct 24  2023 /usr/lib/x86_64-linux- gnu/libssl.so -> libssl.so.3 -rw-r--r-- 1 root root 696352 Oct 24  2023 /usr/lib/x86_64-linux- gnu/libssl.so.3 Note the first one is a symlink and does not have a version number, its intended for use at (dynamic) link time, but FPC tries to open it at run time ! And, as I said, it works. But should not be relied on IMHO. Just making the symlink works just as well by the way but end users get scared .... QuoteCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // HACK!!! until FPC 3.2.X is updated// use openssl version command to get your installed version number... mine is 3.1.4openssl.DLLVersions[1] := '.3';openssl.DLLVersions[2] := '.3.1';openssl.DLLVersions[3] := '.3.1.4'; OK, that that would help with Windows, that would be good. But I had decided I was not willing to hack at the FPC.openssl, I'm not the security expert Thaddy is and when I looked at a diff of the two code sets, there were a lot more changes in the FPC-fixes version than just version numbers. Its not a very good situation, one that can only be fixed with a proper release of FPC ! Davo ---------------------------------------------------------------------- PascalDragon · 2024-05-26 20:26 Quote from: Thaddy on May 23, 2024, 07:04:39 amQuote from: Handoko on May 23, 2024, 06:34:08 amWindows file system is case insensitive but Linux file system is case sensitive. This is not true, NTFS is a case sensitive file system. The file system as a whole is a case preserving file system. Only because single directories can be switched to case sensitive does not make the file system as a whole case sensitive, just like Ext4's ability to make single directories case insensitive does not make it case insensitive as a whole. Quote from: Thaddy on May 23, 2024, 07:04:39 am 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fsutil.exe file SetCaseSensitiveInfo C:\folder\path enableThe 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  Important note: folders with enabled case sensitivity can not be accessed as network shares (or if the share is non-case sensitive then you can't enter such directories inside the share)! Quote from: Thaddy on May 23, 2024, 08:05:24 amA similar unkown on NTFS are sparse files, which are very useful, Or Alternate Data Streams 😍 At work we use them to store the PDB and MAP files generated by the MSVC compiler as part of the binary (our builds are then stored as WIM files which allows the storing of ADS as well)