January 03, 2016 Re: Call C function - Access violation | ||||
---|---|---|---|---|
| ||||
Posted in reply to TheDGuy | On 03.01.2016 21:32, TheDGuy wrote:
> If i type:
> gcc -c -otest.c.o
>
> the 'test.c.o' file is generated but if i type:
>
> dmd main.d test.c.o i get: 'Error: unrecognized file extension o'?
You're probably on Windows then? dmd doesn't recognize the .o extension on Windows, use .obj instead.
|
January 03, 2016 Re: Call C function - Access violation | ||||
---|---|---|---|---|
| ||||
Posted in reply to anonymous | On Sunday, 3 January 2016 at 21:20:35 UTC, anonymous wrote:
> On 03.01.2016 21:32, TheDGuy wrote:
>> If i type:
>> gcc -c -otest.c.o
>>
>> the 'test.c.o' file is generated but if i type:
>>
>> dmd main.d test.c.o i get: 'Error: unrecognized file extension o'?
>
> You're probably on Windows then? dmd doesn't recognize the .o extension on Windows, use .obj instead.
If i rename "test.o" to "test.obj" i get:
'Error: Module or Dictionary corrupt'
|
January 03, 2016 Re: Call C function - Access violation | ||||
---|---|---|---|---|
| ||||
Posted in reply to TheDGuy | On 03.01.2016 22:37, TheDGuy wrote: > If i rename "test.o" to "test.obj" i get: > > 'Error: Module or Dictionary corrupt' My guess is, that means that dmd can't handle the object file format that gcc produces. Disclaimer: I don't know much about object formats, gcc, and Windows. I may be mistaken in what I write here. I think there are three object file formats that are relevant for us: * OMF: the format dmd uses by default on 32 bit Windows, * COFF: the format dmd uses on 64 bit Windows and in 32 bit mode with the -m32mscoff switch, * ELF: the format gcc uses by default (on Linux at least, maybe on Windows too). You should probably try to find out what gcc produces (by reading gcc documentation, I supppose). Then you need to get your D compiler and your C compiler to produce the same format. As mentioned, dmd has some switches that affect the used/expected object format: -m32 (OMF) -m64 (COFF) -m32mscoff (COFF). You can also try to get gcc to produce another format. I don't know how to do that. Or you can use another C compiler that produces a different format than gcc. I'd expect Digital Mars's (i.e. Walter's) dmc to be compatible with dmd and produce OMF files. Looks like there's a free download: http://www.digitalmars.com/download/freecompiler.html dmd's COFF mode is supposed to be compatible with Microsoft's Visual Studio. So that would be another option. |
Copyright © 1999-2021 by the D Language Foundation