[llvm-dev] Using LLD to link against third-party libraries? How?

Fabian Giesen via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 11 13:38:00 PST 2018


What do you mean by "third-party" here?

To link with a library, either:

1. Add the library to the link line. Not with any command line switches 
in front, just add it as you would an object file. You mention ".lib" so 
I'm assuming you're on Windows or something similar? In that case, you'd 
just have "foo.obj bar.obj path/to/library.lib". Just list it like you 
would any object file.

2. Add the path containing the library to the library search directory 
(that's what uppercase "-L" does) then specify the name of the library 
via "-l". In your case that would look something like "-Lpath/to foo.obj 
bar.obj -llibrary". For Unix-like linkers, this will search for the 
files "liblibrary.so" and "liblibrary.a" in the search paths specified 
via -L ("lib" prepended to the name of the library, and ".so" or ".a" 
extensions appended). I'm not sure what rules GNU LD, Gold or LLD use to 
figure out what files to search on Windows host platforms.

-Fabian

On 12/11/2018 11:20 AM, Osman Zakir via llvm-dev wrote:
> How do I use LLD to link against third-party libraries?  I've tried 
> providing the full path along with the library name in the same argument 
> with the -L flag (i.e. -L path/to/library.lib) without success.  I 
> really want to know how I can do this.  Thanks in advance.
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 


More information about the llvm-dev mailing list