Hi, I’m working on Win32 platform at the moment, and I observed some “weird” behaviour about q’s dynamic loading. I hope the community here could help to confirm my understanding.
I noticed that when q performs dynamic loading of DLL (using 2:), it only respects the %PATH% environment variable set before q process starts. So if I change the %PATH% environment within q script (using setenv), it seems that 2: will not see the new %PATH% at all. It is an expected behaviour?
My use case is like following:
Some of the 3rd-party libraries are stored in a separate directory. So when a user loads the wrapper I wrote for such library, I need to make sure the 3rd-party library directory is in %PATH%. But very often, that’s not the case, especially on some of the long-running q processes in our environment. As rebooting such q process takes a huge impact on the environment, I was trying to modify the %PATH% environment dynamically in q script before I try to load the library – This didn’t work out.
So I’d like to check with the community that this is indeed the expected behaviour, or if there was anything that I did wrongly.
Sample code:
cd:system"cd"
path:0N!ssr[;“/”;“\”]1_string .Q.dd[hsym`$cd]`test_dll`Release / the actual library directory (in real application, there could be multiple directories)
PATH setenv";"sv enlist[path],";"vs getenv
PATH
test_dll 2:(
test_fun;1) / this always yields DLL loading error if library directory was not on %PATH% at the time when q process started up
I’d also like to hear if there is any rule-of-thumb guideline that I can try to follow in such situation, i.e., trying to load a library in the loading running q process, but end up needing to load the library from some other directories.