SWI generated executable is not loading dll's from the local directory

I’m using: SWI-Prolog version ???

I want the code to load DLL’s from my local directory, not from the installation. This old version cannot run because it is not loading the local DLL as I need it to. Is there a thing I can do about this, or does this need a fix to SWI itself?

2019-09-02 01:32 PM 30,720 uri.dll
2019-09-02 01:32 PM 51,200 uuid.dll
2019-09-02 01:32 PM 24,576 websocket.dll
2019-09-02 01:32 PM 49,152 yaml4pl.dll
2018-06-01 08:24 AM 122,880 zlib1.dll
2019-09-02 01:32 PM 22,016 zlib4pl.dll
58 File(s) 20,522,256 bytes
3 Dir(s) 898,635,890,688 bytes free

D:\vmm builds\NewBuild\server>startserv.exe
ERROR: c:/program files/swipl/library/uri.pl:56: Initialization goal raised exception:
ERROR: The specified procedure could not be found.

ERROR: In:
ERROR: [18] throw(error(shared_object(open,‘The specified procedure could not be found.\r\n’),context(…,_24864)))
ERROR: [16]
ERROR: [15] with_mutex(’$foreign’,load_foreign_library(foreign(uri),uri,default(install)))
ERROR: [12] ‘$run_init_goal’(shlib:load_foreign_library(…)) at c:/program files/swipl/boot/init.pl:686
ERROR: [11] catch(system:’$run_init_goal’(…),_24990,system:’$initialization_error’(_25012,…,…)) at c:/program files/swipl/boot/init.pl:457
ERROR: [10] catch_with_backtrace(system:’$run_init_goal’(…),_25042,system:’$initialization_error’(_25064,…,…)) at c:/program files/swipl/boot/init.pl:506
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
ERROR: c:/program files/swipl/library/sgml.pl:187: Initialization goal raised exception:
ERROR: The specified procedure could not be found.

ERROR: In:
ERROR: [18] throw(error(shared_object(open,‘The specified procedure could not be found.\r\n’),context(…,_28376)))
ERROR: [16]
ERROR: [15] with_mutex(’$foreign’,load_foreign_library(foreign(sgml2pl),sgml,default(install)))
ERROR: [12] ‘$run_init_goal’(shlib:load_foreign_library(…)) at c:/program files/swipl/boot/init.pl:686
ERROR: [11] catch(system:’$run_init_goal’(…),_28502,system:’$initialization_error’(_28524,…,…)) at c:/program files/swipl/boot/init.pl:457
ERROR: [10] catch_with_backtrace(system:’$run_init_goal’(…),_28554,system:’$initialization_error’(_28576,…,…)) at c:/program files/swipl/boot/init.pl:506
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.

Is this a recent problem? The latest devel release is compiled using MinGW 10, which comes with an additional runtime library libssp-0.dll.

You can load a dll from any directory, but you must be aware that possible dependencies of that dll must be in the dll search path. That is all mighty complex and varies significantly between Windows versions. See also win_add_dll_directory/1

I only now tried to run a program I generated last year and it didn’t work. I do not want any DLL search path, everything is already in the current directory. But the system is ignoring the package I put together with all the right files and going instead to the installation.

I uninstalled SWI and then the software worked. This is not good.

"C:\Program Files\swipl\bin\swipl.exe" --goal=run_server 
            -o ..\..\..\build\server\startserv.exe -c load2.pl

This is the line to create startserv. I ran this line again to create a new executable against the latest SWI, so I have a working startserv.

But I must have this fixed. I cannot live with a past version being unusable because it was on a past SWI. What can I do so startserv does not default to loading incompatible DLL’s from the latest SWI install directory?

The best way to guarantee that the correct DLLs are picked up is by copying them into the same directory as the executable. It might also be wise to make sure that environment variables such as SWI_HOME_DIR and PATH do not point at the wrong version. This is in the end just Windows DLL management.