Skip to content

Long environment variable value causes link failure #25

@Geod24

Description

@Geod24

Transferred from: https://issues.dlang.org/show_bug.cgi?id=1327
Platform: x86 Windows

User Bruce Adams reported (2007-07-09 20:30:06 CEST):

Hi
I had some problems getting DMD to play nicely with cygwin. It turns out the problem was down to a long environment variable value. As a newcomer to D I was very confused. It was not at all obvious what was happening.

Regards,

Bruce.

F:\projects\Agenda>c:\cygwin\bin\make dtest2
dmc hello.d -o hello
c:\dmd\bin\..\..\dm\bin\link.exe hello,,,user32+kernel32/noi;
c:\dmd\bin\..\..\dm\bin\link.exe hello,,,user32+kernel32/noi;
hello.d:
hello.d:
link hello+hello,,,user32+kernel32/noi;

F:\projects\Agenda>set GCCINCDIR="C:\cygwin\usr\include;C:\cygwin\usr\include\sys;C:\cygwin\usr\include\w32api;C:\cygwin\usr\local\i686-pc-cygwin\include;C:\cygwin\usr\local\i686-pc-cygwin\include\sys;C:\cygwin\usr\include\c++\3.4.4;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin\bits;C:\cygwin\lib\gcc-lib\i686-pc-cygwin\3.4.4\include;C:\cygwin\usr\include;C:\cygwin\usr\include\sys;C:\cygwin\usr\include\w32api;C:\cygwin\usr\local\i686-pc-cygwin\include;C:\cygwin\usr\local\i686-pc-cygwin\include\sys;C:\cygwin\usr\include\c++\3.4.4;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin\bits;C:\cygwin\lib\gcc\i686-pc-cygwin\C:\cygwin\usr\include;C:\cygwin\usr\include\sys;C:\cygwin\usr\include\w32api;C:\cygwin\usr\local\i686-pc-cygwin\include;C:\cygwin\usr\local\i686-pc-cygwin\include\sys;C:\cygwin\usr\include\c++\3.4.4;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin\bits;C:\cygwin\lib\gcc-lib\i686-pc-cygwin\3.4.4\include;C:\cygwin\usr\include;C:\cygwin\usr\include\sys;C:\cygwin\usr\include\w32api;C:\cygwin\usr\local\i686-pc-cygwin\include;C:\cygwin\usr\local\i686-pc-cygwin\include\sys;C:\cygwin\usr\include\c++\3.4.4;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin\bits\include;C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include\c++;;C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include\c++\i686-pc-cygwin;C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include"

F:\projects\Agenda>c:\cygwin\bin\make dtest2
dmc hello.d -o hello
c:\dmd\bin\..\..\dm\bin\link.exe hello,,,user32+kernel32/noi;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

phobos.lib
 Warning 2: File Not Found phobos.lib
OPTLINK : Warning 23: No Stack
hello.obj(hello)
 Error 42: Symbol Undefined _main
hello.obj(hello)
 Error 42: Symbol Undefined __acrtused_con
OPTLINK : Warning 134: No Start Address
--- errorlevel 2
hello.d:
--- errorlevel 2
make: *** [dtest2] Error 2

User Bruce Adams responded (2007-07-09 20:51:24 CEST):

I can confirm this also happens on the latest version (v2.002)

User @baxissimo responded (2007-07-09 21:10:01 CEST):

Ouch. That must have taken ages to figure out.

Actually it seems to be related to both the variable name and its value. For instance "XCCINCDIR" worked ok, and many values of GCCINCDIR are ok for me. But other variables caused the problem too, like "FOOINCDIR". I can't really determine a pattern.

In any event you should probably use 'dmd' to compile D code and not 'dmc' (which is a C++ compiler) ;-)

User @Deewiant responded (2007-07-10 05:49:29 CEST):

Keep the version at the oldest, not the newest, relevant value, please.

User @CyberShadow responded (2014-10-02 15:34:22 CEST):

OPTLINK doesn't see the LIB variable if the environment is too big. In my case it starts to misbehave if the environment is longer than about 8K, but I guess the exact size varies depending on where LIB is in the environment. This affects D2 as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions