views:

642

answers:

3

I'm trying to test out a library that provides a VC++ example; however, I use gcc/g++ for all of my projects.

Well, the way the VC++ example accesses the library is it uses the #import directive, passing the location of the library DLL, then it does a using namespace LIBRARYNAME, and then it's able to create some undefined type (I'd assume it's defined in the DLL) and create a new instance of it with __uuidof. From then on, to call one of the library functions the example just does a createdObj->foo() and that's that.

Well... g++'s #import is different from VC++'s import (see here), so this example won't work for me.

Is there any way this can be converted to compile under g++, or am I SOL until the library developer provides me with a static library I can try out?

+1  A: 

If you are using cygwin, then this page: http://www.cygwin.com/cygwin-ug-net/dll.html will provide you with all the help you need.

If you are using mingw, you can accomplish the same thing, but you probably won't have grep and sed, so you'll have to use some other method of doing the filtering to get your .def file.

Christopher
Thanks; unfortunately, that doesn't work, as the command they give on that website returns "no symbols" for me. Makes me wonder, then, how VC++ is able to extract the symbols from it? Perhaps it's because the library's functions are stdcall functions, not cdecl functions?
beepboopbopbop
A: 

If you were using #import in VC++ it means the DLL isn't a regular DLL, it's a COM DLL.

Since gcc doesn't have COM support, you'll just have to wait for the library author to write a non-COM version.

Dan Berindei
COM is well documented. You can interop with it using nothing more than a C compiler
jalf
Ok, I'm not saying it's impossible, but then you would have to create the interfaces by hand to match the VC++ vtable layout.You would be much better off finding a non-COM library or switching to a VC++ Express for this project.
Dan Berindei
A: 

Maybe it could have helped you to use the OLEViewer and "View type information" to extract the basics of the IDL. Or maybe you could just use the VC++ generated .tlh and .tli files and import them into your G++ project.

I guess this answer is way too late, but right now I'm encountering similar issues myself so I just got into this thread. Hope you found the solution on time.

Regards.

Mike