Reputation: 177
What programming language can support same dll?
I just bought a product bundled with 3 api: JAVA, .NET, C++
In each api folder, I found dll files on .Net and C++ folder while jar file on java folder. My question is, can i integrate dll on different languages? I already tried implementing a dll in java using jni and it worked. I read that dll supports multi language program but why is that different dll were used with .net and c++?
Any answer will be appreciated. Thanks
Upvotes: 2
Views: 8782
Reputation: 28987
It would be perfectly possible to call the C++ DLL from C# (or other .Net language), but it would be a matter of writing P/Invoke code to do so (and this is hard).
As a matter of convenience, the authors of the API have written a native C# wrapper for you which you can use much as you would use any other C# class.
(The above assumes that the "real" DLL is the C++ one - it could actually be the C# one, and the C++ DLL is a wrapper written in C++/CLI. Doesn't actually much change the logic.)
Similarly writing JNI interfaces is tedious and fiddly - much better to do it once (right), rather than answer all the support calls "How do I..."
Upvotes: 2
Reputation: 587
According to Wikipedia as of 15th of November 2016,
Dynamic-link library (or DLL) is Microsoft's implementation of the shared library concept in the Microsoft Windows and OS/2 operating systems. These libraries usually have the file extension DLL, OCX (for libraries containing ActiveX controls), or DRV (for legacy system drivers). The file formats for DLLs are the same as for Windows EXE files – that is, Portable Executable (PE) for 32-bit and 64-bit Windows, and New Executable (NE) for 16-bit Windows. As with EXEs, DLLs can contain code, data, and resources, in any combination.
This means that you can store different things including code into a DLL. A DLL is loaded at runtime. You can load DLLs according to a language's supported features.
You can do this in the following ways:-
Another point to be noted is that the DLL must be compiled for the operating system you will be calling it on before hand. Different operating systems have different file extensions / concepts for DLLs as an analogy.
For example, the following workflow is valid,
Compile DLL in C++ -> Store in Disk -> Call your DLL from any other language like C# / C++/ Java
Upvotes: 1