www.digitalmars.com         C & C++   DMDScript  

D - Embedding D into HTML.

reply Dave Taylor <me webmasterdave.co.uk> writes:
I'm sorry if I am posting this into the wrong newgroup...

I have just downloaded the D compiler for Linux, and have installed it 
fine - I can compile normal D programs.
I read on the official website that you can embed D in HTML, is this true? 
I tried what it said, but failed.
I saved the following file as "embedhtml.html":

<html>
<head>
<title>HTML D Test</title>
</head>
<code>
     import std.c.stdio;
     int main()
     {
	printf("hello world\n");
	return 0;
     }
</code>
</body>
</html>

But when I compile - using "dmd embedhtml.html" I get a load of errors:

/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libphobos.a(dmain2.o)(.gnu.l
nkonce.tmain+0x64): 
In function `main':
: undefined reference to `_Dmain'
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh21
DHandlerTable+0x9): 
In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
: undefined reference to `_deh_beg'
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh21
DHandlerTable+0xe): 
In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
: undefined reference to `_deh_beg'
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh213
HandlerTable+0x14): 
In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
: undefined reference to `_deh_end'
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh213
HandlerTable+0x37): 
In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
: undefined reference to `_deh_end'
collect2: ld returned 1 exit status
--- errorlevel 256

Am I doing something wrong? Or is this a bug in the compiler?
I am using Linux Mandrake 9.2 and GCC 3.3.1.

Any help would be greatfully appreciated - again, sorry if this is posted 
into the wrong newsgroup.

Regards.

Dave.
Mar 01 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
Dave Taylor wrote:
 I'm sorry if I am posting this into the wrong newgroup...

No apology necessary. This is the right newsgroup.
 
 I have just downloaded the D compiler for Linux, and have installed it 
 fine - I can compile normal D programs.
 I read on the official website that you can embed D in HTML, is this 
 true? I tried what it said, but failed.
 I saved the following file as "embedhtml.html":
 
 <html>
 <head>
 <title>HTML D Test</title>
 </head>
 <code>
     import std.c.stdio;
     int main()
     {
     printf("hello world\n");
     return 0;
     }
 </code>
 </body>
 </html>

This code works fine on my computer in Windows: d:\dmd\bin\..\..\dm\bin\link.exe embedhtml,,,user32+kernel32/noi; hello world It's possible there's a flaw in the Linux version. Have you been able to compile the unembedded version of this program? import std.c.stdio; int main() { printf("hello world\n"); return 0; }
 
 But when I compile - using "dmd embedhtml.html" I get a load of errors:
 
 /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libphobos.a(dmain2.o)(.gnu.l
nkonce.tmain+0x64): 
 In function `main':
 : undefined reference to `_Dmain'
 /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh21
DHandlerTable+0x9): 
 In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
 : undefined reference to `_deh_beg'
 /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh21
DHandlerTable+0xe): 
 In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
 : undefined reference to `_deh_beg'
 /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh213
HandlerTable+0x14): 
 In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
 : undefined reference to `_deh_end'
 /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh213
HandlerTable+0x37): 
 In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
 : undefined reference to `_deh_end'
 collect2: ld returned 1 exit status
 --- errorlevel 256
 
 Am I doing something wrong? Or is this a bug in the compiler?
 I am using Linux Mandrake 9.2 and GCC 3.3.1.

Your error message suggests to me that libphobos.a isn't being found by the linker. If you've set up DMD right, it must be a a compiler bug. If you haven't already I think you should check that everything is set up right. You might want to review the compiler installation instructions http://www.digitalmars.com/d/dcompiler.html#linux and test a non-embedded file. I'm no good with Linux (Windows has ruined me), so that's as much help as I can give. Good luck.
 
 Any help would be greatfully appreciated - again, sorry if this is 
 posted into the wrong newsgroup.
 
 Regards.
 
 Dave.

-- Justin http://jcc_7.tripod.com/d/
Feb 29 2004
next sibling parent reply "KTC" <me here.com> writes:
Me thinks it's a flaw in the linux release as the example works fine
under windows as been mentioned but not linux.

I've just tried it under linux after having it works under windows,
the .d version works fine but .html doesn't and gives same errors for
me ...

KTC

-- 
Experience is a good school but the fees are high.
    - Heinrich Heine
Feb 29 2004
parent Dave Taylor <me webmasterdave.co.uk> writes:
Thanks for all of your help...

I can compile .d programs yes... And I have set up DMD on my Windows [XP] 
box, and the .html compiling works, so it must be a linux bug - 
unfortunately, I don't have another linux box I can try it on.

The linker it uses is GCC yes, but on Windows you have to download that 
"utilities" package to get a different linker, and the one that comes with 
Visual C++ doesn't like it.

I will await for future releases, though the embedded html stuff isn't 
really important to me.

Regards.

Dave. 
Mar 01 2004
prev sibling parent reply Juan C <Juan_member pathlink.com> writes:
My first thought is that the linker comes with Digital Mars C/C++, not with D,
so you need both to compile D.
Feb 29 2004
parent J C Calvarese <jcc7 cox.net> writes:
Juan C wrote:
 My first thought is that the linker comes with Digital Mars C/C++, not with D,
 so you need both to compile D.

That's true with the windows version of DMD, but with Linux, GCC is used for linking. From what KTC wrote: "I've just tried it under linux after having it works under windows, the .d version works fine but .html doesn't and gives same errors for me ..." ... it sounds like a bug in the Linux version relating to embedding D into HTML. -- Justin http://jcc_7.tripod.com/d/
Feb 29 2004