www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can't get D calling C to build.

reply Bob Cowdery <bob bobcowdery.plus.com> writes:
 Hi

Just trying to get started and need a little advice. First up was
selecting an IDE, tried a few and settled on Code::Blocks. I need
Windows and Linux and also C and D supported in the same IDE. The
support does not seem to be finished in Code::Blocks though, does it
really not have syntax highlighting for D or did I miss something.

Anyhow it works well enough for now. First task was to build a test of D
calling C. Made the simplest possible C static library, one method
returns a string. Made the simplest possible D app which calls the C
method and prints the result. I built the C part and then referenced it
as a library in the D build. The D build goes with no errors and says it
has written the output file... but it doesn't, there is  no output file.

It says:
Linking console executable: bin\Release\DTest.exe

Now I've tried this with just D code and it writes the output and runs
so I know something works. Does anyone know where to look, is it
Code::Blocks, compiler, stupidity (probably).

Regards
Bob
Aug 19 2010
next sibling parent reply Kagamin <spam here.lot> writes:
Bob Cowdery Wrote:

 Now I've tried this with just D code and it writes the output and runs
 so I know something works. Does anyone know where to look, is it
 Code::Blocks, compiler, stupidity (probably).

On windows dmd uses ancient OMF object format, but gcc compiles to COFF.
Aug 19 2010
parent Bob Cowdery <bob bobcowdery.plus.com> writes:
 A bit more playing and I see that it's assumed that C code is compiled
with dmc and then the  D code can be compiled with dmd which will also
link in the obj left by dmc. It wasn't clear at all that to make things
work easily one needs to use both the C and D Digital Mars compilers.

Code::Blocks has led me a right old game by adding in switches the
compiler doesn't understand. Eventually got it configured to use the dmc
and dmd toolchains and managed to build and link in a C library. Some
progress at last.

bob

On 20/08/2010 09:54, Bob Cowdery wrote:
  On 20/08/2010 06:51, Kagamin wrote:
 Bob Cowdery Wrote:

 Now I've tried this with just D code and it writes the output and runs
 so I know something works. Does anyone know where to look, is it
 Code::Blocks, compiler, stupidity (probably).


C obj file to OMF and it now builds. It seems very odd to me to have to jump through this loop. This should be up in big red letters on the D site somewhere. bob

Aug 20 2010
prev sibling parent Bob Cowdery <bob bobcowdery.plus.com> writes:
 On 20/08/2010 06:51, Kagamin wrote:
 Bob Cowdery Wrote:

 Now I've tried this with just D code and it writes the output and runs
 so I know something works. Does anyone know where to look, is it
 Code::Blocks, compiler, stupidity (probably).


C obj file to OMF and it now builds. It seems very odd to me to have to jump through this loop. This should be up in big red letters on the D site somewhere. bob
Aug 20 2010