www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D not able to link .o files

reply meldolion <pi marsinvasion.de> writes:
I tried to include a external c function created by MinGW in a D source.

so I got a helloworld.o file

when i want to compile my main.d module with following command:

dmd main.d helloworld.o 
I get the error
Error: unrecognized file extension o

How can I solve that problem

thx for help
meldolion
Feb 25 2008
parent reply Tim Healey <leikeze gmail.com> writes:
meldolion wrote:
 I tried to include a external c function created by MinGW in a D source.
 
 so I got a helloworld.o file
 
 when i want to compile my main.d module with following command:
 
 dmd main.d helloworld.o 
 I get the error
 Error: unrecognized file extension o
 
 How can I solve that problem
 
 thx for help
 meldolion

Different compilers use different object formats. It would probably be easier to either compile the C program with Digital Mars C and continue using DMD or compile the D program with GDC and continue using MinGW.
Feb 25 2008
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Tim Healey wrote:
 meldolion wrote:
 I tried to include a external c function created by MinGW in a D source.

 so I got a helloworld.o file

 when i want to compile my main.d module with following command:

 dmd main.d helloworld.o I get the error
 Error: unrecognized file extension o

 How can I solve that problem

 thx for help
 meldolion

Different compilers use different object formats. It would probably be easier to either compile the C program with Digital Mars C and continue using DMD or compile the D program with GDC and continue using MinGW.

BTW, if you got your DMD installation from DigitalMars.com (and not from the Tango folks) then you already have a copy of "dmc" the DigitalMars C++ compiler. Additionally, one way to get around the object file differences is to build a DLL, since the DLL format is standardized. Given a MinGW library called libThing.a you can build a shared lib with a crazy command line like this: gcc -mno-cygwin -shared -o Thing.dll \ -Wl,--out-implib=Thing_mingw.lib \ -Wl,--export-all-symbols -Wl,--allow-multiple-definition \ -Wl,--enable-auto-import -Wl,--whole-archive libThing.a \ -Wl,--no-whole-archive [libs libThing uses internally] That'll create Thing.dll and an import lib called Thing_mingw.lib. Ignore Thing_mingw.lib, and create a new DMD-compatible import lib using: implib /system Thingdll.lib Thing.dll (implib should be in the dm/bin dir) --bb
Feb 25 2008
parent reply Jacob Carlborg <doobnet gmail.com> writes:
Bill Baxter wrote:
 That'll create Thing.dll and an import lib called Thing_mingw.lib.
 Ignore Thing_mingw.lib, and create a new DMD-compatible import lib using:
 
     implib /system Thingdll.lib Thing.dll
 
 (implib should be in the dm/bin dir)
 --bb

I have never seen implib in either the dmd zip or dmc
Feb 25 2008
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Jacob Carlborg wrote:
 Bill Baxter wrote:
 That'll create Thing.dll and an import lib called Thing_mingw.lib.
 Ignore Thing_mingw.lib, and create a new DMD-compatible import lib using:

     implib /system Thingdll.lib Thing.dll

 (implib should be in the dm/bin dir)
 --bb

I have never seen implib in either the dmd zip or dmc

Oops. Maybe you need to get the "Basic Utilities Package" then. I should read my README.txt more closely next time ;-). There I clearly state: """ Next you need to create a D-compatible import lib from that using 'implib' in the "Basic Utilties Package": http://www.digitalmars.com/download/freecompiler.html --> http://ftp.digitalmars.com/bup.zip """ :-) --bb
Feb 25 2008
parent reply Jacob Carlborg <doobnet gmail.com> writes:
Bill Baxter wrote:
 Jacob Carlborg wrote:
 Bill Baxter wrote:
 That'll create Thing.dll and an import lib called Thing_mingw.lib.
 Ignore Thing_mingw.lib, and create a new DMD-compatible import lib 
 using:

     implib /system Thingdll.lib Thing.dll

 (implib should be in the dm/bin dir)
 --bb

I have never seen implib in either the dmd zip or dmc

Oops. Maybe you need to get the "Basic Utilities Package" then. I should read my README.txt more closely next time ;-). There I clearly state: """ Next you need to create a D-compatible import lib from that using 'implib' in the "Basic Utilties Package": http://www.digitalmars.com/download/freecompiler.html --> http://ftp.digitalmars.com/bup.zip """ :-) --bb

There they are, that will make a lot of things easier :)
Feb 25 2008
parent reply meldolion <pi marsinvasion.d> writes:
thx for answering

i will try it
Feb 26 2008
parent meldolion <pi marsinvasion.d> writes:
another information is written here.

http://www.digitalmars.com/d/1.0/faq.html#omf
Feb 26 2008