Using .lib and .dll in D applications

moe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 22 11:03:59 PDT 2016


On Wednesday, 22 June 2016 at 05:34:33 UTC, Mike Parker wrote:
> On Wednesday, 22 June 2016 at 03:06:29 UTC, moe wrote:
>
>> I meant like this:
>>
>> - PluginContract // not a dub project, just some folder
>> -- iplugin.d
>>
>> - 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
>>
>> The only dub project would be TestApp. PluginContract would 
>> just be some folder completely outside the TestApp dub 
>> project. I could not get a relative path to work like this.
>
> Just to be clear, are you compiling iplugin.d as well? I 
> assumed you were referring to a compiler error (i.e. missing 
> import), but based on this post I would guess you're getting a 
> linker error. You should probably add this to your dub.json in 
> addition to the importPaths:
>
> "sourceFiles": ["../PluginContract/iplugin.d"]



I have added all of these to the dub.json:

"sourcePaths": ["../PluginContract"],
"importPaths": ["../PluginContract"],
"sourceFiles": ["../PluginContract/iplugin.d"],

In my app I use:
import iplugin;

I would expect that both the compiler and the linker finds the 
needed files. I would also prefer a path to link a folder rather 
than adding files individually. It seams more error prone when I 
have to remember to add every file in a bigger project. However, 
every combination of the above seams to fail. With a linker error.

Linking...
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 23: No Stack
.dub\build\debug-debug-windows-x86-dmd_2071-0BEC1C92408DC77EE5C50BCF4B1225A9\tes
tapp.obj(testapp)
  Error 42: Symbol Undefined _D18TypeInfo_Interface6__vtblZ
.dub\build\debug-debug-windows-x86-dmd_2071-0BEC1C92408DC77EE5C50BCF4B1225A9\tes
tapp.obj(testapp)
  Error 42: Symbol Undefined _D14TypeInfo_Class6__vtblZ
OPTLINK : Warning 134: No Start Address
--- errorlevel 2
dmd failed with exit code 2.


Without the adjustments in the dub.json I get the following error 
(But that is expected if dub only searches in the source folder 
by default):

testplugin ~master: building configuration "debug"...
source\SomePlugin.d(3,8): Error: module iplugin is in file 
'iplugin.d' which can
not be read
import path[0] = source
import path[1] = C:\D\dmd2\windows\bin\..\..\src\phobos
import path[2] = C:\D\dmd2\windows\bin\..\..\src\druntime\import
dmd failed with exit code 1.


More information about the Digitalmars-d-learn mailing list