pragma(linkerDirective,_) removes double quotes, dmd ignores LIB

Adam D Ruppe destructionator at gmail.com
Mon Nov 28 14:41:01 UTC 2022


On Monday, 28 November 2022 at 14:19:46 UTC, NonNull wrote:
> double quotes whatsoever into the linker command line via 
> pragma(linkerDirective,_).

linkerDirective doesn't add things to the linker command line at 
all.

https://dlang.org/spec/pragma.html#linkerDirective

"Implementation Defined: The string literal specifies a linker 
directive to be embedded in the generated object file. Linker 
directives are only supported for MS-COFF output. "


"embedded in the generated object file" is not "added to linker 
command line". Only some switches are supported for embedding and 
the syntax might be different. This is why the error message also 
says "invalid directive".

This is the Microsoft doc page for the feature the pragma uses:

https://learn.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?source=recommendations&view=msvc-170#linker

It looks like they actually removed some options in the recent 
update, I know /SUBSYSTEM used to work there too but it is no 
longer listed and there's people on the web saying it stopped 
working after updating to the 2022 visual studio. So yeah I think 
they removed support for that.

But /LIBPATH has never been supported as far as I know.

You'll want to use a build script/makefile/dub config/whatever to 
set linker command line options.


More information about the Digitalmars-d-learn mailing list