How may I tell dub where to find a C library for linking?

evilrat evilrat666 at gmail.com
Mon Dec 10 05:24:16 UTC 2018


On Monday, 10 December 2018 at 02:59:21 UTC, Pablo De Nápoli 
wrote:
>
> On my system (Debian GNU/Linux 9, 64 bits) the library is in 
> the directory /usr/lib/llvm-6.0/lib/
>
> $ ls -l /usr/lib/llvm-6.0/lib/libLLVM.so
> lrwxrwxrwx 1 root root 14 oct 24 19:44 
> /usr/lib/llvm-6.0/lib/libLLVM.so -> libLLVM-6.0.so
>
> But how am I supposed to tell dub this, so it passes this 
> information to the linker??
>
> I guess I should set "libs" in dubs.json
>

IIRC your guess is correct. "libs" is passed directly to linker 
and is the only way to do it, so you just do smth like this

    "libs" : ["-L/usr/lib/llvm-6.0/lib/", "libLLVM-6.0"]

note that this -L will be extended for linker as -L-L...
(also note that you can do platform specific way with 
"libs-windows", "libs-posix"? to pick proper paths per platform)

Though I'm not a linux pro and don't remember if linking to .so 
is same as linking import library, if this is not the case you 
just need to set RPATH or whatever it is so it can find dynamic 
lib.


More information about the Digitalmars-d-learn mailing list