www.digitalmars.com         C & C++   DMDScript  

D - Sample Problem

reply "Gary" <gedumer bcpl.net> writes:
Sorry if you've all heard this before, but... I'm having a problem
compiling/linking the winsamp.d sample program... as follows:

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

winsamp.obj(winsamp)
 Error 42: Symbol Undefined _CreateFontA 56
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
--- errorlevel 4

D:\dmd\samples\d>


Please help... Gary.
Mar 04 2003
parent reply Patrick Down <pat codemoon.com> writes:
Try

dmd winsamp32.d gdi32.lib


"Gary" <gedumer bcpl.net> wrote in news:b43lh7$109j$1 digitaldaemon.com:

 Sorry if you've all heard this before, but... I'm having a problem
 compiling/linking the winsamp.d sample program... as follows:
 
 D:\dmd\samples\d>dmd winsamp.d
 D:\DMD\BIN\..\..\dm\bin\link.exe winsamp,,,user32+kernel32/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved
 
 winsamp.obj(winsamp)
  Error 42: Symbol Undefined _CreateFontA 56
 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
 --- errorlevel 4
 
 D:\dmd\samples\d>
 
 
 Please help... Gary.
 
 

Mar 04 2003
parent reply "Gary" <gedumer bcpl.net> writes:
Isn't there a way to compile it using gdi32.dll instead of statically
linking the whole gdi library? The resulting 91K exe is a bit much.

"Patrick Down" <pat codemoon.com> wrote in message
news:Xns9334D2F054EB9patcodemooncom 63.105.9.61...
 Try

 dmd winsamp32.d gdi32.lib


 "Gary" <gedumer bcpl.net> wrote in news:b43lh7$109j$1 digitaldaemon.com:

 Sorry if you've all heard this before, but... I'm having a problem
 compiling/linking the winsamp.d sample program... as follows:

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

 winsamp.obj(winsamp)
  Error 42: Symbol Undefined _CreateFontA 56
 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
 --- errorlevel 4

 D:\dmd\samples\d>


 Please help... Gary.


Mar 05 2003
parent reply Patrick Down <Patrick_member pathlink.com> writes:
Actually gdi32.lib has little actual code in it.  It just provides 
symbolic linkage to the DLL.  Also you probably need to look a the 
space a simple hello world takes up, some people remark that the
D runtime is a little large.  It's all a trade off.  Most runtimes
don't have a GC in them.


In article <b453fa$1qam$1 digitaldaemon.com>, Gary says...
Isn't there a way to compile it using gdi32.dll instead of statically
linking the whole gdi library? The resulting 91K exe is a bit much.

"Patrick Down" <pat codemoon.com> wrote in message
news:Xns9334D2F054EB9patcodemooncom 63.105.9.61...
 Try

 dmd winsamp32.d gdi32.lib


 "Gary" <gedumer bcpl.net> wrote in news:b43lh7$109j$1 digitaldaemon.com:

 Sorry if you've all heard this before, but... I'm having a problem
 compiling/linking the winsamp.d sample program... as follows:

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

 winsamp.obj(winsamp)
  Error 42: Symbol Undefined _CreateFontA 56
 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
 --- errorlevel 4

 D:\dmd\samples\d>


 Please help... Gary.



Mar 05 2003
next sibling parent reply "Gary" <gedumer bcpl.net> writes:
Wow... you're right... I didn't realize how large the hello world sample
really was.

Having said that however... getting back to my original question, is there
any way to compile it using gdi32.dll instead of statically linking the
whole gdi library?

Gary

linking the whole gdi library


news:b457to$1t6v$1 digitaldaemon.com...
 Actually gdi32.lib has little actual code in it.  It just provides
 symbolic linkage to the DLL.  Also you probably need to look a the
 space a simple hello world takes up, some people remark that the
 D runtime is a little large.  It's all a trade off.  Most runtimes
 don't have a GC in them.


 In article <b453fa$1qam$1 digitaldaemon.com>, Gary says...
Isn't there a way to compile it using gdi32.dll instead of statically
linking the whole gdi library? The resulting 91K exe is a bit much.

"Patrick Down" <pat codemoon.com> wrote in message
news:Xns9334D2F054EB9patcodemooncom 63.105.9.61...
 Try

 dmd winsamp32.d gdi32.lib


 "Gary" <gedumer bcpl.net> wrote in



 Sorry if you've all heard this before, but... I'm having a problem
 compiling/linking the winsamp.d sample program... as follows:

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

 winsamp.obj(winsamp)
  Error 42: Symbol Undefined _CreateFontA 56
 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
 --- errorlevel 4

 D:\dmd\samples\d>


 Please help... Gary.




Mar 05 2003
next sibling parent reply "Mike Wynn" <mike.wynn l8night.co.uk> writes:
"Gary" <gedumer bcpl.net> wrote in message
news:b45n7m$27g3$1 digitaldaemon.com...
 Wow... you're right... I didn't realize how large the hello world sample
 really was.

 Having said that however... getting back to my original question, is there
 any way to compile it using gdi32.dll instead of statically linking the
 whole gdi library?

read the reply, gdi32.lib is the lib to link your app to gdi32.dll gdi.dll is 218K on my machine (win2K) check your gdi32.dll if its more than 90K the obviously your app does not have it statically linked. the size of your app is due to the size of the phobos+gc libs which are statically linked.
 Gary

linking the whole gdi library


news:b457to$1t6v$1 digitaldaemon.com...
 Actually gdi32.lib has little actual code in it.  It just provides
 symbolic linkage to the DLL.  Also you probably need to look a the
 space a simple hello world takes up, some people remark that the
 D runtime is a little large.  It's all a trade off.  Most runtimes
 don't have a GC in them.


 In article <b453fa$1qam$1 digitaldaemon.com>, Gary says...
Isn't there a way to compile it using gdi32.dll instead of statically
linking the whole gdi library? The resulting 91K exe is a bit much.

"Patrick Down" <pat codemoon.com> wrote in message
news:Xns9334D2F054EB9patcodemooncom 63.105.9.61...
 Try

 dmd winsamp32.d gdi32.lib


 "Gary" <gedumer bcpl.net> wrote in



 Sorry if you've all heard this before, but... I'm having a problem
 compiling/linking the winsamp.d sample program... as follows:

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

 winsamp.obj(winsamp)
  Error 42: Symbol Undefined _CreateFontA 56
 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
 --- errorlevel 4

 D:\dmd\samples\d>


 Please help... Gary.





Mar 05 2003
parent "Dario" <supdar yahoo.com> writes:
 Wow... you're right... I didn't realize how large the hello world sample
 really was.

 Having said that however... getting back to my original question, is


 any way to compile it using gdi32.dll instead of statically linking the
 whole gdi library?


 read the reply, gdi32.lib is the lib to link your app to gdi32.dll
 gdi.dll is 218K on my machine (win2K)  check your gdi32.dll if its more

 90K the obviously your app does not have it statically linked.

 the size of your app is due to the size of the phobos+gc libs which are
 statically linked.

Why is phobos.lib really linked in the hello world sample program if none of its function is used? I think that the linker should exclude functions which are not used. Even the GC should be excluded if no objects are allocated. Can we develop a more powerful linker without giving up the classic compile/link model? Anyway, I think that a cleverer linking system is worth the drop of that model.
Mar 05 2003
prev sibling parent reply Ilya Minkov <midiclub 8ung.at> writes:
Again: gdi32 *code* is not linked into an application. gdi32.lib is a 
"stub library", which contains no real code, but simply loads *the 
functions you use from the DLL* into your application at startup. It 
doesn't actually increase the executable size.

Your example is not really large. Consider: if you compile hello-world 
with DMC, you get about 45K executable. It contains a few parts of C 
library. Now, phobos partially wraps C library, and also adds a couple 
of dozen kilos for a GC and somesuch. Now, there you have it. it simply 
*can't* be much smaller than that.

I assume DMC links C standard library into the executable, else the 
minimal program size would go down to 8 kilobytes. LCC-Win32 and some 
versions of MingW use M1cro$oft's msvcrt.dll, which is almost 300K large 
and is distributed with W1nd0w$, and is a C standard library implementation.

Unless the library is moved into a DLL, the size won't go down.

BTW, is there an *easy* way to make shared libraries of object code, 
which would probably work with only one compiler, but would requiere no 
changes in source? Delphi allows to use its DLL derivate, simply create 
a "package" and specify "use run-time packages" instead of "link with 
packages" when compiling applications.

-i.

Gary wrote:
 Wow... you're right... I didn't realize how large the hello world sample
 really was.
 
 Having said that however... getting back to my original question, is there
 any way to compile it using gdi32.dll instead of statically linking the
 whole gdi library?
 
 Gary
 

Mar 05 2003
next sibling parent "Gary" <gedumer bcpl.net> writes:
Thanks Ilya... your very kind, considerate, and thorough reply is most
welcome. I now understand.

Thanks again... Gary.

"Ilya Minkov" <midiclub 8ung.at> wrote in message
news:b45si3$2b9o$1 digitaldaemon.com...
 Again: gdi32 *code* is not linked into an application. gdi32.lib is a
 "stub library", which contains no real code, but simply loads *the
 functions you use from the DLL* into your application at startup. It
 doesn't actually increase the executable size.

 Your example is not really large. Consider: if you compile hello-world
 with DMC, you get about 45K executable. It contains a few parts of C
 library. Now, phobos partially wraps C library, and also adds a couple
 of dozen kilos for a GC and somesuch. Now, there you have it. it simply
 *can't* be much smaller than that.

 I assume DMC links C standard library into the executable, else the
 minimal program size would go down to 8 kilobytes. LCC-Win32 and some
 versions of MingW use M1cro$oft's msvcrt.dll, which is almost 300K large
 and is distributed with W1nd0w$, and is a C standard library

 Unless the library is moved into a DLL, the size won't go down.

 BTW, is there an *easy* way to make shared libraries of object code,
 which would probably work with only one compiler, but would requiere no
 changes in source? Delphi allows to use its DLL derivate, simply create
 a "package" and specify "use run-time packages" instead of "link with
 packages" when compiling applications.

 -i.

 Gary wrote:
 Wow... you're right... I didn't realize how large the hello world sample
 really was.

 Having said that however... getting back to my original question, is


 any way to compile it using gdi32.dll instead of statically linking the
 whole gdi library?

 Gary


Mar 05 2003
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
I generally do not like the 'standard library as dll' approach because it
leads inevitably to 'dll hell'. I prefer to make self contained executables
that are not going to randomly crash because it got hooked up to some
obsolete dll.
Mar 06 2003
next sibling parent "Mike Wynn" <mike.wynn l8night.co.uk> writes:
"Walter" <walter digitalmars.com> wrote in message
news:b49cc3$1ajv$1 digitaldaemon.com...
 I generally do not like the 'standard library as dll' approach because it
 leads inevitably to 'dll hell'. I prefer to make self contained

 that are not going to randomly crash because it got hooked up to some
 obsolete dll.

it would be nice to have the option to chose static gc+phobos or dynamic. while phobos, and D are developing then yes, std libs in a dll will be a nightmare, but once they are stable then as long as the dll name changes when API's change things are not too bad (MFC is fine as a dll now). it would also be good to have a D dll (as opposed to a C dll) which allow D classes to be dynamically (in a dll not a Java sense) loaded. (perhaps a COM interface ICollect used to pass the GC to the dll on load via a D dll entry point, call LoadDLibrary, does LoadLibrary, then attaches the GC, then gets the class info's (should contain constuctors, static methods [static methods of dll loaded classes similar to delphi class virtual methods i.e. call via class info] as well as vtbl) ) choices that would be good. app + gc(dll) + phobos(dll) + [ownlib( dll )] app(gc) + phobos(dll) + [ownlib( dll )] app(phobos) + gc(dll) + [ownlib( dll )] all statically linked. when building a dll that contained a template, you would have to declare which instances it included.
Mar 07 2003
prev sibling parent reply Ilya Minkov <midiclub 8ung.at> writes:
I didn't mean "making it standard", but rather "making it posible".

Consider: someone wants to write a whole office suit in D. Take a look 
at some working office suit: OpenOffice for example. It is 70 Megs of 
object code, almost everything of it are DLLs which are simply all 
placed in the installation directory. This approach makes sense, because:
  - the suit of applications uses lots of common code -> distibution 
size is saved;
  - one can assume that often multiple applications are loaded 
simultanously -> memory is conserved;
  - the application loads features as soon as it needs them, making 
start-up times short.

If someone were out to write an OS in D, he would be even more grateful.

One could make it a standard feature to be able to compile sets of 
modules to DLLs. They could then be loaded statically *or* dynamically. 
I'm not exactly sure wether it's a bit slower since all access would be 
indirect (is it with static DLL binding? i don't know). The advantage 
is, that at application startup the library is represented with a set of 
uninitialised references. An acess to which would cause the library to 
load. Is this possible?

I assume it is with functions - simply the references need to be 
initialised to a loader function, written in assembly. I don't know 
whether there is a similar way for variables and constants. Possibly 
throught exception handling? If not, shared variables and constants can 
still be placed into the main application, and the library would have to 
"import" them from it at startup. Another solution is that the main 
application would wrap itself with checks, which IMO exception handling 
is intended to eliminate need for. Or this approach applied only to 
variables, and constants get always linked into the application?

Walter wrote:
 I generally do not like the 'standard library as dll' approach because it
 leads inevitably to 'dll hell'. I prefer to make self contained executables
 that are not going to randomly crash because it got hooked up to some
 obsolete dll.

Mar 07 2003
parent "Walter" <walter digitalmars.com> writes:
I agree that there are times and places for DLLs. D can both become a DLL
and call DLL's.
Mar 07 2003
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
"Patrick Down" <Patrick_member pathlink.com> wrote in message
news:b457to$1t6v$1 digitaldaemon.com...
 Actually gdi32.lib has little actual code in it.  It just provides
 symbolic linkage to the DLL.  Also you probably need to look a the
 space a simple hello world takes up, some people remark that the
 D runtime is a little large.  It's all a trade off.  Most runtimes
 don't have a GC in them.

The gc adds some code (maybe 40k). A big chunk comes, however, from all the unit tests in phobos.lib. Those should be removed from a release build, it is built now with all the debug checks and unit tests on.
Mar 05 2003
next sibling parent "Gary" <gedumer bcpl.net> writes:
Thanks for the info.

Gary

"Walter" <walter digitalmars.com> wrote in message
news:b466p8$2hi9$1 digitaldaemon.com...
 "Patrick Down" <Patrick_member pathlink.com> wrote in message
 news:b457to$1t6v$1 digitaldaemon.com...
 Actually gdi32.lib has little actual code in it.  It just provides
 symbolic linkage to the DLL.  Also you probably need to look a the
 space a simple hello world takes up, some people remark that the
 D runtime is a little large.  It's all a trade off.  Most runtimes
 don't have a GC in them.

The gc adds some code (maybe 40k). A big chunk comes, however, from all

 unit tests in phobos.lib. Those should be removed from a release build, it
 is built now with all the debug checks and unit tests on.

Mar 05 2003
prev sibling parent reply Gerd Schmidt <Gerd_member pathlink.com> writes:
Hi,

In article <b466p8$2hi9$1 digitaldaemon.com>, Walter says...
The gc adds some code (maybe 40k). A big chunk comes, however, from all the
unit tests in phobos.lib. Those should be removed from a release build, it
is built now with all the debug checks and unit tests on.

If I try to make an optimized version of phobos.lib I get the message: Error: don't know how to make 'gc2\dmgc.lib' I have changed this two lines in the makefile from CFLAGS=-g -mn -6 -r DFLAGS=-unittest -g to CFLAGS=-mn -6 -o -r DFLAGS=-release -inline -O but I think that is not the problem ... Gerd
Mar 06 2003
parent "Walter" <walter digitalmars.com> writes:
You need to go into phobos/gc2 to build dmgc.lib. -Walter

"Gerd Schmidt" <Gerd_member pathlink.com> wrote in message
news:b4772d$1d3$1 digitaldaemon.com...
 Hi,

 In article <b466p8$2hi9$1 digitaldaemon.com>, Walter says...
The gc adds some code (maybe 40k). A big chunk comes, however, from all


unit tests in phobos.lib. Those should be removed from a release build,


is built now with all the debug checks and unit tests on.

If I try to make an optimized version of phobos.lib I get the message: Error: don't know how to make 'gc2\dmgc.lib' I have changed this two lines in the makefile from CFLAGS=-g -mn -6 -r DFLAGS=-unittest -g to CFLAGS=-mn -6 -o -r DFLAGS=-release -inline -O but I think that is not the problem ... Gerd

Mar 06 2003