www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Trouble with -lib in linux "undefined reference to `_Dmain'"

reply =?ISO-8859-15?Q?Andr=E9?= <andre s-e-a-p.de> writes:
Hi,
I use Mono-D and have a hello world example which compiles fine.
I set the compiler option "-lib" and receives an error "undefined 
reference to `_Dmain'".

Following commands are generated for the build process:
dmd -c "main.d" 
-of"/home/user/Dokumente/MonoDevelop/HelloWorld/HelloWorld/obj/Debug/main.o" 
-I"/usr/include/d/dmd/phobos" -I"/usr/include/d/dmd/druntime/import" 
-gc -debug -lib

dmd -gc -debug 
-of"/home/user/Dokumente/MonoDevelop/HelloWorld/HelloWorld/b
n/Debug/HelloWorld" 
"obj/Debug/main.o"

Do I miss an additional linux option or is the order of the commands wrong?

Kind regards
André
Feb 29 2012
parent reply Kevin Cox <kevincox.ca gmail.com> writes:
--0015175d033456735604ba1da7ab
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I think you need the -lib in the linker command (too?).
On Feb 29, 2012 12:25 PM, "Andr=C3=A9" <andre s-e-a-p.de> wrote:

 Hi,
 I use Mono-D and have a hello world example which compiles fine.
 I set the compiler option "-lib" and receives an error "undefined
 reference to `_Dmain'".

 Following commands are generated for the build process:
 dmd -c "main.d" -of"/home/user/Dokumente/**MonoDevelop/HelloWorld/**Hello=

 -I"/usr/include/d/dmd/phobos" -I"/usr/include/d/dmd/**druntime/import"
 -gc -debug -lib

 dmd -gc -debug -of"/home/user/Dokumente/**MonoDevelop/HelloWorld/**
 HelloWorld/bin/Debug/**HelloWorld" "obj/Debug/main.o"

 Do I miss an additional linux option or is the order of the commands wron=

 Kind regards
 Andr=C3=A9

--0015175d033456735604ba1da7ab Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <p>I think you need the -lib in the linker command (too?).</p> <div class=3D"gmail_quote">On Feb 29, 2012 12:25 PM, &quot;Andr=C3=A9&quot;= &lt;<a href=3D"mailto:andre s-e-a-p.de">andre s-e-a-p.de</a>&gt; wrote:<br= type=3D"attribution"><blockquote class=3D"gmail_quote" style=3D"margin:0 0= 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Hi,<br> I use Mono-D and have a hello world example which compiles fine.<br> I set the compiler option &quot;-lib&quot; and receives an error &quot;unde= fined reference to `_Dmain&#39;&quot;.<br> <br> Following commands are generated for the build process:<br> dmd -c &quot;main.d&quot; -of&quot;/home/user/Dokumente/<u></u>MonoDevelop/= HelloWorld/<u></u>HelloWorld/obj/Debug/main.o&quot; -I&quot;/usr/include/d/= dmd/phobos&quot; -I&quot;/usr/include/d/dmd/<u></u>druntime/import&quot; -g= c -debug -lib<br> <br> dmd -gc -debug -of&quot;/home/user/Dokumente/<u></u>MonoDevelop/HelloWorld/= <u></u>HelloWorld/bin/Debug/<u></u>HelloWorld&quot; &quot;obj/Debug/main.o&= quot;<br> <br> Do I miss an additional linux option or is the order of the commands wrong?= <br> <br> Kind regards<br> Andr=C3=A9<br> </blockquote></div> --0015175d033456735604ba1da7ab--
Feb 29 2012
parent =?UTF-8?B?QW5kcsOp?= <andre s-e-a-p.de> writes:
you are right, that was the error.
Thanks.

Kind regards
André

Am 29.02.2012 18:27, schrieb Kevin Cox:
 I think you need the -lib in the linker command (too?).

 On Feb 29, 2012 12:25 PM, "André" <andre s-e-a-p.de
 <mailto:andre s-e-a-p.de>> wrote:

     Hi,
     I use Mono-D and have a hello world example which compiles fine.
     I set the compiler option "-lib" and receives an error "undefined
     reference to `_Dmain'".

     Following commands are generated for the build process:
     dmd -c "main.d"
     -of"/home/user/Dokumente/__MonoDevelop/HelloWorld/__HelloWorld/obj/Debug/main.o"
     -I"/usr/include/d/dmd/phobos"
     -I"/usr/include/d/dmd/__druntime/import" -gc -debug -lib

     dmd -gc -debug
     -of"/home/user/Dokumente/__MonoDevelop/HelloWorld/__HelloWorld/bin/Debug/__HelloWorld"
     "obj/Debug/main.o"

     Do I miss an additional linux option or is the order of the commands
     wrong?

     Kind regards
     André

Feb 29 2012