www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D does not like certain libraries

reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
in particular, the directx 9 libraries.  if i try to link them into my
project, optlink whines that they are not valid libraries.

i found a fantastic up-to-date d3d9 D module on a japanese website
(http://hp.vector.co.jp/authors/VA031566/d_direct3d9/).  unfortunately, it's
in.. japanese.  so they guy might explain why you can't use these libraries
directly, but i wouldn't know.  instead, his module loads the directx DLL
and gets the process addresses.  which works, but isn't very elegant, and
it's a pain to load all the functions before i use them.

that site links to a DX8 conversion project by Burton Radons.  but it's DX8
and i want DX9 ;)

as an example i've attached quartz.lib, one of the libraries that doesn't
work.  try linking it into a project and you'll see what i mean.

does anyone have ANY idea why these libraries don't want to link?
Jul 16 2004
next sibling parent reply Ilya Minkov <minkov cs.tum.edu> writes:
Jarrett Billingsley schrieb:

 in particular, the directx 9 libraries.  if i try to link them into my
 project, optlink whines that they are not valid libraries.

Probably they are not valid. The file you have attached looks suspiciously like a COFF library, like from MS or MinGW, while DigitalMars uses OMF format, like OpenWatcom. Even among compilers with the same format, always use the libraries generated by the corresponding compiler, because symbols or sections can be named differently. You have following choices: - since the library is a simple stub for a DLL, you can generate one from the DLL using DigitalMars implib. - otherwise you could try using the multi-format linker from Christof Meerwald (http://cmeerw.org/prog/owtools/) -eye
Jul 16 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
In article <cd981s$gci$1 digitaldaemon.com>, Ilya Minkov says...
Jarrett Billingsley schrieb:

 in particular, the directx 9 libraries.  if i try to link them into my
 project, optlink whines that they are not valid libraries.

Probably they are not valid. The file you have attached looks suspiciously like a COFF library, like from MS or MinGW, while DigitalMars uses OMF format, like OpenWatcom. Even among compilers with the same format, always use the libraries generated by the corresponding compiler, because symbols or sections can be named differently. You have following choices: - since the library is a simple stub for a DLL, you can generate one from the DLL using DigitalMars implib. - otherwise you could try using the multi-format linker from Christof Meerwald (http://cmeerw.org/prog/owtools/) -eye

I think what Ilya has written is correct. There was a similar discussion on dsource regarding OpenGL .lib files: http://www.dsource.org/forums/viewtopic.php?t=221 jcc7
Jul 16 2004
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
thank you Ilya and JC :) didn't know that the two were actually different
formats!  you would think that a .lib would be very portable and that there
would only be one kind but i guess not.
Jul 16 2004
prev sibling next sibling parent reply pragma <EricAnderton at yahoo dot com> <pragma_member pathlink.com> writes:
In article <cd93p7$ehh$1 digitaldaemon.com>, Jarrett Billingsley says...
does anyone have ANY idea why these libraries don't want to link?

*Any* ideas? Well I've had issues linking against MS-compiled libraries as well. This is the reason why the Alpha for DSP features a C apache module (mod_dsp.c) instead of a D one. I've always thought it was some binary incompatibility between micrsoft's .lib format and Digitalmars' format, but I'm not sure on this. I just accepted the two as incompatible and moved on. - Pragma
Jul 16 2004
parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
"pragma" <EricAnderton at yahoo dot compragma_member pathlink.com> escribió
en el
mensaje news:cd98tp$gqa$1 digitaldaemon.com
| *Any* ideas?
|
| Well I've had issues linking against MS-compiled libraries as well.  This
is the
| reason why the Alpha for DSP features a C apache module (mod_dsp.c)
instead of a
| D one.
|
| I've always thought it was some binary incompatibility between micrsoft's
.lib
| format and Digitalmars' format, but I'm not sure on this. I just accepted
the
| two as incompatible and moved on.
|
| - Pragma

You can convert coff to omf. First, you convert the coff lib from version 6
to version 5 (lib /convert or link /convert, I'm not sure) with Microsoft
tools. Then you use DigitalMars' coff2omf and there you have it.

-----------------------
Carlos Santander Bernal
Jul 17 2004
next sibling parent pragma <EricAnderton at yahoo dot com> <pragma_member pathlink.com> writes:
In article <cdcsv9$1uvl$1 digitaldaemon.com>, Carlos Santander B. says...
"pragma" <EricAnderton at yahoo dot compragma_member pathlink.com> escribió
en el
mensaje news:cd98tp$gqa$1 digitaldaemon.com
| *Any* ideas?
|
| Well I've had issues linking against MS-compiled libraries as well.  This
is the
| reason why the Alpha for DSP features a C apache module (mod_dsp.c)
instead of a
| D one.
|
| I've always thought it was some binary incompatibility between micrsoft's
.lib
| format and Digitalmars' format, but I'm not sure on this. I just accepted
the
| two as incompatible and moved on.
|
| - Pragma

You can convert coff to omf. First, you convert the coff lib from version 6
to version 5 (lib /convert or link /convert, I'm not sure) with Microsoft
tools. Then you use DigitalMars' coff2omf and there you have it.

- Pragma
Jul 18 2004
prev sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
indeed, thank you :)  i figured that there should be some way to convert
.libs.  after all, they serve the same purpose.
Jul 20 2004
prev sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
aaagh :P

it doesn't work.  i used the DLL to generate a .lib file, and linked it, and
it worked fine.  but when i run it i get an access violation any time i try
to access ANY imported function.

not to mention there are a few directx libs that do not have any DLL
counterpart (like d3dx).  in which case i am TOTALLY stuck.

i read on that OpenGL thread that JC posted that i might need to make a .def
file with all the function names.. but who says that will work if the
conversion from DLL>lib didn't?  especially since the directx functions
don't have any decoration, and i don't see why i'd need a .def explaining
the conversions (like _func 4=func) ...
Jul 17 2004
parent reply Mike Parker <aldacron71 yahoo.com> writes:
Jarrett Billingsley wrote:
 aaagh :P
 
 it doesn't work.  i used the DLL to generate a .lib file, and linked it, and
 it worked fine.  but when i run it i get an access violation any time i try
 to access ANY imported function.
 
 not to mention there are a few directx libs that do not have any DLL
 counterpart (like d3dx).  in which case i am TOTALLY stuck.
 
 i read on that OpenGL thread that JC posted that i might need to make a .def
 file with all the function names.. but who says that will work if the
 conversion from DLL>lib didn't?  especially since the directx functions
 don't have any decoration, and i don't see why i'd need a .def explaining
 the conversions (like _func 4=func) ...
 
 

*Create functions. This can be avoided altogether via LoadLibrary or, preferably, obtaining the desired interfaces through the CoCreateInstance function. If you aren't familiar with COM, the three functions you will need are CoInitialize (or CoInitializeEx), CoCreateInstance, and CoUninitialize. This is the *only* way to use DirectMusic as there is no DirectMusic lib. If you've defined all of the GUIDs and interfaces you need then you should have no troubles with this approach.
Jul 17 2004
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
sorry, i was away for a few days :P

thanks for the response!  i've used those before (in my C++ DX project) and
i didn't know they existed in D.  i shall be looking into that :)
Jul 20 2004