- - Making use of DLL Libraries in BB

From: [at]} <Wojtek>
Date: Mon, 10 Jul 2006 11:21:46 -0400 (EDT)

----boundary-LibPST-iamunique-1211082011_-_-
Content-type: text/plain

I changed the topic to avoid confusing Eryk.

On Mon, 10 Jul 2006, Campbell, Robert D (SELEX) (UK Edinburgh) wrote:

> AMD provide a C header file to define
> the interfaces. Is there an automatic way
> of translating these C header files into
> BBox DLL interface modules?

I asked this question to OMS long ago and I seem to recall they have some
sort of interface generator for their internal use. But it was long ago
and I do not remember. I never got hold of any such tool. I spent
considerable time on trial-and-error. The last part of my PowerPoint
presentation is devoted to this topic. I suppose my slides look extremely
boring to an average BB user, but they become fascinating to someone who
is just starting on this slippery road. I suggest you have a look.

The header files are part of the problem. The run-time may be another
part. I always succeded with my pedestrian approach, until one day I hit
a snag with National Instruments DLLs. I just could not load the DLL
to memory. I then realised that BB does not offer the diagnostic tools
for such a case. All I could say was that the DLL did not load, and
therefore the entire module tree above the DLL did not load either.
All the buttons were gray and did not work because the code was not
loaded.

I did not know what to do. OMS sent me a very simple module which bypasses
the entire BB runtime system. Using that module I determined that the
DLL sometimes would load, and sometimes would not load. Then I used the
Dependency Walker to find out that the National Instruments DLL loads
about 30 other NI's DLLs. One of these refused to init properly. My
collaborator who is fluent with Visual Studio debugger was able to watch
the exact sequence of calls which BB issued to load the DLL. The sequence
was weird and neither I nor OMS could make sense of it. The same guy
confirmed that Visual Basic also saw the problem, so we could shift the
blame away from BB.

At the end it turned out that National Instruments DLL system, which
is composed of several dozens DLLs, was not installed properly. Some
versions were inconsistent with some other versions. One of their DLLs
was overzelaous in its checks and refused to init properly, what
threw off the entire init chain. The end result was that the top-level
DLL refused to load. National Instruments' software is notorious for
this kind of problems.

Lessons learned, which may or may not be useful to you.

1. Avoid National Instruments. (Impossible, they have good hardware.)

2. In case of problems:

2.1 Use other software to load and test the DLLs. For example, Visual Basic.

2.2. Have someone handy who is fluent with Visual Studio debugger.

2.3. Study the low-level BB modules which load the DLLs via API calls.

2.4. Read M$ documentation concerning the DLL loading process.

3. In case of no problems:

3.1 Consider yourself lucky.

Hope it helps, -- W.

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy



----boundary-LibPST-iamunique-1211082011_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEkgY2hhbmdlZCB0aGUgdG9waWMgdG8gYXZvaWQg
Y29uZnVzaW5nIEVyeWsuXHBhcg0KXHBhcg0KT24gTW9uLCAxMCBKdWwgMjAwNiwgQ2FtcGJlbGws
IFJvYmVydCBEIChTRUxFWCkgKFVLIEVkaW5idXJnaCkgd3JvdGU6XHBhcg0KXHBhcg0KPiBBTUQg
cHJvdmlkZSBhIEMgaGVhZGVyIGZpbGUgdG8gZGVmaW5lXHBhcg0KPiB0aGUgaW50ZXJmYWNlcy4g
SXMgdGhlcmUgYW4gYXV0b21hdGljIHdheVxwYXINCj4gb2YgdHJhbnNsYXRpbmcgdGhlc2UgQyBo
ZWFkZXIgZmlsZXMgaW50b1xwYXINCj4gQkJveCBETEwgaW50ZXJmYWNlIG1vZHVsZXM/XHBhcg0K
XHBhcg0KSSBhc2tlZCB0aGlzIHF1ZXN0aW9uIHRvIE9NUyBsb25nIGFnbyBhbmQgSSBzZWVtIHRv
IHJlY2FsbCB0aGV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YXINCjIuIEluIGNhc2Ugb2YgcHJvYmxlbXM6
XHBhcg0KXHBhcg0KMi4xIFVzZSBvdGhlciBzb2Z0d2FyZSB0byBsb2FkIGFuZCB0ZXN0IHRoZSBE
TExzLiBGb3IgZXhhbXBsZSwgVmlzdWFsIEJhc2ljLlxwYXINClxwYXINCjIuMi4gSGF2ZSBzb21l
b25lIGhhbmR5IHdobyBpcyBmbHVlbnQgd2l0aCBWaXN1YWwgU3R1ZGlvIGRlYnVnZ2VyLlxwYXIN
ClxwYXINCjIuMy4gU3R1ZHkgdGhlIGxvdy1sZXZlbCBCQiBtb2R1bGVzIHdoaWNoIGxvYWQgdGhl
IERMTHMgdmlhIEFQSSBjYWxscy5ccGFyDQpccGFyDQoyLjQuIFJlYWQgTSQgZG9jdW1lbnRhdGlv
biBjb25jZXJuaW5nIHRoZSBETEwgbG9hZGluZyBwcm9jZXNzLlxwYXINClxwYXINCjMuIEluIGNh
c2Ugb2Ygbm8gcHJvYmxlbXM6XHBhcg0KXHBhcg0KMy4xIENvbnNpZGVyIHlvdXJzZWxmIGx1Y2t5
LlxwYXINClxwYXINCkhvcGUgaXQgaGVscHMsICAtLSBXLlxwYXINClxwYXINCi0tLSBCbGFja0Jv
eFxwYXINCi0tLSBzZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlNDUklCRSB0byBibGFja2JveEBv
YmVyb24uY2hccGFyDQp9fQB4QG9i


----boundary-LibPST-iamunique-1211082011_-_---
Received on Mon Jul 10 2006 - 17:21:46 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:27:49 UTC