www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - linking to shared lib on Windows

reply cartland <example example.com> writes:
I now have the following working on Linux and macOS.

-----
name "myapp"
targetType "executable"
description "A minimal D application."
authors "bartland"
copyright "Copyright © 2019, bartland"
license "public"
libs "mylib"
lflags "-L../../_cache/" "-rpath" "../../_cache/"
-------

What is the approach on Windows these days (many posts on the 
matter seem out of date)? The shared C dll was built in 
MSYS2/MINGW32.

On Windows (PATH=C:\D\dmd2\windows\bin;C:\D\dmc\dm\bin):
(Looks like it's invoking the MS linker?)

Linking...
C:\D\dmd2\windows\bin\dmd.exe 
-of.dub\build\application-debug-windows-x86_64-dmd_2089-5F4166A8E1793C219FB49E
77A7D7D35\myapp.exe .dub\build\application-debug-windows-x86_64-dmd_2089-5F4166A8E1793C219FB49E
77A7D7D35\myapp.obj mylib.lib -L-L../../_cache/ -L-rpath -L../../_cache/ -m64 -g
LINK : warning LNK4044: unrecognized option '/L../../_cache/'; 
ignored
LINK : warning LNK4044: unrecognized option '/rpath'; ignored
LINK : fatal error LNK1104: cannot open file '../../_cache/.obj'
Error: linker exited with status 1104
Nov 12 2019
parent reply cartland <example example.com> writes:
On Wednesday, 13 November 2019 at 00:47:11 UTC, cartland wrote:
 I now have the following working on Linux and macOS.
 *snip*

 What is the approach on Windows these days (many posts on the 
 matter seem out of date)? The shared C dll was built in 
 MSYS2/MINGW32.

*snip*
FYI Got it working using the sdl below. libmylib.lib/dll is built using the msys2 mingw32 toolchain. I have a cmd file which wraps dub: rdub.cmd ---------- set DLANG_DUB_LIBS=..\..\_cache\libmylib mkdir bin copy "%DLANG_DUB_LIBS%.dll" bin dub -a x86_mscoff %1 %2 %3 %4 %5 ---------- dub.sdl ------------ name "myapp" targetType "executable" description "A minimal D application." authors "bartland" copyright "Copyright © 2019, bartland" license "public" libs "$DLANG_DUB_LIBS" platform="windows" libs "mylib" platform="posix" lflags "-L../../_cache/" "-rpath" "../../_cache/" platform="posix" targetPath "bin" -------------
Nov 19 2019
parent cartland <example example.com> writes:
On Tuesday, 19 November 2019 at 10:10:14 UTC, cartland wrote:
 On Wednesday, 13 November 2019 at 00:47:11 UTC, cartland wrote:
*snip*
PS I uninstalled ALL Microsoft build tools and Visual Studios, then reinstalled DMD and LDC.
Nov 19 2019