Thread overview
How do I link outside /dmd/src/phobos?
Jul 03, 2004
Walter
July 03, 2004
Hi, I'm having trouble linking files outside the /dmd/src/phobos directory. Any ideas on what's going wrong?

1. I have a Hello World application named "dtest.d".
2. Compiling it in "c:/dmd/src/phobos/dtest" works, and links to produce a
valid EXE.
3. Compiling the exact same file in "d:/projects/dtest" works, but has link
warnings, and produces a corrupt EXE.

DM and DMD are installed in "c:/dm" and "c:/dmd" respectively.  My LIB environment variable is "c:\dmd\lib;c:\dm\lib".  I'm compiling on Win32 with DMD 0.86.

I'm rather stuck.  I'd love any help anyone can offer.  I've attached output to the end of this message.

-david

--------- Success Case: Compiling in
c:/dmd/src/phobos/dtest ------------------ C:\dmd\src\phobos\dtest>dmd dtest.d c:\dmd\bin\..\..\dm\bin\link.exe dtest,,,user32+kernel32/noi;

C:\dmd\src\phobos\dtest>dir
 Volume in drive C is APP DRIVE
 Volume Serial Number is 9CDC-919A

 Directory of C:\dmd\src\phobos\dtest

07/02/2004  10:01 PM    <DIR>          .
07/02/2004  10:01 PM    <DIR>          ..
07/02/2004  10:00 PM                94 dtest.d
07/02/2004  10:02 PM               383 dtest.obj
07/02/2004  10:02 PM             2,390 dtest.map
07/02/2004  10:02 PM            68,124 dtest.exe
               4 File(s)         70,991 bytes
               2 Dir(s)     579,637,248 bytes free

C:\dmd\src\phobos\dtest>dtest
Hello!

C:\dmd\src\phobos\dtest>

------------- Failure Case: Compiling in d:/projects/dtest -------------

D:\Projects\dtest>dmd dtest.d
c:\dmd\bin\..\..\dm\bin\link.exe dtest,,,user32+kernel32/noi;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

user32.lib
 Warning 2: File Not Found user32.lib
kernel32.lib
 Warning 2: File Not Found kernel32.lib
SNN.lib
 Warning 2: File Not Found SNN.lib
OPTLINK : Warning 23: No Stack
dtest.obj(dtest)
 Error 42: Symbol Undefined __acrtused_con
c:\dmd\bin\..\lib\phobos.lib(dmain2)
 Error 42: Symbol Undefined ___alloca
c:\dmd\bin\..\lib\phobos.lib(dmain2)
 Error 42: Symbol Undefined __except_list
c:\dmd\bin\..\lib\phobos.lib(dmain2)
 Error 42: Symbol Undefined _printf
dtest.obj(dtest)
 Error 42: Symbol Undefined _puts
c:\dmd\bin\..\lib\phobos.lib(dmain2)
 Error 42: Symbol Undefined _strlen
c:\dmd\bin\..\lib\phobos.lib(deh)
 Error 42: Symbol Undefined __local_except_handler
c:\dmd\bin\..\lib\phobos.lib(deh)
 Error 42: Symbol Undefined _RaiseException@16
c:\dmd\bin\..\lib\phobos.lib(deh)
 Error 42: Symbol Undefined __global_unwind
c:\dmd\bin\..\lib\phobos.lib(gc)
 Error 42: Symbol Undefined _malloc
c:\dmd\bin\..\lib\phobos.lib(gc)
 Error 42: Symbol Undefined _calloc
c:\dmd\bin\..\lib\phobos.lib(gc)
 Error 42: Symbol Undefined _memset
c:\dmd\bin\..\lib\phobos.lib(monitor)
 Error 42: Symbol Undefined _free
c:\dmd\bin\..\lib\phobos.lib(monitor)
 Error 42: Symbol Undefined _DeleteCriticalSection@4
c:\dmd\bin\..\lib\phobos.lib(monitor)
 Error 42: Symbol Undefined _LeaveCriticalSection@4
c:\dmd\bin\..\lib\phobos.lib(monitor)
 Error 42: Symbol Undefined __assert
c:\dmd\bin\..\lib\phobos.lib(monitor)
 Error 42: Symbol Undefined _EnterCriticalSection@4
c:\dmd\bin\..\lib\phobos.lib(monitor)
 Error 42: Symbol Undefined _InitializeCriticalSection@4
c:\dmd\bin\..\lib\phobos.lib(gcx)
 Error 42: Symbol Undefined _memcpy
c:\dmd\bin\..\lib\phobos.lib(gcx)
 Error 42: Symbol Undefined _memmove
c:\dmd\bin\..\lib\phobos.lib(gcx)
 Error 42: Symbol Undefined _realloc
c:\dmd\bin\..\lib\phobos.lib(gcx)
 Error 42: Symbol Undefined _GetThreadContext@8
c:\dmd\bin\..\lib\phobos.lib(win32)
 Error 42: Symbol Undefined __end
c:\dmd\bin\..\lib\phobos.lib(win32)
 Error 42: Symbol Undefined __xi_a
c:\dmd\bin\..\lib\phobos.lib(win32)
 Error 42: Symbol Undefined _VirtualFree@12
c:\dmd\bin\..\lib\phobos.lib(win32)
 Error 42: Symbol Undefined _VirtualAlloc@16
c:\dmd\bin\..\lib\phobos.lib(memset)
 Error 42: Symbol Undefined __fltused
c:\dmd\bin\..\lib\phobos.lib(thread)
 Error 42: Symbol Undefined __beginthreadex
c:\dmd\bin\..\lib\phobos.lib(thread)
 Error 42: Symbol Undefined _WaitForSingleObject@8
c:\dmd\bin\..\lib\phobos.lib(thread)
 Error 42: Symbol Undefined _SetThreadPriority@8
c:\dmd\bin\..\lib\phobos.lib(thread)
 Error 42: Symbol Undefined _GetCurrentThreadId@0
c:\dmd\bin\..\lib\phobos.lib(thread)
 Error 42: Symbol Undefined _SuspendThread@4
c:\dmd\bin\..\lib\phobos.lib(thread)
 Error 42: Symbol Undefined _ResumeThread@4
c:\dmd\bin\..\lib\phobos.lib(thread)
 Error 42: Symbol Undefined _GetCurrentThread@0
c:\dmd\bin\..\lib\phobos.lib(thread)
 Error 42: Symbol Undefined _GetCurrentProcess@0
c:\dmd\bin\..\lib\phobos.lib(thread)
 Error 42: Symbol Undefined _DuplicateHandle@28
c:\dmd\bin\..\lib\phobos.lib(thread)
 Error 42: Symbol Undefined _CloseHandle@4
c:\dmd\bin\..\lib\phobos.lib(string)
 Error 42: Symbol Undefined __ULDIV@
OPTLINK : Warning 134: No Start Address
--- errorlevel 38

D:\Projects\dtest>dir
 Volume in drive D is DATA DRIVE
 Volume Serial Number is 151C-1D09

 Directory of D:\Projects\dtest

07/02/2004  09:59 PM    <DIR>          .
07/02/2004  09:59 PM    <DIR>          ..
07/02/2004  10:00 PM                94 dtest.d
07/02/2004  10:01 PM               383 dtest.obj
07/02/2004  10:01 PM             4,380 dtest.map
07/02/2004  10:01 PM            21,844 dtest.exe
               4 File(s)         26,701 bytes
               2 Dir(s)     859,357,184 bytes free

D:\Projects\dtest>set LIB
lib=c:\dmd\lib;c:\dm\lib

D:\Projects\dtest>


July 03, 2004
Look in \dm\bin and see if there's an sc.ini, that will override the LIB environment variable settings. Also look for \dmd\bin\sc.ini.


July 03, 2004
Good idea.  However, I checked and I haven't done anything to the file -- it's still in its original state.  Here's its contents:

----- Original: c:/dmd/bin/sc.ini -----------
[Version]
version=7.51 Build 020

[Environment]
LIB="%@P%\..\lib";\dm\lib
DFLAGS="-I%@P%\..\src\phobos"
LINKCMD=%@P%\..\..\dm\bin\link.exe
-----------------------------------

I think the %@P% is the path of "dmd.exe", which translates to "c:/dmd/bin/dmd.exe".  Thus after translation, I think it should be:

LIB=c:/dmd/bin/../lib;dm/lib

OH!  Wow, there it is.  The DMD/lib path is translating fine, but the DM/lib path is failing because it's mapping to the D: drive (where my source file is) instead of the C: drive.  I've changed SC.INI as follows:

------ New: c:/dmd/sc.ini ----------
[Version]
version=7.51 Build 020

[Environment]
LIB="%@P%\..\lib";c:\dm\lib
DFLAGS="-I%@P%\..\src\phobos"
LINKCMD=%@P%\..\..\dm\bin\link.exe
----------------------------------

And that did the trick.  Thanks for the suggestion!

-david

"Walter" <newshound@digitalmars.com> wrote in message news:cc5ctj$1qen$1@digitaldaemon.com...
> Look in \dm\bin and see if there's an sc.ini, that will override the LIB environment variable settings. Also look for \dmd\bin\sc.ini.
>
>