www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - LIB flag on Windows DMD (nagging)

reply Bane <branimir.milosavljevic gmail.com> writes:
(Disclaimer: I don't know is this solved on dmd later than 1.030, I'm stuck
with it past...)

Problem: PITA when using DMD on windows with custom library paths

Example: there is pragma(lib, "mylib.lib"); somewhere in the code. mylib.lib is
not on the known path for the compiler (lets say c:\xxx). How to tell dmd where
to look for it?


1.
dmd ... -Ic:\xxx
 won't work


2. dmd ... -Lsome_flag_to_optlink
 won't work (I haven't found in optlink docs that you can pass argument for lib
path)


3. set LIB=c:\xxx dmd ...
  won't work (sc.ini in dmd binary folder rewrites LIB env. var with the one in
it)


4. bud ... -LIBPATH=c:\xxx ...
 wont work (same as 3)


4. edit sc.ini in dmd folder and add c:\xxx
 not smart (not all projects need that lib path, even worse if different
projects use 2 distinct mylib.lib)


5. create sc.ini in project folder and add c:\xxx to LIB env var
 pain in the royal behind (lot of duplication, as original LIB, DFLAGS and
LINKCMD are not changed, also, full path to dmd folder must be supplied as % P%
points to project folder now)


Is there a way to remedy it? Or just to edit line in original sc.ini in dmd folder from LIB="% P%\..\lib";\dm\lib to LIB="% P%\..\lib";\dm\lib;%LIB% it seems that adding %LIB% at the end apends existing LIB env var, so paths are preserved.
Mar 30 2010
next sibling parent reply "Robert Jacques" <sandford jhu.edu> writes:
On Tue, 30 Mar 2010 06:31:44 -0300, Bane  
<branimir.milosavljevic gmail.com> wrote:
 (Disclaimer: I don't know is this solved on dmd later than 1.030, I'm  
 stuck with it past...)

 Problem: PITA when using DMD on windows with custom library paths

 Example: there is pragma(lib, "mylib.lib"); somewhere in the code.  
 mylib.lib is not on the known path for the compiler (lets say c:\xxx).  
 How to tell dmd where to look for it?


 1.
 dmd ... -Ic:\xxx
 won't work


2. dmd ... -Lsome_flag_to_optlink
 won't work (I haven't found in optlink docs that you can pass argument  
 for lib path)


3. set LIB=c:\xxx dmd ... >> won't work (sc.ini in dmd binary folder rewrites LIB env. var with the one in it) 4. bud ... -LIBPATH=c:\xxx ...
 wont work (same as 3)


4. edit sc.ini in dmd folder and add c:\xxx
 not smart (not all projects need that lib path, even worse if  
 different projects use 2 distinct mylib.lib)


5. create sc.ini in project folder and add c:\xxx to LIB env var
 pain in the royal behind (lot of duplication, as original LIB, DFLAGS  
 and LINKCMD are not changed, also, full path to dmd folder must be  
 supplied as % P% points to project folder now)


Is there a way to remedy it? Or just to edit line in original sc.ini in dmd folder from LIB="% P%\..\lib";\dm\lib to LIB="% P%\..\lib";\dm\lib;%LIB% it seems that adding %LIB% at the end apends existing LIB env var, so paths are preserved.

I don't know about the general case, but I use pragma(lib,...) with a library in my working directory and it works.
Mar 30 2010
parent Bane <branimir.milosavljevic gmail.com> writes:
Robert Jacques Wrote:

 I don't know about the general case, but I use pragma(lib,...) with a  
 library in my working directory and it works.

That works by default. Problem is when different projects share same libs from some other folder.
Mar 30 2010
prev sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Bane wrote:
 Or just to edit line in original sc.ini in dmd folder from
 
  LIB="% P%\..\lib";\dm\lib
 
 to
 
  LIB="% P%\..\lib";\dm\lib;%LIB%
 
 it seems that adding %LIB% at the end apends existing LIB env var, so paths
are preserved.

The reason this is not the default, and why sc.ini overrides the environment, is because changing the environment for each compiler is tedious and error prone. dmd is designed to default to be independent of the environment for that reason.
Mar 30 2010