[llvm-dev] Using LLD to link against third-party libraries? How?
David Chisnall via llvm-dev
llvm-dev at lists.llvm.org
Fri Dec 14 02:10:15 PST 2018
On 12/12/2018 16:16, Osman Zakir via llvm-dev wrote:
> I need them so I can build stuff using clang or clang-cl with its C++
> standard libraries. To make sure that lld-link won't give errors about
> missing symbols from any standard libraries.
Looking at your linker errors, it looks as if this is the root of the
problem. Different C++ standard library implementations may be source
compatible, but they are *not* binary compatible. If you have compiled
some library with the native toolchain (or downloaded a pre-built
library built with the native toolchain) then all of its interfaces that
use standard library types will depend on the version from your Visual
Studio C++ standard library. When you compile with libc++, you will get
undefined symbols in your binary that refer to versions of these
functions using the libc++ versions of the same source-language types.
When you try to link this with the library, it will fail because the
library doesn't expose those symbols.
If you want to link C++ libraries, you need to make sure that they were
compiled and linked with the same C++ standard library. On Windows,
most native libraries expose either C or COM interfaces to avoid any
dependency at the boundary on C++ library types.
More information about the llvm-dev