how to check for is error 126 in advance?

112 views
Skip to first unread message

jtu...@objektfabrik.de

unread,
Apr 19, 2013, 1:40:08 PM4/19/13
to va-sma...@googlegroups.com
hi

how can I check (e.g. on application startup) if a certain DLL/lib can be found/loaded.

I know I could issue a call and wrap it in proper exception handling blocks. but I'd like to do something like dlopen() just to see if it is there. Thus I don't have to implement individual calls for each required lib/DLL

Joachim

Sebastian Heidbrink

unread,
Apr 19, 2013, 1:45:39 PM4/19/13
to va-sma...@googlegroups.com
Hi Joachim,

for your own dll, you should have the general path/resource information
in your abt.ini,... I would just check for existence based on the Cfs-layer.
The next step would be checking the registry or PATH variables for the
dll entry....

Don't forget to check for the access rights on those directories. I had
issues on that one before....

Sebastian
> --
> You received this message because you are subscribed to the Google
> Groups "VA Smalltalk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to va-smalltalk...@googlegroups.com.
> To post to this group, send email to va-sma...@googlegroups.com.
> Visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Marten Feldtmann

unread,
Apr 19, 2013, 2:25:01 PM4/19/13
to va-sma...@googlegroups.com
I would think, that getting an address of a platform function should be ok to know, if the library is available.


jtu...@objektfabrik.de

unread,
Apr 20, 2013, 12:59:45 AM4/20/13
to va-sma...@googlegroups.com
Hi Sebastian,

hmm. Sounds like quite some coding for a simple check. But it's sure better than just waiting if the first call fails...

I was hoping for a method that's equivalent to dlopen, which would do all of that and throw an error if it's not found.

Joachim

jtu...@objektfabrik.de

unread,
Apr 20, 2013, 1:06:23 AM4/20/13
to va-sma...@googlegroups.com
Marten,

I am not sure I understand your comment. I would like to start my web server and check for availability of libs/dlls right at the start so that I can present some web page with error information rather than wait for the first call to fail.

But maybe you are saying there is a way to ask for a function's address without actually calling it. How can I do that?

Joachim

Sebastian Heidbrink

unread,
Apr 20, 2013, 1:34:35 AM4/20/13
to va-sma...@googlegroups.com
Joachim,

checking if a file exists in a directory should be a lot of codeing. accessing the abt.ini also.

For the registry stuff check the method "abtScanEnv", or so.
I hope I have that right in mind...

Sebastian

Marten Feldtmann

unread,
Apr 20, 2013, 3:03:08 AM4/20/13
to va-sma...@googlegroups.com
Example:

functionName :=
            PlatformFunction fromArray: (
                Array
                    with: 'C'
                    with: 'ucal_getNow_49'
                    with: nil
                    with: libraryName
                    with: Array new
                    with: #double).
value := functionName address.

Hermann Ottens

unread,
Apr 23, 2013, 10:25:30 AM4/23/13
to va-sma...@googlegroups.com
Hi Joachim,

in case you're still looking for a simple code that should work on Windows (we're using VAST 8.5.2, but iirc it works also in 7.0, 7.5):

 | module fileName |

fileName := 'your.dll'. "fileName can be fully qualified"
"get DLL handle to see if it is already loaded"
(module := OSHmodule getModuleHandle: fileName) isNull ifTrue:
  ["load the DLL"
  module := OSHmodule loadLibrary: fileName].
module isNull not ifTrue:
  ["free the DLL"
  module freeLibrary ifFalse: ["could not unload the dll"]]

On Windows you can check the DLLs loaded by your program with ProcessExplorer (SysInternals).

Hermann

jtu...@objektfabrik.de

unread,
Apr 24, 2013, 9:20:38 AM4/24/13
to va-sma...@googlegroups.com
Hi Hermann,

that's exactly the kind of code I was looking for:
Just try to load the DLL / Lib and see if that works, without setting up all the stuff that's needed to call any specific function in it.

Unfortunately, my deployment platform is Linux. On Linux there neither is a Class named OSHmodule nor another implementor of #loadLibrary: . So I am afraid I'll either have to chose one of the other approaches or simply keep my code as it is. It does catch errors, but only at first invocation of external functions, so it's not too bad. I just would have liked to see problems in a startup log of my server application.

Joachim

Thomas Koschate

unread,
Apr 25, 2013, 8:05:34 AM4/25/13
to va-sma...@googlegroups.com
On Wednesday, April 24, 2013 9:20:38 AM UTC-4, jtu...@objektfabrik.de wrote:

Unfortunately, my deployment platform is Linux.

 It's becoming increasingly apparent that all your problems are because you insist on doing things in Linux.  If you'd just give up, go with the flow, and work exclusively in Windows instead of some obscure operating system that will never catch on anyway, all would be well.  :{)

Tom

Marten Feldtmann

unread,
Apr 25, 2013, 8:47:20 AM4/25/13
to va-sma...@googlegroups.com
Joachim,

whenever working with external functions - use instances of PlatformFunctions and not the pragma style, tough it may be faster in the first round.

When you have reached this state of programming you may use several methods on the instance side of PlatformFunction or instance side/class side of PlatformLibrary to get what you want ...

When working on different platforms use PlatformLibrary and logical- und physical name mapping definitions during startup. No need to use any special OS functions to get the work done.

Otherwise you may look at my MSKICU config map, where I - during startup - look for several versions of ICU, tries to load different versions of ICU and when I know, which version is available I have to change the function names. More or less everything you want to do ...


jtu...@objektfabrik.de

unread,
Apr 25, 2013, 9:14:12 AM4/25/13
to va-sma...@googlegroups.com
Tom,

you should be careful. You never know who's going to haunt you in your next couple of nightmares :().
I'd say Linux accounts for a significant percentage of virtual and physical root servers on the web. And it is a supported platform of Vast, if I remember correctly.

I'm gonna tell my older brother about your post!

Joachim

jtu...@objektfabrik.de

unread,
Apr 25, 2013, 9:26:24 AM4/25/13
to va-sma...@googlegroups.com
Marten,

I've given up on pragma style function calls, a while ago, because I needed to use futures, which is only possible with instances of PlatformFunction.


The startup behavior of your MSKICU LIBRARY sounds interesting, I should take a look at it.
Reply all
Reply to author
Forward
0 new messages