Linking on MS Windows.

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 5 11:37:43 PDT 2016


On Friday, August 05, 2016 18:28:48 ciechowoj via Digitalmars-d-learn wrote:
> Is default dmd linker (on MS Windows, OPTILINK) supposed to link
> against static libraries created with Visual Studio?
>
> Specifically I want to link a project compiled on windows with
> dmd against pre-compiled library `libclang.lib` from LLVM suite.
> I'm pretty sure they used Visual Studio to compile the library.

dmc (and thus optlink) and VS use different library formats. So, you can't
mix any libraries between them unless you dynamically load them at runtime
(which can't be done with a statically linked library). Neither statically
linked libraries nor dynamically linked libraries compiled by one compile
can be mixed with those from the other.

I know that dmd supports VS' binary format and linker for 64-bit (dmc and
optlink were never updated to support 64-bit), and I think that 32-bit
support for using VS' library format and linker were added later. So, I'm
fairly certain that you could compile your D program to be compatible with
that statically linked library by using the right compiler flag with dmd.
But I don't use Windows much aside from work, so I'm not very familiar with
how to use dmd with Windows beyond the basics and am not going to be very
helpful in telling you how to actually do it. You might be able to figure it
out by looking at dmd's compiler flags, but if not, I'm sure that someone
else here who actually uses Windows with D will be able to tell you.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list