FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

_Dmain error with GDC

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
Dune



Joined: 22 Nov 2006
Posts: 6

PostPosted: Wed Nov 22, 2006 2:39 pm    Post subject: _Dmain error with GDC Reply with quote

Hi, just started with D and can't compile any windows apps with GDC.
(on Windows with gdc-0.19-gcc-3.4.5.exe and MinGW)

Always get the error:
undefined reference to '_Dmain'

When using DMD it works. It works also with DFL/DMD.


Thanks in advance

Dune
Back to top
View user's profile Send private message
Myrd



Joined: 27 Nov 2006
Posts: 2

PostPosted: Mon Nov 27, 2006 10:48 am    Post subject: Reply with quote

Hi, I am having the same problem.

I'm on OS X, and I'm trying to convert a command-line C project built using make to use D. Since the project isn't small, it has multiple files, so my first goal is to make the building process support both .c and .d source files and make a single executable from them.

I have adjusted my Makefile so it works well and generates .o object files for both C and D code (it chooses either gcc or gdc depending on the file).

However, the linker is giving me the following error:

ld: Undefined symbols:
__Dmain

Obviously, for some reason gdc is trying to make a stand-alone executable out of my .d source file - which is NOT what I want. I want it to be an object file that can be linked in with my C object files from my program (the main() method exists in the C code). How do I resolve this?

(BTW: The file is being compiled thus: gdc -d -g -Wall -o dtest.o dtest.d )
Back to top
View user's profile Send private message
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Tue Nov 28, 2006 2:40 am    Post subject: Reply with quote

You should get standalone object files using the -c switch to the compiler. Remember though, that there are several functions that need to be called from your main to initialize the D runtime if you choose not to use the D main.
Back to top
View user's profile Send private message
Myrd



Joined: 27 Nov 2006
Posts: 2

PostPosted: Tue Nov 28, 2006 6:35 am    Post subject: Reply with quote

Which functions are these?
Back to top
View user's profile Send private message
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Tue Nov 28, 2006 6:45 am    Post subject: Reply with quote

You will have to see in the D documentation for which functions. But I see no good reason why you would rather use the C main instead of the D main, if you're going to have D code anyway. It is no problem using the C code from D anyway.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group