Jump to page: 1 2 3
Thread overview
Re: Can't get D calling C to build.
Aug 20, 2010
Bob Cowdery
Aug 20, 2010
div0
Aug 21, 2010
Bob Cowdery
Aug 21, 2010
bearophile
Aug 21, 2010
Johannes Pfau
Aug 22, 2010
Bob Cowdery
Aug 22, 2010
bearophile
Aug 22, 2010
Bob Cowdery
Aug 23, 2010
Bob Cowdery
Aug 23, 2010
Bob Cowdery
Aug 23, 2010
Andrej Mitrovic
Aug 23, 2010
bearophile
Aug 23, 2010
bearophile
Aug 24, 2010
Bob Cowdery
Aug 26, 2010
Philippe Sigaud
Aug 26, 2010
Andrej Mitrovic
Aug 27, 2010
Bob Cowdery
Aug 27, 2010
Andrej Mitrovic
Aug 27, 2010
Philippe Sigaud
Aug 27, 2010
torhu
Aug 21, 2010
div0
Aug 22, 2010
Bob Cowdery
Aug 23, 2010
Kagamin
August 20, 2010
 Thanks for the replies. I've bounced off D a few times because it
didn't seem ready to risk a whole development. I should have mentioned
I'm trying this on Windows 7. I did suspect object formats were
incompatible but as you say would have expected a decent error message.
I also tried from the command line with the same problem, it just
generates an empty map file and nothing else. I also tried using gdc,
now surely the output of gcc and gdc must be compatible. However, it
didn't work and it doesn't look like gdc is being actively developed.

I'm still concerned it's a bit too soon as a lot of things seem to be either Windows or Linux (cmake says its only tested for *nix) but not both and there is very little guidance on building. I really want to get this working on Windows first. As D makes so much of its binary compatibility with C I find it odd that there is no information on how to build mixed systems just on how to code the calls.

dmc gives me this error:
OPTLINK : Error 118: Filename Expected
LIB="C:\D2.0\dm\bin\..\lib";"C:\D2.0\dm\bin\..\mfc\lib";C:\Program
Files\Gtk+\lib

The paths are correct as far as I can tell.

Sorry, didn't mean that to sound like a rant, just not sure where to go from here. Anybody got a definitive answer as to what works on Windows.

bob


>Jonathan M Davis said

>My first question would be whether you used the same linker for both D and C. On Linux, they should both be using gcc. On Windows, they should both be using dmc. Still, I would have expected a linking error to be a bit more explosive than nothing.

>steve said

>My experience has been the opposite - dmd is needed to link programs
>that mix C and D.  While you may not want to jump into CMake for
>builds, the regression tests for cmaked include building and link D+C
>objects and D + C libraries.
>http://code.google.com/p/cmaked2/wiki/GettingStarted
>FYI, cmaked is still work in progress, so you might run into bumps.
>-steve

>Kagamin said

>On windows dmd uses ancient OMF object format, but gcc compiles to COFF.



August 20, 2010
On 20/08/2010 09:17, Bob Cowdery wrote:
>
> I'm still concerned it's a bit too soon as a lot of things seem to be
> either Windows or Linux (cmake says its only tested for *nix) but not
> both and there is very little guidance on building. I really want to get
> this working on Windows first. As D makes so much of its binary
> compatibility with C I find it odd that there is no information on how
> to build mixed systems just on how to code the calls.

C compatibly is fine as long as you either build with dmc
or convert the VC c libs to dmc's format. The conversion tool is only available as part of the paid tool set off of digital mars I think; though possibly there's a free one around.

Try searching the learn archive it's been discussed before.

Personnaly I just compile stuff with dmc and it all works great as long as you get the extern c declarations right.

> dmc gives me this error:
> OPTLINK : Error 118: Filename Expected
> LIB="C:\D2.0\dm\bin\..\lib";"C:\D2.0\dm\bin\..\mfc\lib";C:\Program
> Files\Gtk+\lib
>
> The paths are correct as far as I can tell.
>

Optlink hates spaces in paths. It will also barf if you have spaces in any of the directories in the PATH environment var as well; you should setup an explicit PATH when running DMD.

If you really need stuff with spaces in the name, you can use junction to create symlinks on 'doze and put the sym links in your path instead:

http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
August 21, 2010
 On 20/08/2010 18:44, div0 wrote:
> On 20/08/2010 09:17, Bob Cowdery wrote:
>>
>> I'm still concerned it's a bit too soon as a lot of things seem to be either Windows or Linux (cmake says its only tested for *nix) but not both and there is very little guidance on building. I really want to get this working on Windows first. As D makes so much of its binary compatibility with C I find it odd that there is no information on how to build mixed systems just on how to code the calls.
>
> C compatibly is fine as long as you either build with dmc
> or convert the VC c libs to dmc's format. The conversion tool is only
> available as part of the paid tool set off of digital mars I think;
> though possibly there's a free one around.
>
> Try searching the learn archive it's been discussed before.
>
> Personnaly I just compile stuff with dmc and it all works great as long as you get the extern c declarations right.
>
I have compiled all my stuff now with dmc. It has some differences from gcc which caused me some issues. I then went to link up my program with a D front end and realised that I use many 3rd party libraries which will all need to be converted.  This doesn't seem like such a great idea any more. Why does a modern language use an old object format I wonder.

For me at least I'm wondering if it stacks up. Linux support seems secondary (correct me if I'm wrong). The only painless way to use C libraries is as dll's and even then the import library must be converted for which the tool in not free. The language itself is nice but the hassle factor for mixed language multi-platform seems quite high. I hope I'm wrong on both counts.

>> dmc gives me this error:
>> OPTLINK : Error 118: Filename Expected
>> LIB="C:\D2.0\dm\bin\..\lib";"C:\D2.0\dm\bin\..\mfc\lib";C:\Program
>> Files\Gtk+\lib
>>
>> The paths are correct as far as I can tell.
>>
>
> Optlink hates spaces in paths. It will also barf if you have spaces in any of the directories in the PATH environment var as well; you should setup an explicit PATH when running DMD.
>
> If you really need stuff with spaces in the name, you can use junction to create symlinks on 'doze and put the sym links in your path instead:
>
> http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx
>

August 21, 2010
Bob Cowdery:
> Why does a modern language use an old object format I wonder.

This problem will need to be addressed (among others).


> The language itself is nice but the
> hassle factor for mixed language multi-platform seems quite high. I hope
> I'm wrong on both counts.

Despite being in the works for about ten years, D language is young, and the manpower working on its tools and back-end is quite limited, so such problems get solved slowly. In theory help from external people may help the situation, but it's not an easy job (are you able to change dmd object format?).

Languages as Scala become usable in less time because they are based on an already existing virtual machine with good GC, a std lib, tons of tools, etc. D is both an ambitious language (C++ class performance with a better design) and is not much based on existing 'platforms'. So progress is slow. On the other hand Walter has shown to be determined and able to go on and on, so I have hope that many problems will be addressed :-)

Bye,
bearophile
August 21, 2010
On 21.08.2010 23:07, Bob Cowdery wrote:
> 
> For me at least I'm wondering if it stacks up. Linux support seems secondary (correct me if I'm wrong). The only painless way to use C libraries is as dll's and even then the import library must be converted for which the tool in not free.

I had the same problem some time ago, and in some old newsgroup post I
found this link:
ftp://ftp.digitalmars.com/coffimplib.zip

It still works. So I think it's free to use by the D community, but I could be totally wrong. Only Walter can answer that.
-- 
Johannes Pfau
August 21, 2010
On 21/08/2010 22:07, Bob Cowdery wrote:
>   On 20/08/2010 18:44, div0 wrote:
>> On 20/08/2010 09:17, Bob Cowdery wrote:
>>>
>>> I'm still concerned it's a bit too soon as a lot of things seem to be
>>> either Windows or Linux (cmake says its only tested for *nix) but not
>>> both and there is very little guidance on building. I really want to get
>>> this working on Windows first. As D makes so much of its binary
>>> compatibility with C I find it odd that there is no information on how
>>> to build mixed systems just on how to code the calls.
>>
>> C compatibly is fine as long as you either build with dmc
>> or convert the VC c libs to dmc's format. The conversion tool is only
>> available as part of the paid tool set off of digital mars I think;
>> though possibly there's a free one around.
>>
>> Try searching the learn archive it's been discussed before.
>>
>> Personnaly I just compile stuff with dmc and it all works great as
>> long as you get the extern c declarations right.
>>
> I have compiled all my stuff now with dmc. It has some differences from
> gcc which caused me some issues. I then went to link up my program with
> a D front end and realised that I use many 3rd party libraries which
> will all need to be converted.  This doesn't seem like such a great idea
> any more. Why does a modern language use an old object format I wonder.
>
> For me at least I'm wondering if it stacks up. Linux support seems
> secondary (correct me if I'm wrong). The only painless way to use C
> libraries is as dll's and even then the import library must be converted
> for which the tool in not free. The language itself is nice but the
> hassle factor for mixed language multi-platform seems quite high. I hope
> I'm wrong on both counts.

Well that's true; D still isn't really ready for production use, unless you have time or money to burn to do a lot of it yourself.

I love D, but I only use it for my own small hobby projects.

Mr B has stated though that once d2 is wrapped up (which should be just about now) he's going to start concentrating on the tool chain, so these sorts of issues I expect will get much better over the next 6 months.

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
August 22, 2010
 On 22/08/2010 00:54, div0 wrote:
> On 21/08/2010 22:07, Bob Cowdery wrote:
>>   On 20/08/2010 18:44, div0 wrote:
>>> On 20/08/2010 09:17, Bob Cowdery wrote:
>>>>
>>>> I'm still concerned it's a bit too soon as a lot of things seem to be
>>>> either Windows or Linux (cmake says its only tested for *nix) but not
>>>> both and there is very little guidance on building. I really want
>>>> to get
>>>> this working on Windows first. As D makes so much of its binary
>>>> compatibility with C I find it odd that there is no information on how
>>>> to build mixed systems just on how to code the calls.
>>>
>>> C compatibly is fine as long as you either build with dmc
>>> or convert the VC c libs to dmc's format. The conversion tool is only
>>> available as part of the paid tool set off of digital mars I think;
>>> though possibly there's a free one around.
>>>
>>> Try searching the learn archive it's been discussed before.
>>>
>>> Personnaly I just compile stuff with dmc and it all works great as long as you get the extern c declarations right.
>>>
>> I have compiled all my stuff now with dmc. It has some differences from gcc which caused me some issues. I then went to link up my program with a D front end and realised that I use many 3rd party libraries which will all need to be converted.  This doesn't seem like such a great idea any more. Why does a modern language use an old object format I wonder.
> >
>> For me at least I'm wondering if it stacks up. Linux support seems secondary (correct me if I'm wrong). The only painless way to use C libraries is as dll's and even then the import library must be converted for which the tool in not free. The language itself is nice but the hassle factor for mixed language multi-platform seems quite high. I hope I'm wrong on both counts.
>
> Well that's true; D still isn't really ready for production use, unless you have time or money to burn to do a lot of it yourself.
>
> I love D, but I only use it for my own small hobby projects.
>
> Mr B has stated though that once d2 is wrapped up (which should be just about now) he's going to start concentrating on the tool chain, so these sorts of issues I expect will get much better over the next 6 months.
>
Thanks, that's an honest opinion. The first project I have in mind is a personal one but it's quite large. My hope would be to move a lot of the C code into D eventually. I don't think I would risk it on a commercial project until the toolchain is sorted and its a bit more mature.
August 22, 2010
 On 21/08/2010 22:41, Johannes Pfau wrote:
> On 21.08.2010 23:07, Bob Cowdery wrote:
>> For me at least I'm wondering if it stacks up. Linux support seems secondary (correct me if I'm wrong). The only painless way to use C libraries is as dll's and even then the import library must be converted for which the tool in not free.
> I had the same problem some time ago, and in some old newsgroup post I
> found this link:
> ftp://ftp.digitalmars.com/coffimplib.zip
>
> It still works. So I think it's free to use by the D community, but I could be totally wrong. Only Walter can answer that.
Well, the link still works but the download is 0 bytes so I guess its not available. Thanks for the thought.
August 22, 2010
Bob Cowdery:
> Well, the link still works but the download is 0 bytes so I guess its not available. Thanks for the thought.

That links works for me :-)
Be happy, bye,
bearophile
August 22, 2010
 On 22/08/2010 20:57, bearophile wrote:
> Bob Cowdery:
>> Well, the link still works but the download is 0 bytes so I guess its not available. Thanks for the thought.
> That links works for me :-)
> Be happy, bye,
> bearophile
Works if I paste it but not straight from the email,odd.
« First   ‹ Prev
1 2 3