www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Unable to link Windows examples

reply Blackspawn <a b.com> writes:
Hi!

I don't know if this is a bug or if it's just my fault, but I didn't 
find a general help newsgroup for D so I'm just posting it here.

I have installed the D compiler on my Win2k system along with the linker 
and the tools. I'm using the Zeus editor to compile/edit sources. Now 
the problem is, I am unable to correctly link any of the windows 
examples in the \dmd\samples\d\ directory. After compiling/linking, I do 
get an .exe file, but it seems to be broken (Windows reports "xxx is not 
a valid Win32 application). Also, I'm getting strange linker errors. For 
example, if I try to compile and link chello.d, I get:

parse     chello
semantic  chello
semantic2 chello
semantic3 chello
code      chello
generating code for function 'this'
generating code for function '_dtor'
generating code for function 'Init'
generating code for function 'QueryInterface'
generating code for function 'Release'
generating code for function 'Print'
c:\dm\bin\link.exe chello,,,user32+kernel32/co/noi;

OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

chello.obj(chello)
  Error 42: Symbol Undefined _D9invariant12_d_invariantFC6ObjectZv
chello.obj(chello)
  Error 42: Symbol Undefined _IID_IUnknown
chello.obj(chello)
  Error 42: Symbol Undefined __D3std1c7windows3com9ComObject6AddRefWZk 0
chello.obj(chello)
  Error 42: Symbol Undefined _D6object6Object8opEqualsFC6ObjectZi
chello.obj(chello)
  Error 42: Symbol Undefined _D6object6Object5opCmpFC6ObjectZi
chello.obj(chello)
  Error 42: Symbol Undefined _D6object6Object6toHashFZk
chello.obj(chello)
  Error 42: Symbol Undefined _D6object6Object8toStringFZAa
chello.obj(chello)
  Error 42: Symbol Undefined _D6object6Object5printFZv
chello.obj(chello)
  Error 42: Symbol Undefined __Class_3std1c7windows3com9ComObject
chello.obj(chello)
  Error 42: Symbol Undefined __vtbl_9ClassInfo
chello.obj(chello)
  Error 42: Symbol Undefined __Interface_3std1c7windows3com8IUnknown
OPTLINK : Warning 134: No Start Address

--- errorlevel 11


Another example, winsamp.d:

parse     winsamp
semantic  winsamp
semantic2 winsamp
semantic3 winsamp
code      winsamp
generating code for function 'WindowProc'
generating code for function 'doit'
generating code for function 'WinMain'
c:\dm\bin\link.exe winsamp,,,user32+kernel32/co/noi;

OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

winsamp.obj(winsamp)
  Error 42: Symbol Undefined _SelectObject 8
winsamp.obj(winsamp)
  Error 42: Symbol Undefined _SetTextAlign 8
winsamp.obj(winsamp)
  Error 42: Symbol Undefined _TextOutA 20
winsamp.obj(winsamp)
  Error 42: Symbol Undefined _CreateFontA 56

--- errorlevel 4

Is this the fault of the linker/compiler or am I missing something here? :/


PS: I get the same errors when I try to compile and link the examples 
manually, so it's not the fault of my IDE.

PPS: All non-windows examples, like for example dhry.d, compile and link 
just fine.
Nov 23 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
In article <cnvc4h$lm1$1 digitaldaemon.com>, Blackspawn says...
winsamp.obj(winsamp)
  Error 42: Symbol Undefined _SelectObject 8
winsamp.obj(winsamp)
  Error 42: Symbol Undefined _SetTextAlign 8
winsamp.obj(winsamp)
  Error 42: Symbol Undefined _TextOutA 20
winsamp.obj(winsamp)
  Error 42: Symbol Undefined _CreateFontA 56

--- errorlevel 4

Is this the fault of the linker/compiler or am I missing something here? :/


PS: I get the same errors when I try to compile and link the examples 
manually, so it's not the fault of my IDE.

PPS: All non-windows examples, like for example dhry.d, compile and link 
just fine.

It sounds like you're not compiling and linking with the right options. For example with dserver you need to add "chello.obj uuid.lib ole32.lib advapi32.lib kernel32.lib user32.lib" to compile command at the command prompt. I'm not sure if you can do this from your syntax editor. There are some hints in \samples\d\all.sh. Also compile htmlget like this: dmd htmlget.d ws2_32.lib jcc7
Nov 23 2004
parent reply Blackspawn <a b.com> writes:
J C Calvarese wrote:

 It sounds like you're not compiling and linking with the right options. For
 example with dserver you need to add "chello.obj uuid.lib ole32.lib
advapi32.lib
 kernel32.lib user32.lib" to compile command at the command prompt. I'm not sure
 if you can do this from your syntax editor.
 
 There are some hints in \samples\d\all.sh.
 

Well, I have also tried to execute \dmd\samples\d\run.bat which compiles and links all examples automatically by running all.sh, but all the resulting .exe files are invalid, too...
Nov 23 2004
parent reply Blackspawn <a b.com> writes:
Blackspawn wrote:
 J C Calvarese wrote:
 
 It sounds like you're not compiling and linking with the right 
 options. For
 example with dserver you need to add "chello.obj uuid.lib ole32.lib 
 advapi32.lib
 kernel32.lib user32.lib" to compile command at the command prompt. I'm 
 not sure
 if you can do this from your syntax editor.

 There are some hints in \samples\d\all.sh.

Well, I have also tried to execute \dmd\samples\d\run.bat which compiles and links all examples automatically by running all.sh, but all the resulting .exe files are invalid, too...

Correction, the non-windows examples compile and link correctly, while the windows examples are not linked at all...
Nov 23 2004
next sibling parent reply Regan Heath <regan netwin.co.nz> writes:
On Tue, 23 Nov 2004 18:14:27 +0100, Blackspawn <a b.com> wrote:
 Blackspawn wrote:
 J C Calvarese wrote:

 It sounds like you're not compiling and linking with the right 
 options. For
 example with dserver you need to add "chello.obj uuid.lib ole32.lib 
 advapi32.lib
 kernel32.lib user32.lib" to compile command at the command prompt. I'm 
 not sure
 if you can do this from your syntax editor.

 There are some hints in \samples\d\all.sh.

Well, I have also tried to execute \dmd\samples\d\run.bat which compiles and links all examples automatically by running all.sh, but all the resulting .exe files are invalid, too...

Correction, the non-windows examples compile and link correctly, while the windows examples are not linked at all...

I gave run.bat a go, it contains the following: \dmd\bin\shell all.sh which I changed to ..\..\bin\shell all.sh as my dmd dir is not at the root. Then I edited all.sh and changed DMD=\dmd\bin\dmd to DMD=dmd as my dmd dir is not at the root and dmd.exe is in my PATH so will execute without a path. Running it gives the following executables: 24/11/2004 12:16 p.m. 81,436 sieve.exe 24/11/2004 12:16 p.m. 89,628 pi.exe 24/11/2004 12:16 p.m. 86,556 dhry.exe 24/11/2004 12:16 p.m. 82,972 wc.exe 25/07/2004 12:50 a.m. 103,452 htmlget.exe I noticed errors for the 'dserver' and 'dclient' programs, the dserver errors were at first: dserver.d(254): C style cast deprecated, use cast(LPOLESTR)(szID) dserver.d(301): C style cast deprecated, use cast(LPOLESTR)(szID) i.e. old style casts, which I then fixed, next error: dserver.d(80): class chello.CHello member this is not accessible looking at CHello (in chello.d) I see the constructor is inside a 'protected' block. I do not know what the correct solution here is as I do not know what is achieved by putting a constructor in a protected block. Perhaps someone else has a solution/idea? Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 23 2004
next sibling parent reply J C Calvarese <jcc7 cox.net> writes:
Regan Heath wrote:
 On Tue, 23 Nov 2004 18:14:27 +0100, Blackspawn <a b.com> wrote:
 
 I noticed errors for the 'dserver' and 'dclient' programs, the dserver 
 errors were at first:
 
 dserver.d(254): C style cast deprecated, use cast(LPOLESTR)(szID)
 dserver.d(301): C style cast deprecated, use cast(LPOLESTR)(szID)

Arg! Didn't we already tell Walter about this months ago?
 
 i.e. old style casts, which I then fixed, next error:
 
 dserver.d(80): class chello.CHello member this is not accessible
 
 looking at CHello (in chello.d) I see the constructor is inside a 
 'protected' block. I do not know what the correct solution here is as I 
 do not know what is achieved by putting a constructor in a protected block.
 
 Perhaps someone else has a solution/idea?

Right. When I commented out the protect in chello.d (line 41), it worked. Maybe that is what it's supposed to be. Also, all.sh refers to a mysterious file called test.d that doesn't exist. Good grief! I'd think that testing the samples would be part of the testing regimen before each version of D is released...
 
 Regan
 

-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Nov 23 2004
parent J C Calvarese <jcc7 cox.net> writes:
J C Calvarese wrote:
 Regan Heath wrote:
 
 On Tue, 23 Nov 2004 18:14:27 +0100, Blackspawn <a b.com> wrote:

 I noticed errors for the 'dserver' and 'dclient' programs, the dserver 
 errors were at first:

 dserver.d(254): C style cast deprecated, use cast(LPOLESTR)(szID)
 dserver.d(301): C style cast deprecated, use cast(LPOLESTR)(szID)

Arg! Didn't we already tell Walter about this months ago?

digitalmars.D/3416 (8 Jun 2004) I suppose he may have not have seen it because he's probably still behind in reading messages, and I guess it wasn't ever posted to the bugs newsgroup. -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Nov 23 2004
prev sibling parent reply Blackspawn <a b.com> writes:
Regan Heath wrote:

 Running it gives the following executables:
 
 24/11/2004  12:16 p.m.            81,436 sieve.exe
 24/11/2004  12:16 p.m.            89,628 pi.exe
 24/11/2004  12:16 p.m.            86,556 dhry.exe
 24/11/2004  12:16 p.m.            82,972 wc.exe
 25/07/2004  12:50 a.m.           103,452 htmlget.exe
 

I also get als those files, except htmlget.exe. That one isn't even mentioned in my all.sh...
Nov 23 2004
next sibling parent Blackspawn <a b.com> writes:
Blackspawn wrote:

 I also get als those files, except htmlget.exe. That one isn't even 
 mentioned in my all.sh...

Just managed to compile and link htmlget.exe via dmd htmlget.d ws2_32.lib :)
Nov 23 2004
prev sibling parent Regan Heath <regan netwin.co.nz> writes:
On Wed, 24 Nov 2004 00:44:56 +0100, Blackspawn <a b.com> wrote:
 Regan Heath wrote:

 Running it gives the following executables:

 24/11/2004  12:16 p.m.            81,436 sieve.exe
 24/11/2004  12:16 p.m.            89,628 pi.exe
 24/11/2004  12:16 p.m.            86,556 dhry.exe
 24/11/2004  12:16 p.m.            82,972 wc.exe
 25/07/2004  12:50 a.m.           103,452 htmlget.exe

I also get als those files, except htmlget.exe. That one isn't even mentioned in my all.sh...

Actually, neither, I think I built that one earlier, sorry, I was misleading. Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 23 2004
prev sibling parent reply J C Calvarese <jcc7 cox.net> writes:
Blackspawn wrote:
 Blackspawn wrote:
 
 J C Calvarese wrote:

 It sounds like you're not compiling and linking with the right 
 options. For
 example with dserver you need to add "chello.obj uuid.lib ole32.lib 
 advapi32.lib
 kernel32.lib user32.lib" to compile command at the command prompt. 
 I'm not sure
 if you can do this from your syntax editor.

 There are some hints in \samples\d\all.sh.

Well, I have also tried to execute \dmd\samples\d\run.bat which compiles and links all examples automatically by running all.sh, but all the resulting .exe files are invalid, too...

Correction, the non-windows examples compile and link correctly, while the windows examples are not linked at all...

Does winsamp work? Try to compile it like this (as the instructions within the code mention): dmd winsamp gdi32.lib winsamp.def It works for me. As Regan mentioned, apparently some of the programs have some obsolete code. Sorry about that. I guess we'll have to give Walter a hard time. -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Nov 23 2004
parent Blackspawn <a b.com> writes:
J C Calvarese wrote:

 Does winsamp work?
 
 Try to compile it like this (as the instructions within the code mention):
 
 dmd winsamp gdi32.lib winsamp.def
 
 It works for me.
 

Yes, it's working. :)
Nov 23 2004