Thread overview
Newbie question: how do I specify (at the command line) a library in the same directory as my .obj file?
Aug 21, 2019
WhatMeWorry
Aug 22, 2019
David Nadlinger
Aug 22, 2019
WhatMeWorry
Aug 23, 2019
kinke
August 21, 2019
So I've got a tiny program.

C:\Users\me\klondike>ldc2 -c klondike

The import of the library symbols are successful. The .obj file is created.

Directory of C:\Users\me\klondike
08/13/2019  03:40 PM           803,328 test.lib
08/21/2019  06:17 PM             7,213 klondike.d
08/21/2019  06:39 PM           475,609 klondike.obj

But when I try linking, I get errors.

C:\Users\me\klondike>ldc2 klondike
lld-link: error: undefined symbol: _D8colorize7winterm16WinTermEmulation10initializeMFNbNiZv
>>> referenced by klondike.obj:(_D8colorize6cwrite__TQkTAyaZQrFS3std5stdio4FileQxZv)

Is there a way to specify my test.lib in the command?


August 22, 2019
On 22 Aug 2019, at 0:55, WhatMeWorry via digitalmars-d-ldc wrote:
> Is there a way to specify my test.lib in the command?

Typically, either supply the library file as a command line argument and let LDC handle it, or use the `-L` option to supply the appropriate flags directly to the linker. —David
August 22, 2019
On Thursday, 22 August 2019 at 00:06:48 UTC, David Nadlinger wrote:
> On 22 Aug 2019, at 0:55, WhatMeWorry via digitalmars-d-ldc wrote:
>> Is there a way to specify my test.lib in the command?
>
> Typically, either supply the library file as a command line argument and let LDC handle it, or use the `-L` option to supply the appropriate flags directly to the linker. —David

Sorry to be dense here, but shouldn't the command below work?


08/21/2019  06:17 PM             7,213 tiny.d
08/21/2019  12:23 PM           475,605 tiny.obj
08/19/2019  03:40 PM           803,328 test.lib

C:\Users\me\tiny>ldc2 tiny.d test.lib
lld-link: error: test.lib: unknown file type
Error: linking with LLD failed

How much clearer can this be?

I've googled for the answer but I either get these huge dissertations on compiler/linkers or just a repeat of the ldc2 -help



August 23, 2019
On Thursday, 22 August 2019 at 17:32:54 UTC, WhatMeWorry wrote:
> C:\Users\me\tiny>ldc2 tiny.d test.lib
> lld-link: error: test.lib: unknown file type
> Error: linking with LLD failed

You probably specified an incompatible .lib (e.g., 32-bit lib for 64-bit LDC target). The LLD error message is minimalistic.