Recent

Author Topic: I want to port my LDL project to freepascal  (Read 819 times)

JordanCpp

  • New member
  • *
  • Posts: 8
I want to port my LDL project to freepascal
« on: January 24, 2026, 09:24:03 am »
Greetings.

My project is LDL.
https://github.com/JordanCpp/LDL

I'm creating a library that works on both new and old PCs. However, I realize that when developing in C++, I spend a lot of time configuring the library's build for older systems. Freepascal supports a wide range of architectures and operating systems. I would like to rewrite the project in freepascal and create bindings for C and C++. However, I have a question for you. Can I create dll/so for old windows 95, 98, me and linux debian 3 and above, and kade dos 16/32. Will it work?


Is it necessary to make a great effort to support old hardware by developing a single code in freepascal?

Thank you for your answers.

Boleeman

  • Hero Member
  • *****
  • Posts: 1106
Re: I want to port my LDL project to freepascal
« Reply #1 on: January 24, 2026, 02:44:25 pm »
Hi JordanCpp.

Today I came across:

Explanation and example, how to use shared libraries in different languages
https://github.com/jakobsche/polynomial

Hopefully it can help you out.

I have not really done this sort of stuff, except for playing around with helper functions for the Lazarus bindings for C PlutoSvg (on Github as well).

JordanCpp

  • New member
  • *
  • Posts: 8
Re: I want to port my LDL project to freepascal
« Reply #2 on: January 24, 2026, 04:53:23 pm »
Thanks for the information.

I got acquainted with the new features of free pascal. I especially liked generics and analogues of constructors and the copy method. The possibility of checking for ManagedType is especially interesting. This mechanism is very similar to the C++ mechanisms.

To create a prototype, I chose object pascal without using new features to get the hang of it.

In the chat, I was advised to check the support for older systems, since no one writes for them and there may be bugs.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12636
  • FPC developer.
Re: I want to port my LDL project to freepascal
« Reply #3 on: January 24, 2026, 04:56:17 pm »
Free Pascal is not a magic wand that makes fundamental differences between OSes disappear.  Threading, unicode and dynamic linking are some of the pain points.

What it does do is that it is a bit easier to crosscompile specially for non *nix systems due to the internal linker. However if you start linking static libraries from other languages, the internal linker might not support everything.

Also, the current release versions of FPC don't support Windows 9x.   Moreover while older NT (2000,XP,Vista,W7, W8) are probably mostly still working with release versions, but with ever more unicode and threading expansion that will hit a limit someday too, oldest first.  Maybe not such a problem, since an older FPC (3.0.2?) needed for win9x can also be used to service older NTs.

I've never heard of Kade Dos (and a quick google doesn't help, maybe because Kade is the dutch word for quay), but whatever dos or dos extender (maybe with the exception of WDOSX), doing any form of shared linking will be non existent for the most.

Cross Unix compatibility of binaries is low, and crosscompiling for Linux requires libraries on host, so you would have to target each major version of Debian separately, either by VM or cross setup.



« Last Edit: January 24, 2026, 04:57:58 pm by marcov »

JordanCpp

  • New member
  • *
  • Posts: 8
Re: I want to port my LDL project to freepascal
« Reply #4 on: January 24, 2026, 05:08:05 pm »
Thanks for your reply. I had too much faith in the description on the website

Quote
Introduction
Overview
Free Pascal is a mature, versatile, open source Pascal compiler. It can target many processor architectures: Intel x86 (16 and 32 bit), AMD64/x86-64, PowerPC, PowerPC64, SPARC, SPARC64, ARM, AArch64, MIPS, Motorola 68k, AVR, and the JVM. Supported operating systems include Windows (16/32/64 bit, CE, and native NT), Linux, Mac OS X/iOS/iPhoneSimulator/Darwin, FreeBSD and other BSD flavors, DOS (16 bit, or 32 bit DPMI), OS/2, AIX, Android, Haiku, Nintendo GBA/DS/Wii, AmigaOS, MorphOS, AROS, Atari TOS, and various embedded platforms. Additionally, support for RISC-V (32/64), Xtensa, and Z80 architectures, and for the LLVM compiler infrastructure is available in the development version. Additionally, the Free Pascal team maintains a transpiler for pascal to Javascript called pas2js.

Of course, I understand that it's not easy to develop a library with a single API for working on old and new systems.
There is confidence that the Free Pascal infrastructure is better suited to this. As a single tool for all systems.

I'm thinking of creating a small prototype with a minimum of features. And try to build it under dos, windows 9x. Compare compiler versions.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12636
  • FPC developer.
Re: I want to port my LDL project to freepascal
« Reply #5 on: January 24, 2026, 05:30:44 pm »
That is probably best. Note that that description doesn't say Win9x explicitely. Windows 32-bit can be Windows for Workgrounds (win32s), Win9x or WinNT variants.
 
And even then, with two versions (say FPC 3.0.2 and something current) you can still support that.

Start with the most important targets first, leave difficult stuff (like 16-bit) for later.

jamie

  • Hero Member
  • *****
  • Posts: 7518
Re: I want to port my LDL project to freepascal
« Reply #6 on: January 25, 2026, 03:22:21 pm »
I have a util app I made to translate C/C++ code over the Object Pascal; it's not completed but enough for my purposes. Maybe I should do some work on that and help it along with projects like this.

  I examine the sources and there are a lot of them.

 My util composes Header files and body files to form a unit but I place comments on the converted sections of where to find the original references as it builds.

 It also has stop in place assistance when it encounters and unknown so I can edit a macro for the converter to use for the remaining, sort of self-educate as it goes along and builds a database that can be share among other conversions.

 Places where I cannot come up with a macro at the time for the conversion, I simply insert the original code with a Comment block so I can manually edit it later and maybe enhance the converter to build a corrective translation.

 I kind of stopped when I got to the point where I was able to complete the working translation of the C++ app I was converting.

 Maybe I should use those sources as an example to build on it more.

Jamie
The only true wisdom is knowing you know nothing

JordanCpp

  • New member
  • *
  • Posts: 8
Re: I want to port my LDL project to freepascal
« Reply #7 on: January 29, 2026, 06:49:38 am »
I experimented with pascal. The idea is that you can use delphi 7 to support Win9x (95,98,Me). For modern systems, you can use freepascal + linux. The code is the same, and it uses object pascal without features. The main thing is to create a module with types to avoid any problems. If you separate the OS-specific implementation into different modules and replace the module directories with the specific OS during compilation, the code remains clean and macro-free.

As a result, two compilers are used to support both old and new systems. The setup is minimal, and no ide or build settings are required. You can build on any system with a single command.

There's even a more radical idea. Limit the syntax and capabilities to tp 7.0
This will provide support for dos 16\32
Override the string types in the module.

JordanCpp

  • New member
  • *
  • Posts: 8
Re: I want to port my LDL project to freepascal
« Reply #8 on: January 29, 2026, 08:40:56 am »
fpc 3.2.2


JordanCpp

  • New member
  • *
  • Posts: 8
Re: I want to port my LDL project to freepascal
« Reply #9 on: January 29, 2026, 08:41:35 am »
fpc 2.4.0

Code: Pascal  [Select][+][-]
  1. program WinApiWindow;
  2.  
  3. {$mode objfpc}
  4.  
  5. uses windows;
  6.  
  7. const
  8.   ClassName = 'MyWindowClass';
  9.  
  10. function WindowProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
  11. begin
  12.   case Msg of
  13.     WM_DESTROY:
  14.     begin
  15.       PostQuitMessage(0);
  16.       Exit(0);
  17.     end;
  18.   else
  19.     Result := DefWindowProc(hWnd, Msg, wParam, lParam);
  20.   end;
  21. end;
  22.  
  23. var
  24.   wc: TWndClass;
  25.   msg: TMsg;
  26. begin
  27.  
  28.   FillChar(wc, SizeOf(wc), 0);
  29.   wc.lpfnWndProc   := @WindowProc;
  30.   wc.hInstance     := hInstance;
  31.   wc.lpszClassName := ClassName;
  32.   wc.hbrBackground := COLOR_WINDOW + 1;
  33.   wc.hCursor       := LoadCursor(0, IDC_ARROW);
  34.  
  35.   RegisterClass(wc);
  36.  
  37.  
  38.   CreateWindowEx(0, ClassName, 'Hello, WinAPI!',
  39.     WS_OVERLAPPEDWINDOW or WS_VISIBLE,
  40.     CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,
  41.     0, 0, hInstance, nil);
  42.  
  43.  
  44.   while GetMessage(msg, 0, 0, 0) do
  45.   begin
  46.     TranslateMessage(msg);
  47.     DispatchMessage(msg);
  48.   end;
  49. end.    
  50.  

JordanCpp

  • New member
  • *
  • Posts: 8
Re: I want to port my LDL project to freepascal
« Reply #10 on: Today at 10:05:41 am »
I'm continuing to develop the LDL prototype.

The final version.
The code compiles with FPC 1, 2, 3, and Delphi 4 and higher.

Code: Pascal  [Select][+][-]
  1. program Main;
  2.  
  3. {$ifdef fpc}
  4.     {$mode objfpc}{$H+}
  5. {$endif}
  6.  
  7. uses LDL;
  8.  
  9. var
  10.   Window  : TMainWindow;
  11.   Expected: TExpected;
  12.   Event   : TEvent;
  13.  
  14. begin
  15.   Expected.Create();
  16.  
  17.   Window.Create(Expected, Vec2u(0,0), Vec2u(800,600), 'LDL window!');
  18.  
  19.   if (Expected.GetOk()) then
  20.   begin
  21.       while (Window.GetRunning()) do
  22.       begin
  23.           while (Window.GetEvent(Event)) do
  24.           begin
  25.               if (Event.Kind = TEventIsQuit) then
  26.               begin
  27.                   Window.StopEvent();
  28.               end;
  29.           end;
  30.  
  31.           window.Present();
  32.       end;
  33.  
  34.       Window.Destroy();
  35.   end;
  36. end.
  37.  

 

TinyPortal © 2005-2018