Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Szabadember on May 24, 2007, 11:20:55 am

Title: dwmapi.h, Vista GLASS and MingW compiler?
Post by: Szabadember on May 24, 2007, 11:20:55 am
Hi everybody!
I would like to use the new DWMAPI(Desktop Window Manager API) introduced in windows Vista, but i don't want to change to another compiler. Is it possible to use the dwmapi with MingW or gcc? There's no dwmapi.h in the include folder of my MingW installation.

I also tried to use the VC compiler from the windows sdk but i get 284 Warnings although everything seems to work fine.
Title: Re: dwmapi.h, Vista GLASS and MingW compiler?
Post by: Szabadember on May 24, 2007, 06:08:18 pm
I've already solved it, i used LoadLibrary() to import "dwmapi.dll" and wrote my own header.
I'm soooooooo smart!!!  :lol: 8)
Title: Re: dwmapi.h, Vista GLASS and MingW compiler?
Post by: wxLearner on May 24, 2007, 09:42:27 pm
I've already solved it, i used LoadLibrary() to import "dwmapi.dll" and wrote my own header.
I'm soooooooo smart!!!  :lol: 8)
The Linux and MinGW linker ld can link to shared libraries directly (you don't need any import lib and you don't need the LoadLibrary/FreeLibrary and GetProcAddress APIs). If the dwmapi.dll exports C functions, it shouldn't be a problem.
Title: Re: dwmapi.h, Vista GLASS and MingW compiler?
Post by: iw2nhl on May 24, 2007, 11:29:17 pm
The Linux and MinGW linker ld can link to shared libraries directly (you don't need any import lib and you don't need the LoadLibrary/FreeLibrary and GetProcAddress APIs). If the dwmapi.dll exports C functions, it shouldn't be a problem.
Are you sure? I tried to use a DLL, but MinGW linker could not use it: it always complained about unresolved functions.
(the compilation was fine because I had the ".h" files)
May be because the DLL was generated with VC++?
I needed to use the xerces-c lib (an XML parser) and I solved recompiling it with MinGW as a static lib (it generated a ".a" file which was good for MinGW).

Anyway if you know why it didn't work, please tell me! It would be nice to be able to use the DLL directly :-)
Title: Re: dwmapi.h, Vista GLASS and MingW compiler?
Post by: wxLearner on May 25, 2007, 02:16:55 pm
If a dll exports C functions, ld can link them directly also, because no name mangling is used. xerces-c (http://xml.apache.org/xerces-c/) is a C++ library, or is there a C version also? C++ libraries, built by different compilers/linkers, mostly export different names. To avoid name mangling, a C bridge can be used:
Code
#ifdef __cplusplus
extern "C"
{
#endif

//no name mangling here

#ifdef __cplusplus
}
#endif
If it's a VC dll, VC's import libs can be used by ld also. If you don't have VC's import lib, you can use pexports (http://www.emmestech.com/software/cygwin/pexports-0.43/moron1.html) (which is included in mingw-utils), to create a .def file and then use dlltool to create a .a file (MinGW import lib). Take a look at the MinGW-FAQ (http://www.mingw.org/mingwfaq.shtml#faq-msvcdll) also.
Title: Re: dwmapi.h, Vista GLASS and MingW compiler?
Post by: iw2nhl on May 25, 2007, 02:56:24 pm
Thank you very much to everyone for the infos!

I'll try with that tools of MinGW, I din't know it was possible...