www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Error importing std.socket ?

reply SeeSchloss <seeschloss seeschloss.org> writes:
Hi everybody,

I've been trying to use sockets now that they are included in phobos, 
but I must have forgotten to do something somewhere. When I try to 
compile a file containing just "import std.socket;" in it, dmd spits out 
a bunch of errors I don't really understand :

gcc sockets.o -o sockets -lphobos -lpthread -lm
/usr/lib/gcc-lib/i686-pc-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/i686-pc-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh21
DHandlerTable+0x4): 
In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
: undefined reference to `_deh_beg'
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh21
DHandlerTable+0xc): 
In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
: undefined reference to `_deh_beg'
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh213
HandlerTable+0x13): 
In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
: undefined reference to `_deh_end'
/usr/lib/gcc-lib/i686-pc-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

/usr/lib/libphobos.a is the last libphobos.a from the 0.88 zip archive.

Anyone knows where the problem could come from ? (I probably overlooked 
something evident somewhere :)

Thanks.

--
Schee
May 09 2004
parent reply Mike Swieton <mike swieton.net> writes:
You need a main method. You'll find that you get that error upon importing
any module. Try adding:

int main(char[][] args) { return 0; }

to your file.

On Sun, 09 May 2004 19:07:24 +0200, SeeSchloss wrote:

 Hi everybody,
 
 I've been trying to use sockets now that they are included in phobos, 
 but I must have forgotten to do something somewhere. When I try to 
 compile a file containing just "import std.socket;" in it, dmd spits out 
 a bunch of errors I don't really understand :
 
 gcc sockets.o -o sockets -lphobos -lpthread -lm
 /usr/lib/gcc-lib/i686-pc-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/i686-pc-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh21
DHandlerTable+0x4): 
 In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
 : undefined reference to `_deh_beg'
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh21
DHandlerTable+0xc): 
 In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
 : undefined reference to `_deh_beg'
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../../libphobos.a(deh2.o)(.gnu.linkonce.t_D4deh213__eh_finddataFPvZPS4deh213
HandlerTable+0x13): 
 In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
 : undefined reference to `_deh_end'
 /usr/lib/gcc-lib/i686-pc-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
 
 /usr/lib/libphobos.a is the last libphobos.a from the 0.88 zip archive.
 
 Anyone knows where the problem could come from ? (I probably overlooked 
 something evident somewhere :)
 
 Thanks.
Mike Swieton __ The difference between losers and winners is that losers don't fail enough. - Ross Jeffries
May 09 2004
parent reply SeeSchloss <seeschloss seeschloss.org> writes:
Mike Swieton wrote:
 You need a main method. You'll find that you get that error upon importing
 any module. Try adding:
 
 int main(char[][] args) { return 0; }
 
 to your file.
OMG, I'm so ashamed :-/ Actually I accidentaly launched a compilation before writing anything else, and after seeing the errors I didn't even try to go further... Well, next time I'll ponder a bit before getting in panic :) Thanks -- Schee
May 09 2004
parent reply Regan Heath <regan netwin.co.nz> writes:
On Sun, 09 May 2004 20:18:52 +0200, SeeSchloss <seeschloss seeschloss.org> 
wrote:
 Mike Swieton wrote:
 You need a main method. You'll find that you get that error upon 
 importing
 any module. Try adding:

 int main(char[][] args) { return 0; }

 to your file.
OMG, I'm so ashamed :-/
We all do something like this every now and again :)
 Actually I accidentaly launched a compilation before writing anything 
 else, and after seeing the errors I didn't even try to go further...
If the compiler error was clearer...
 Well, next time I'll ponder a bit before getting in panic :)

 Thanks

 --
 Schee
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
May 09 2004
parent reply "Phill" <phill pacific.net.au> writes:
"Regan Heath" <regan netwin.co.nz> wrote in message
news:opr7q59gfy5a2sq9 digitalmars.com...
 On Sun, 09 May 2004 20:18:52 +0200, SeeSchloss <seeschloss seeschloss.org>
 wrote:
 Mike Swieton wrote:
 You need a main method. You'll find that you get that error upon
 importing
 any module. Try adding:

 int main(char[][] args) { return 0; }

 to your file.
OMG, I'm so ashamed :-/
We all do something like this every now and again :)
 Actually I accidentaly launched a compilation before writing anything
 else, and after seeing the errors I didn't even try to go further...
If the compiler error was clearer...
You mean somthing like the following, which is written in the third line of the error? " In function `main': : undefined reference to `_Dmain' " Phill
 Well, next time I'll ponder a bit before getting in panic :)

 Thanks

 --
 Schee
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
May 09 2004
parent Regan Heath <regan netwin.co.nz> writes:
On Mon, 10 May 2004 09:32:10 +1000, Phill <phill pacific.net.au> wrote:
 "Regan Heath" <regan netwin.co.nz> wrote in message
 news:opr7q59gfy5a2sq9 digitalmars.com...
 On Sun, 09 May 2004 20:18:52 +0200, SeeSchloss 
 <seeschloss seeschloss.org>
 wrote:
 Mike Swieton wrote:
 You need a main method. You'll find that you get that error upon
 importing
 any module. Try adding:

 int main(char[][] args) { return 0; }

 to your file.
OMG, I'm so ashamed :-/
We all do something like this every now and again :)
 Actually I accidentaly launched a compilation before writing anything
 else, and after seeing the errors I didn't even try to go further...
If the compiler error was clearer...
You mean somthing like the following, which is written in the third line of the error? " In function `main': : undefined reference to `_Dmain' "
Yes, without the others.. so it's clear. Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
May 09 2004