[fpc-pascal] Dynamic loading to static?

Michael Van Canneyt michael at freepascal.org
Fri Oct 25 18:02:32 CEST 2019



On Fri, 25 Oct 2019, Ryan Joseph wrote:

> Maybe a stupid question but I thought I’d asked before I potentially waste a bunch of time. I have code to dynamically load functions using Dynlibs.LoadLibrary, for example:
>
> type
>  _Py_Initialize = procedure; cdecl;
>  _PyImport_ImportModule = function(module: pchar): PPyObject; cdecl;
>
> var
>  […]
>  Py_Initialize := _Py_Initialize(GetProcAddress(handle, 'Py_Initialize'));
>
> The problem is I would like to change this to static linking now but I only have function pointers instead of declarations. Is there a way I can get the compiler to statically link these function pointers or do I need to manually change them all by hand to be things like:
>
> 	function  PyImport_ImportModule(module: pchar): PPyObject; cdecl;

You need to manually change them.

if you look in the packages, you'll see that many library import units exist in 2
flavours. One static, one dynamic.

Michael.


More information about the fpc-pascal mailing list