Bug 454 – Setting LIB environment variable has no effect on Windows
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-10-24T16:53:00Z
Last change time
2014-02-15T13:20:33Z
Assigned to
bugzilla
Creator
digitalmars-com
Comments
Comment #0 by digitalmars-com — 2006-10-24T16:53:13Z
To reproduce problem:
Extract dmc.zip to C:\
Extract dmd.172.zip to C:\
Change directory to an alternate drive, for example "cd d:"
Create file test.d with the following contents:
import std.stdio;
void main() {
writefln("test");
}
set PATH=c:\dm\bin;c:\dmd\bin;%PATH%
dmd test.d
--- Fails to link because phobos.lib is not found ---
set LIB=c:\dm\lib;c:\dmd\lib
dmd test.d
--- Still fails to link because phobos.lib is not found ---
Add "%@P%\..\..\dmd\lib" to LIB in c:\dm\sc.ini for example:
LIB="%@P"\..\lib";"%@P%\..\..\dmd\lib";"%@P%\..\mfc\lib";%LIB%
dmd test.d
--- Now links successfully ---
This problem also leads me to believe that the dmd\bin\sc.ini may also not be working because it was set to the following:
LIB="%@P%\..\lib";\dm\lib
Although this is in the location of the dmd compiler, it should have been passed through to the linker like the LIB environment variable
Personally, I think dmd\bin\sc.ini should default to this:
LIB="%@P%\..\lib";"%@P%\..\..\dm\lib";%LIB%
The setting \dm\lib will not work if the linker is on a different drive from where the compile command is executed. I think it is more likely that the dm and dmd directories will be in the same relative location.
Comment #1 by aldacron — 2006-10-25T07:35:31Z
I don't think DMD (or DMC) ever claims to use the LIB environment variable.
If, like I have, you've ever tried installing eight different C++
compilers on the one machine, you learn to hate environment variables.
Part of the reason I gave DMD a look, was that DMC was the only compiler
that didn't interfere with the others.
[email protected] wrote:
> To reproduce problem:
>
> Extract dmc.zip to C:\
> Extract dmd.172.zip to C:\
> Change directory to an alternate drive, for example "cd d:"
> Create file test.d with the following contents:
> import std.stdio;
> void main() {
> writefln("test");
> }
>
> set PATH=c:\dm\bin;c:\dmd\bin;%PATH%
> dmd test.d
> --- Fails to link because phobos.lib is not found ---
> set LIB=c:\dm\lib;c:\dmd\lib
> dmd test.d
> --- Still fails to link because phobos.lib is not found ---
> Add "%@P%\..\..\dmd\lib" to LIB in c:\dm\sc.ini for example:
> LIB="%@P"\..\lib";"%@P%\..\..\dmd\lib";"%@P%\..\mfc\lib";%LIB%
> dmd test.d
> --- Now links successfully ---
>
> This problem also leads me to believe that the dmd\bin\sc.ini may also not be
> working because it was set to the following:
> LIB="%@P%\..\lib";\dm\lib
> Although this is in the location of the dmd compiler, it should have been
> passed through to the linker like the LIB environment variable
>
> Personally, I think dmd\bin\sc.ini should default to this:
> LIB="%@P%\..\lib";"%@P%\..\..\dm\lib";%LIB%
> The setting \dm\lib will not work if the linker is on a different drive from
> where the compile command is executed. I think it is more likely that the dm
> and dmd directories will be in the same relative location.
Comment #2 by dvdfrdmn — 2006-10-25T16:10:23Z
DMD does claim to do so on Windows. See the Environment Variables
section under Win32 D Compiler in
http://www.digitalmars.com/d/dcompiler.html
I agree that environment variables are problematic. I don't really care
to use the LIB environment variable, but it was the simplest way to
point to DMD installation and configuration problems. For example, there
are two sc.ini which could be used when building a D program:
dm/bin/sc.ini and dmd/bin/sc.ini. If I want to fix the error "phobos.lib
not found", which one do I change. It is not clear. There are LIB
settings in both.
Bradley
Don Clugston wrote:
> I don't think DMD (or DMC) ever claims to use the LIB environment variable.
> If, like I have, you've ever tried installing eight different C++
> compilers on the one machine, you learn to hate environment variables.
> Part of the reason I gave DMD a look, was that DMC was the only compiler
> that didn't interfere with the others.
>
> [email protected] wrote:
>> To reproduce problem:
>>
>> Extract dmc.zip to C:\
>> Extract dmd.172.zip to C:\
>> Change directory to an alternate drive, for example "cd d:"
>> Create file test.d with the following contents:
>> import std.stdio;
>> void main() {
>> writefln("test");
>> }
>>
>> set PATH=c:\dm\bin;c:\dmd\bin;%PATH%
>> dmd test.d
>> --- Fails to link because phobos.lib is not found ---
>> set LIB=c:\dm\lib;c:\dmd\lib
>> dmd test.d
>> --- Still fails to link because phobos.lib is not found ---
>> Add "%@P%\..\..\dmd\lib" to LIB in c:\dm\sc.ini for example:
>> LIB="%@P"\..\lib";"%@P%\..\..\dmd\lib";"%@P%\..\mfc\lib";%LIB%
>> dmd test.d
>> --- Now links successfully ---
>>
>> This problem also leads me to believe that the dmd\bin\sc.ini may also
>> not be
>> working because it was set to the following:
>> LIB="%@P%\..\lib";\dm\lib
>> Although this is in the location of the dmd compiler, it should have been
>> passed through to the linker like the LIB environment variable
>>
>> Personally, I think dmd\bin\sc.ini should default to this:
>> LIB="%@P%\..\lib";"%@P%\..\..\dm\lib";%LIB%
>> The setting \dm\lib will not work if the linker is on a different
>> drive from
>> where the compile command is executed. I think it is more likely that
>> the dm
>> and dmd directories will be in the same relative location.
>
Comment #3 by bugzilla — 2006-10-25T17:02:16Z
DMD only looks at the LIB environment variable if a LIB setting in sc.ini is not found. This is documented on the dcompiler.html page. It's what enables DMD to be independent of other compilers that use the LIB environment variable.
DMD sets the local (process specific) LIB environment to the contents of the sc.ini file, which is what LINK reads because LINK is run under the control of DMD.