View previous topic :: View next topic |
Author |
Message |
Dune
Joined: 22 Nov 2006 Posts: 6
|
Posted: Wed Nov 22, 2006 2:39 pm Post subject: _Dmain error with GDC |
|
|
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 |
|
|
Myrd
Joined: 27 Nov 2006 Posts: 2
|
Posted: Mon Nov 27, 2006 10:48 am Post subject: |
|
|
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 |
|
|
larsivi Site Admin
Joined: 27 Mar 2004 Posts: 453 Location: Trondheim, Norway
|
Posted: Tue Nov 28, 2006 2:40 am Post subject: |
|
|
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 |
|
|
Myrd
Joined: 27 Nov 2006 Posts: 2
|
Posted: Tue Nov 28, 2006 6:35 am Post subject: |
|
|
Which functions are these? |
|
Back to top |
|
|
larsivi Site Admin
Joined: 27 Mar 2004 Posts: 453 Location: Trondheim, Norway
|
Posted: Tue Nov 28, 2006 6:45 am Post subject: |
|
|
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 |
|
|
|