DUB: How to link an external library on Windows 10?

Steven Schveighoffer schveiguy at gmail.com
Fri Aug 27 15:24:14 UTC 2021


On 8/27/21 11:19 AM, Ki Rill wrote:
> On Friday, 27 August 2021 at 14:52:15 UTC, Mike Parker wrote:
>> On Friday, 27 August 2021 at 14:46:56 UTC, Ki Rill wrote:
>>> On Friday, 27 August 2021 at 13:54:18 UTC, Steven Schveighoffer wrote:
>>>> [...]
>>>
>>> How do I tell DUB where to look for `raylibdll.lib` and `raylib.dll`? 
>>> Via `lflags` section? What if I put them in a different folder 
>>> instead of the project's directory?
>>
>> Yes. The path goes in the lflags directive using whatever the 
>> linker-specific flag is. I assume for lld it's `-Lpath`. For MS link 
>> it's `/LIBPATH:path`.

To clarify, the .dll file's path is not embedded into the binary. You 
have to add it's path to your "Path" environment variable in order for 
your game to load it.

But you do need the /LIBPATH option to tell it where to find the .lib file.

> 
> I've added lfags:
> ```
> "lflags": ["/LIBPATH:C:\\Users\\Username\\Desktop\\test\\source\\"]
> ```
> 
> But now it cannot find the following:
> ```
> msvcrt120.lib
> OLDNAMES.lib
> shell32.lib
> ```
> 
> I think `lfags` overrides the default search path and I need to add it 
> manually as well. But what is that path on Windows?

That shouldn't happen. I've never had to tell it where the default 
libraries are. For sure the lflags does NOT override the default library 
search paths.

I suspect your MSVC installation is bad, or there are some other 
switches causing problems.

-Steve


More information about the Digitalmars-d-learn mailing list