Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
October 24, 2009 Problems linking C and D code | ||||
---|---|---|---|---|
| ||||
Hi all,
I've got a problem with linking two object files on Windows with an external *.lib file. First one is compiled C code, second one is in D. I'm using D2.
$ dmc -c first.c -I path/to/SDL/include
$ dmd -c second.d
First two commands create two *.obj file. After running
$ dmd first.obj second.obj path/to/SDL.lib -ofout.exe
no "out.exe" file is created but the command returns 0. An "out.map" file is created, though. Where am I doing something wrong?
Cheers,
--
Jan Stępień
|
October 24, 2009 Re: Problems linking C and D code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jan Stępień | On 24.10.2009 15:02, Jan Stępień wrote:
> Hi all,
>
> I've got a problem with linking two object files on Windows with an
> external *.lib file. First one is compiled C code, second one is in D.
> I'm using D2.
>
> $ dmc -c first.c -I path/to/SDL/include
> $ dmd -c second.d
>
> First two commands create two *.obj file. After running
>
> $ dmd first.obj second.obj path/to/SDL.lib -ofout.exe
>
> no "out.exe" file is created but the command returns 0. An "out.map"
> file is created, though. Where am I doing something wrong?
>
> Cheers,
Make sure there's a D main function define somewhere. With SDL you're probably supposed to link with SDLmain.lib.
|
October 24, 2009 Re: Problems linking C and D code | ||||
---|---|---|---|---|
| ||||
Posted in reply to torhu | On Sat, 24 Oct 2009 15:56:05 +0200 torhu <no@spam.invalid> wrote: > On 24.10.2009 15:02, Jan Stępień wrote: > > Hi all, > > > > I've got a problem with linking two object files on Windows with an external *.lib file. First one is compiled C code, second one is in D. I'm using D2. > > > > $ dmc -c first.c -I path/to/SDL/include > > $ dmd -c second.d > > > > First two commands create two *.obj file. After running > > > > $ dmd first.obj second.obj path/to/SDL.lib -ofout.exe > > > > no "out.exe" file is created but the command returns 0. An "out.map" file is created, though. Where am I doing something wrong? > > > > Cheers, > > Make sure there's a D main function define somewhere. With SDL you're probably supposed to link with SDLmain.lib. Thanks for the reply. There is int main(string[] args) function in second.d. I tried linking in both combinations, with SDLmain.lib only and with both SDL.lib and SDLmain.lib - results are the same, unfortunately. I also tried linking with SDL.dll instead of SDL.lib, but dmd exited with a message "unrecognized file extension dll". Cheers, -- Jan Stępień |
October 25, 2009 Re: Problems linking C and D code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jan Stępień | On 24.10.2009 16:17, Jan Stępień wrote: > On Sat, 24 Oct 2009 15:56:05 +0200 > torhu<no@spam.invalid> wrote: >> On 24.10.2009 15:02, Jan Stępień wrote: >> > Hi all, >> > >> > I've got a problem with linking two object files on Windows with an >> > external *.lib file. First one is compiled C code, second one is in D. >> > I'm using D2. >> > >> > $ dmc -c first.c -I path/to/SDL/include >> > $ dmd -c second.d >> > >> > First two commands create two *.obj file. After running >> > >> > $ dmd first.obj second.obj path/to/SDL.lib -ofout.exe >> > >> > no "out.exe" file is created but the command returns 0. An "out.map" >> > file is created, though. Where am I doing something wrong? >> > >> > Cheers, >> >> Make sure there's a D main function define somewhere. With SDL you're >> probably supposed to link with SDLmain.lib. > > Thanks for the reply. > > There is int main(string[] args) function in second.d. I tried linking > in both combinations, with SDLmain.lib only and with both SDL.lib and > SDLmain.lib - results are the same, unfortunately. > > I also tried linking with SDL.dll instead of SDL.lib, but dmd exited > with a message "unrecognized file extension dll". > > Cheers, The Derelict project has D bindings for SDL, and seems to be a popular choice. http://www.dsource.org/projects/derelict Other than that, maybe out.exe is a special file name for the linker, or something. You could try another name, just in case. |
October 25, 2009 Re: Problems linking C and D code | ||||
---|---|---|---|---|
| ||||
Posted in reply to torhu | On Sun, 25 Oct 2009 05:36:20 +0100 torhu <no@spam.invalid> wrote: > On 24.10.2009 16:17, Jan Stępień wrote: > > On Sat, 24 Oct 2009 15:56:05 +0200 > > torhu<no@spam.invalid> wrote: > >> On 24.10.2009 15:02, Jan Stępień wrote: > >> > Hi all, > >> > > >> > I've got a problem with linking two object files on Windows with an > >> > external *.lib file. First one is compiled C code, second one is in D. > >> > I'm using D2. > >> > > >> > $ dmc -c first.c -I path/to/SDL/include > >> > $ dmd -c second.d > >> > > >> > First two commands create two *.obj file. After running > >> > > >> > $ dmd first.obj second.obj path/to/SDL.lib -ofout.exe > >> > > >> > no "out.exe" file is created but the command returns 0. An "out.map" > >> > file is created, though. Where am I doing something wrong? > >> > > >> > Cheers, > >> > >> Make sure there's a D main function define somewhere. With SDL you're > >> probably supposed to link with SDLmain.lib. > > > > Thanks for the reply. > > > > There is int main(string[] args) function in second.d. I tried linking in both combinations, with SDLmain.lib only and with both SDL.lib and SDLmain.lib - results are the same, unfortunately. > > > > I also tried linking with SDL.dll instead of SDL.lib, but dmd exited with a message "unrecognized file extension dll". > > > > Cheers, > > The Derelict project has D bindings for SDL, and seems to be a popular choice. Thanks for the suggestion. Using a different library does not answer my question though. Why does the linker return 0, no error/warning messages are displayed and still there's no executable? > Other than that, maybe out.exe is a special file name for the linker, or something. You could try another name, just in case. Thanks for the idea, I've tried various names for the output file. Unfortunately it did not help. Cheers, -- Jan Stępień |
Copyright © 1999-2021 by the D Language Foundation