Recent

Author Topic: How to: create DLL file for Windows 10 64-Bit Pro  (Read 33240 times)

paule32

  • Sr. Member
  • ****
  • Posts: 280
How to: create DLL file for Windows 10 64-Bit Pro
« on: April 01, 2024, 07:36:29 pm »
How can I properly create a .DLL file for Windows 10 64-Bit Professional ?
Currently, I get Windows .DLL Error: 0xc000007b.

rvk

  • Hero Member
  • *****
  • Posts: 6585
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #1 on: April 01, 2024, 07:38:56 pm »
Show the code.

Is this error during loading of the dll?
Is this with your custom rtl or with standard fpc?

« Last Edit: April 01, 2024, 07:47:10 pm by rvk »

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #2 on: April 01, 2024, 07:46:17 pm »
Code: Pascal  [Select][+][-]
  1. {$mode delphi}
  2. library fpc_rtl;
  3.  
  4. // -----------------------------------------------------------------
  5. // export public function's/procedure's ...
  6. // -----------------------------------------------------------------
  7. exports
  8.   move;
  9.  
  10. end.

The error comes, when loading .DLL
Yes, custom rtl.
Yes, standard fpc.

rvk

  • Hero Member
  • *****
  • Posts: 6585
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #3 on: April 01, 2024, 07:47:16 pm »
BTW. This was already discussed.
https://forum.lazarus.freepascal.org/index.php/topic,66396.0.html

And please ALWAYS mention you are working with your own system/rtl files.

rvk

  • Hero Member
  • *****
  • Posts: 6585
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #4 on: April 01, 2024, 07:53:48 pm »
There is no problem with the source code of your dll.

The problem is the custom rtl with which you compile that dll.
The resulting dll isn't a valid dll.


paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #5 on: April 01, 2024, 08:08:29 pm »
The problem is the custom rtl with which you compile that dll.
The resulting dll isn't a valid dll.

I look for command line options - but don't found explicit to create a .DLL file.
I have extend the source with the sysinit.pas procedure.
But I think, it is a linker problem.
So, the linker need a "entry point", and special options.

rvk

  • Hero Member
  • *****
  • Posts: 6585
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #6 on: April 01, 2024, 08:19:10 pm »
Just use fpc without options (and normal default system rtl) on your dll source.
You'll see that the resulting dll will work and load correctly.
(At least in that other topic when I tried it)

So the problem is your custom rtl where there is probably something missing.
I think it was discussed in that topic.

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #7 on: April 01, 2024, 08:30:05 pm »
I don't think, that my custom rtl is the problem.
Because, I did the following command under my msys64 console:

Code: [Select]
gcc -shared -nostdlib -o test.dll *.o -L. -limpsystemAnd all will be done.

The .DLL image will be written correctly without any problems.
So, I can use .dlll files, now.

I don't know, why fpc have this behvoir.

rvk

  • Hero Member
  • *****
  • Posts: 6585
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #8 on: April 01, 2024, 08:41:15 pm »
Code: [Select]
gcc -shared -nostdlib -o test.dll *.o -L. -limpsystemAnd all will be done.
gcc?
And does this use the exact same .pp files as your custom fpc rtl?

And anyway... that's not what I said.
I said to compile your dll with standard default fpc system files.
It will create a correct loadable dll.
So how can you say it's fpc?

It's something you are doing, or not doing, in your custom system files.

Thaddy

  • Hero Member
  • *****
  • Posts: 16194
  • Censorship about opinions does not belong here.
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #9 on: April 01, 2024, 09:06:05 pm »
AND if compiling for win use -WR (only -WN for debugging)
to provide for relocatable code in the case of dll's
This is not a course in computer science, but if you do not even know what the compiler needs to provide for.... :)
But we keep helping you.... :-X :'(
« Last Edit: April 01, 2024, 09:12:21 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #10 on: April 01, 2024, 09:16:39 pm »
@rvk:
I don't claim that FPC is the problem.
I assumed it is.
Because with standard/original FPC, FPC use the common rtl from
the makers of FPC.

Don't worry. Be Happy.

@Thaddy
Me, as developer can use different kind of DSL's, and the toolchain's for it.
So, it is not a problem to merge different things together.
As long as they work.

The finally endpoint is a working application that can be used memory safe
and security safe. - In context of Microsoft Windows 10 and up Operating System's.

Thanks for your lesson's.
I will be catch them, and involved it in my development process.

Thanks for reading
paule32

codehorror

  • New member
  • *
  • Posts: 7
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #11 on: April 02, 2024, 10:42:31 pm »
Are you using the 64-bit FPC? I had this problem when I accidentally downloaded the 32-bit Lazarus.

You can check this under Tools -> Options -> Environment. It should be similar to:

Code: Pascal  [Select][+][-]
  1. $(Lazarusdir)\fpc\3.2.2\bin\x86_64-win64\fpc.exe

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #12 on: April 08, 2024, 02:10:54 am »
yes, 64-Bit of 3.2.0 and 3.2.2

under Microsoft Windows 10/11 64-Bit Professional.
don't have test it under other OS's.

I can develop a .DLL - that the other Developer/User can simply us by using the exported data to the .DLL from the .DLL in their own Application with the "external" keyword.
This bring no Error's, and as such, all is done.

Only me, I have to be attention to the Link process of the .DLL - to write the correct PE-Image informations.
Currently, I use the original FPC 3.2.0 Compiler without any modification's for my current Project - but with my customized RTL.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #13 on: April 08, 2024, 04:34:11 am »
Currently, I get Windows .DLL Error: 0xc000007b.
This error mean that your dll has a wrong or corrupt image format, in most cases it is the wrong bitness <-> wrong image header <-> PE vs PE+.
to write the correct PE-Image informations.
I hope you choose PE+ format and not PE, PE is 32bit while PE+ is 64bit.
Currently, I use the original FPC 3.2.0 Compiler without any modification's for my current Project - but with my customized RTL.
Do you understand that this makes no sense?
Either its original and working or its modified and might work, depend on the developer skills, but having an original modified version is not possible since "original" and "modified" are opposites.
I am still undecided what benefit a modified RTL bring, IMHO it brings more problems than any good, [sarcasm] like unable to write a correct Executable Header [/sarcasm]
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: How to: create DLL file for Windows 10 64-Bit Pro
« Reply #14 on: April 08, 2024, 06:16:12 am »
sorry for misunderstanding.
With original I would be say, that I use a FPC Compiler from the official download Location to compile a new RTL system.pas. This has nothing to do with the command switch, "to not" use the standard config + unit's, because FPC run in it's own process tree.

I use FPC 3.2.0, and FPC 3.2.2 both in 64-Bit Version.
Because, else I could not compile the "move" Function from the 64-Bit RTL Version with FPC 3.2.0/3.2.2 32-Bit Version, that you can find here: https://github.com/paule32/Qt_FPC/blob/952767f3e9639d68ac1535818933d7a36acb3ff0/src/sources/fpc-sys/FPC_System.pas#L254

 

TinyPortal © 2005-2018