Using .lib and .dll in D applications

moe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 21 19:38:23 PDT 2016


On Wednesday, 22 June 2016 at 01:40:47 UTC, Mike Parker wrote:
> On Tuesday, 21 June 2016 at 23:59:54 UTC, moe wrote:
>> I had some time to try it out and I finally got it to work. I 
>> have only tried in windows so far but there was a pitfall in 
>> windows. Your dll need a DllMain entry to compile. This was 
>> the only thing that was missing from your information.
>
> Right, I forgot about that. It's always optional in C and C++, 
> but in D we need to use it to initialize the runtime.
>
>
>> -- TestApp // all files for the app (separate project)
>> ---- packages
>> ------ DerelictUtil-master // contains the project for derelict
>> ---- source
>> ------ app.d // the app
>> ---- dub.json // the project file for the app
>
> This is not the way DerelictUtil, or any DUB package, is 
> intended to be used when you use DUB to manage your project. 
> You don't need to download it this way. You chould change your 
> dependency in TestApp:
>
>
>> 	"dependencies": {
>> 		"derelict-util":  "version=~>2.0.6",
>
> 2.0.6 is the latest. The '~>' means >=2.0.6 && <2.1.0, so that 
> if there is a 2.0.7 released, you can run 'dub upgrade' on your 
> project and start using it. The same for 2.0.8, 2.0.9, 2.0.n...
>
> Of course, if you have a reason for doing it that way, more 
> power to you :)

Yes, I did it intentionally. I wanted to ensure that the packages 
are self contained and check whether it would work fine like 
this. Basically I like to have a project that contains everything 
it needs with the versions originally used to build. It sort of 
creates a reference for learning.

For testing I would have also liked not to build a dub project 
for the PluginContract but rather have a simple iplugins.d file 
in a folder. I could not get it to be imported if it's outside of 
a dub project.

"importPaths": ["../PluginContract"]

Did not work for some reason. But that's a minor issue.


More information about the Digitalmars-d-learn mailing list