www.digitalmars.com         C & C++   DMDScript  

c++.command-line - Specifying library search path for dmc

It seems that dmc has no option to set the library search path like a
simple -L/usr/local/lib for gcc. Is this right? If so, I discovered
this trick to let dmc do what I want (dmc v8.50). Searching the
formus only revealed post from people with similar library path
problems and answers that involve a separate call of the linker or
setting of environment variables. Sorry if my missed a "proper
solution" during my quick scan.

Assume I have a library (relative to the current directory, which may
be named src) ..\lib\mylib.lib, so I want to pass "..\lib\" as the
library path and "mylib.lib" as the name:

dmc myprog.c ..\lib\.lib mylib.lib

The trick:
dmc thinks that "..\lib\.lib" is a library, strips ".lib" from it and
passes "..\lib\" to the linker. The docs of the linker say that it is
interpreted as a path, because is has a trailing backslash.
Jul 25 2008