Thread overview
Linking to a library via the linker on Windows?
Nov 20, 2013
Jeremy DeHaan
Nov 20, 2013
Ali Çehreli
Nov 20, 2013
Jeremy DeHaan
Nov 20, 2013
Mike Parker
Nov 20, 2013
Jeremy DeHaan
November 20, 2013
Like I said in the title, this is related to Windows. Basically, I'm looking to put a command line together to keep things consistent between Windows, OSX and Linux.

On OSX and Linux I would do -L-lLibraryName, but is there something similar that one can do on Windows? Or do I have to add LibraryName.lib to the file list? Just wondering!
November 20, 2013
On 11/19/2013 11:18 PM, Jeremy DeHaan wrote:
> Like I said in the title, this is related to Windows. Basically, I'm
> looking to put a command line together to keep things consistent between
> Windows, OSX and Linux.
>
> On OSX and Linux I would do -L-lLibraryName, but is there something
> similar that one can do on Windows? Or do I have to add LibraryName.lib
> to the file list? Just wondering!

It looks like it is -L on Windows as well:

  http://dlang.org/dmd-windows.html

Ali

November 20, 2013
On Wednesday, 20 November 2013 at 07:47:39 UTC, Ali Çehreli wrote:
> On 11/19/2013 11:18 PM, Jeremy DeHaan wrote:
>> Like I said in the title, this is related to Windows. Basically, I'm
>> looking to put a command line together to keep things consistent between
>> Windows, OSX and Linux.
>>
>> On OSX and Linux I would do -L-lLibraryName, but is there something
>> similar that one can do on Windows? Or do I have to add LibraryName.lib
>> to the file list? Just wondering!
>
> It looks like it is -L on Windows as well:
>
>   http://dlang.org/dmd-windows.html
>
> Ali

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.
November 20, 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.
November 20, 2013
On Wednesday, 20 November 2013 at 12:02:36 UTC, Mike Parker wrote:
> 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.

Ok, thanks. I kind of figured that was the case, but I posted in in hopes that there was something that I had missed.