Jump to content

Recommended Posts

On 3/11/2022 at 2:06 PM, David Heffernan said:

So it's more geared towards looser coupling, a more scripting like approach. I guess if I know the external code I want to use at compile time then linking to a DLL in the classic fashion is generally preferable. 

For me the most promising feature is the ability to link C libs statically. I'd love to have self-contained Delphi EXEs with OpenSSL, for example.

Share this post


Link to post
27 minutes ago, Fr0sT.Brutal said:

For me the most promising feature is the ability to link C libs statically. I'd love to have self-contained Delphi EXEs with OpenSSL, for example.

Distributing DLLs with an exe is really very trivial. Either in the same directory as the exe or a sub directory as an assembly using manifests.

 

Linking .obj files to an exe is a tricksy business. You need to supply the C RTL and for complex libs that is often very hard to achieve. And then on x64 you have the longstanding bug that the Delphi compiler doesn't pick up pdata sections with the exception tables. So exceptions in the C code can just terminate the process. 

  • Like 1

Share this post


Link to post

CPas v1.3.stable released.

 

Big update, code refactor, win32 support and much more. Reworked all examples to support 32/64-bits and more.

 

• Reworked all examples to support 32/64-bits
• Update cpLoadLibFromResource to include an instance (THandle) parameter
• Added a runtime check to make sure CPas and CPas.Static are not used simultaneously
• FPC can now build static releases also
• Add CPas.Static unit now for static builds
• Reformated CHM help format
• Added cpCompile with project directives support
• Replaced cpLoadLibFromStream with cpLoadLibFromMemory
• Refactored codebase and added 32-bit support 😎
• Updated cpAddLibrary to support (.LIB) files
• Updated cpSetVerionInfo to validate FileVersion as SemVer format (major.minor.patch)
• Miscellaneous fixes and enhancements

  • Like 1

Share this post


Link to post
On 3/11/2022 at 7:38 PM, Mark- said:

I think it is interesting but we need 32 bit.

Wish granted! 1.3 released, 32-bit support and more. Big update! :classic_cool:

Share this post


Link to post
48 minutes ago, tinyBigGAMES said:

Wish granted! 1.3 released, 32-bit support and more. Big update! :classic_cool:

Thank you.

  • Thanks 1

Share this post


Link to post

Out of curiosity I checked the original GitHub link, the page has vanished.

Share this post


Link to post
Posted (edited)
1 hour ago, hsauro said:

Out of curiosity I checked the original GitHub link, the page has vanished.

Yeah that was the catalyst for posting here and the webpage of "tinyBigGAMES LLC" did not have it listed. I wonder if he sold his work.

Edited by Mark-

Share this post


Link to post
6 hours ago, Mark- said:

Has this endeavor (CPas) ended?

Hi, for now yes. I may revisit it in the near future. 

  • Like 1

Share this post


Link to post
2 hours ago, hsauro said:

Is it that you can now link lib files?

No, and LIB files is not supported by Delphi for good reason, which is hell of naming and scope, doable though.

 

LIB files are merely a package of object files (.o or .obj), which does have COFF format only with files/sections, in other words it is an uncompressed container of list of files, and that is it.

 

You can use LIB in Delphi but you need to do some conversion first:

1) unpack all the object files form the LIB, there is many tools on the net to do so, there is many tools to do so but you need to search for them and try the one that work with your lib file as different compilers tend to produce a little different lib format or tweaks, while most such tools are built for specific format/tweaks.

2) link the unpacked objects files into one object file, many linkers do this with the command -relocatable (or -r) , though not all linkers support wildcard like *.o and you need to list all the names of object files, and the -o parameter will give you the one linked (combined) one object.

3) use the one object file from (2) same as you use o files, in this case it is the lib itself.

 

extra info

https://stackoverflow.com/questions/3811437/whats-the-format-of-lib-in-windows

 

  • Like 2

Share this post


Link to post

But you can now link lib files with your CPas since you say “Now you can link in static C libs directly into Delphi:”?

Share this post


Link to post
Posted (edited)
10 minutes ago, hsauro said:

But you can now link lib files with your CPas since you say “Now you can link in static C libs directly into Delphi:”?

Using the new Clang based C++ Builder (win64 modern platform), which can compile more C/C++ code than it could in the past, which means it is more likely to be able to compile your favorite C library. You compile the code to generate .o files, which Delphi can consume with {$L unit1.o} for example. I have a unit called CPas.CRuntime that references all the missing c runtime routines that the C lib may reference and thus allow Delphi to compile and use the static C library. Continue to update CPas.CRuntime as you encounter references that you may need. I have included a far bit already.


Now you can link in static C libs directly into Delphi:
means you can take your favorite C lib, such as sqlite and link inside the EXE vs calling it from a DLL. I have sqlite3 as an example in the repo. Not all of them will be possible, but you should be able to do more with the new tool chain than you ever could before. This does require 12.1+ 

Edited by tinyBigGAMES

Share this post


Link to post

This has always been possible. On win64 delphi compiler/linker has never respected the pdata exception tables so exceptions in the linked code have unpredictable results, for instance insta process terminate. Not sure if latest delphi fixes that. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×