Linking to a library via the linker on Windows?

Mike Parker aldacron at gmail.com
Wed Nov 20 04:02:37 PST 2013


On 11/20/2013 5:01 PM, Jeremy DeHaan wrote:
>
> The -L switch is just for sending switches to the linker. On OSX and
> Linux, it is -L-lLibraryName, like I mention before, where -lLibraryName
> is what actually gets passed to the linker. Basically I'm wondering of
> Optlink has a switch that does the same thing as the -l switch for
> linking to a library.

I don't believe there is anything like that. You just pass the lib name.

dmd foo.d bar.lib

You also pass a library path like so:

dmd foo.d bar.lib -L+../path/to/libs

This difference between Windows and other platforms creates a minor 
annoyance when making cross-platform build scripts for D (which, since 
dub came along, I don't worry about anymore). I vaguely recall a 
discussion around here somewhere about having DMD hide all of that 
behind a uniform syntax on the command line, for the library stuff at 
least. But it obviously didn't go anywhere.


More information about the Digitalmars-d-learn mailing list