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

Pablo De Nápoli nospam at dev.null
Mon Dec 10 02:59:21 UTC 2018


Hi,

I was playing with the example in

https://github.com/MoritzMaxeiner/llvm-d/tree/master/examples/fibonacci

When I try to build it using dub, the linker cannot find the LLVM 
library

$ dub build
Performing "debug" build using /usr/bin/dmd for x86_64.
llvm-d 2.4.1: target for configuration "native-target" is up to 
date.
fibonacci ~master: building configuration "link-single"...
Linking...
/usr/bin/ld: cannot find -lLLVM
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
/usr/bin/dmd failed with exit code 1.

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

Off course I have tried to read the dub documentation (like 
https://code.dlang.org/package-format?lang=json) but it was not 
clear enough to me. Please note that this library cannot be find 
by pkgconfig.

Many thanks!
Pablo


More information about the Digitalmars-d-learn mailing list