Recent

Author Topic: How to build DLL Files for Windows Desktop ?  (Read 5155 times)

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to build DLL Files for Windows Desktop ?
« Reply #30 on: February 27, 2024, 04:52:29 pm »
@rvk

Some Month's ago, I read the Command Line Option's Page...
There was a Notice, that FPC don't Support the Creation of DLL.

I don't know if this Issue is fixed. yet.

rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: How to build DLL Files for Windows Desktop ?
« Reply #31 on: February 27, 2024, 04:55:02 pm »
Some Month's ago, I read the Command Line Option's Page...
There was a Notice, that FPC don't Support the Creation of DLL.
I've never heard of that.
library and DLL was always possible, I thought.

Maybe you can find the reference again.

Thaddy

  • Hero Member
  • *****
  • Posts: 16416
  • Censorship about opinions does not belong here.
Re: How to build DLL Files for Windows Desktop ?
« Reply #32 on: February 27, 2024, 04:57:54 pm »
There has not been any issue ever: FPC was always capable of writing shared libraries.
So point us to that wrong info and we will remove such bogus. Maybe a rogue wiki edit by an ill-informed person? Happens all the time. Needs to be corrected all the time. Needs to be punished all the time.
There is nothing wrong with being blunt. At a minimum it is also honest.

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to build DLL Files for Windows Desktop ?
« Reply #33 on: February 27, 2024, 04:58:20 pm »
So, okay.
But what the Fu** with "_DLLMainCRTStartup" why does the Compiler doesn't find this Symbol ?
I included an Assembly Function from Pascal Source into system.pas - see my last Post of this
(procedure DLLMainCRTStartup ...)

Thaddy

  • Hero Member
  • *****
  • Posts: 16416
  • Censorship about opinions does not belong here.
Re: How to build DLL Files for Windows Desktop ?
« Reply #34 on: February 27, 2024, 05:12:44 pm »
_DLLMainCRTStartup is specific to windows, so examine the windows specific pp, pas and inc files.
It is in the rtl. Ever used grep? takes seconds to find it. People who don't know about grep and how to use it should not be allowed to access a source tree.

And you don't need it. Any exported function can be your _dllmain. Things become much more difficult if you need GUI stuff.

./rtl/win32/sysinitpas.pp:53:    procedure _FPC_DLLMainCRTStartup(_hinstance : longint;_dllreason : dword;_dllparam:Pointer);stdcall;public name '_DLLMainCRTStartup';
./rtl/win64/sysinit.pp:122:    procedure _FPC_DLLMainCRTStartup(_hinstance : qword;_dllreason : dword;_dllparam:Pointer);stdcall;public name '_DLLMainCRTStartup';

Etc. So that code is called in sysinit and is not cross platform.
« Last Edit: February 27, 2024, 05:26:21 pm by Thaddy »
There is nothing wrong with being blunt. At a minimum it is also honest.

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to build DLL Files for Windows Desktop ?
« Reply #35 on: February 27, 2024, 06:32:20 pm »
Thanks.

But: procedure _FPC_DLL ...
the pre-fixed _FPC ...

isn't it the same as I write again:
procedure DLLMainCRTStartup; assembler; public name '_DLLMainCRTStartup'; asm ret end;

okay, there are no Parameter's.
But the Rest fit like you posted ... (public name ...)
? ? ?

Thaddy

  • Hero Member
  • *****
  • Posts: 16416
  • Censorship about opinions does not belong here.
Re: How to build DLL Files for Windows Desktop ?
« Reply #36 on: February 27, 2024, 06:35:13 pm »
The prefixes are to uniquely identify code as belonging - in this case - to the compiler.
There is nothing wrong with being blunt. At a minimum it is also honest.

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to build DLL Files for Windows Desktop ?
« Reply #37 on: February 27, 2024, 08:17:38 pm »
There has not been any issue ever: FPC was always capable of writing shared libraries.
So point us to that wrong info and we will remove such bogus. Maybe a rogue wiki edit by an ill-informed person? Happens all the time. Needs to be corrected all the time. Needs to be punished all the time.

You can take a look to:
https://www.freepascal.org/docs-html/user/userap1.html

at Command -CD:
...
-CD   Create also dynamic library (not supported)
...

PascalDragon

  • Hero Member
  • *****
  • Posts: 5823
  • Compiler Developer
Re: How to build DLL Files for Windows Desktop ?
« Reply #38 on: February 27, 2024, 08:31:34 pm »
apart from off -> for? Not immediately, no.
Maybe the claim that everything else is cdecl? (Which it isn't, but the directive behaves correct)

Other way around. Not all Windowses are stdcall. Wince is cdecl. Just messing with ya :-)

And on WinCE the winapi modifier maps to cdecl. ;)

There has not been any issue ever: FPC was always capable of writing shared libraries.
So point us to that wrong info and we will remove such bogus. Maybe a rogue wiki edit by an ill-informed person? Happens all the time. Needs to be corrected all the time. Needs to be punished all the time.

You can take a look to:
https://www.freepascal.org/docs-html/user/userap1.html

at Command -CD:
...
-CD   Create also dynamic library (not supported)
...

That option is at least not used, but it also isn't needed for Windows anyway.

Thaddy

  • Hero Member
  • *****
  • Posts: 16416
  • Censorship about opinions does not belong here.
Re: How to build DLL Files for Windows Desktop ?
« Reply #39 on: February 27, 2024, 08:34:06 pm »
Quote
https://www.freepascal.org/docs-html/user/userap1.html

at Command -CD:
That has a different meaning:
It means that the compiler should also instruct the linker to create a static library AND a dynamic library.

So has nothing to do with your current problems which are due to being ill-informed and sheer laziness..
Oh, well, Danes.... >:D 8-) O:-) O:-) :(

If I am back in a good mood I will tell you how to solve that  :D
 unless you found it already in the ld documentation.... ;) :-X
« Last Edit: February 27, 2024, 08:46:14 pm by Thaddy »
There is nothing wrong with being blunt. At a minimum it is also honest.

Thaddy

  • Hero Member
  • *****
  • Posts: 16416
  • Censorship about opinions does not belong here.
Re: How to build DLL Files for Windows Desktop ?
« Reply #40 on: February 27, 2024, 08:36:26 pm »
That option is at least not used, but it also isn't needed for Windows anyway.
No it is not used. You have to refer to the external linker documentation. In this case I gave ld as an example. It is dead simple.

It is simply instructing the linker to also create a dynamic library from the static one.

(Probably an oversight on a Sunday morning by one of the core developers a very, very long time ago, so not you ;)  you qualify as just long, maybe very)
« Last Edit: February 27, 2024, 08:49:53 pm by Thaddy »
There is nothing wrong with being blunt. At a minimum it is also honest.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5823
  • Compiler Developer
Re: How to build DLL Files for Windows Desktop ?
« Reply #41 on: February 27, 2024, 09:13:11 pm »
It is simply instructing the linker to also create a dynamic library from the static one.

No, the -CD option is literally instructing nothing. It's only including/excluding the cs_create_dynamic option in current_settings.moduleswitches, but that enum value is not used inside the compiler.

Thaddy

  • Hero Member
  • *****
  • Posts: 16416
  • Censorship about opinions does not belong here.
Re: How to build DLL Files for Windows Desktop ?
« Reply #42 on: February 27, 2024, 09:28:02 pm »
You misunderstood me: it does nothing, but was imho meant to be something. That is not more than a -k option. I know it does nothing.... I just described what it is supposed to do. And for at least the external linker that is easy.
There is nothing wrong with being blunt. At a minimum it is also honest.

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to build DLL Files for Windows Desktop ?
« Reply #43 on: February 28, 2024, 12:57:08 am »
so far, so forth...
I am able to "load" a DLL - but the calling of Functions is a little bit strange, yet.
But I am optimistic that this disadvantage can be evaluate next Time.

See my github.com Account, to follow the Process...

rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: How to build DLL Files for Windows Desktop ?
« Reply #44 on: February 28, 2024, 09:19:16 am »
so far, so forth...
I am able to "load" a DLL - but the calling of Functions is a little bit strange, yet.
Not sure what you find strange.
There is no function in the dll (at least not in your github).
Just some main begin/end code (which gets executed multiple times).

 

TinyPortal © 2005-2018