Using VS DLLs (ps3eye) in MinGW

I’m trying to use a DLL in MinGW that was originally created for Visual Studio. Specifically, the PS3EyeLib.

I started with a link Theo sent: http://wiki.tcl.tk/2435

That lead me to this: http://www.mingw.org/wiki/MSVC-and-MinGW-DLLs

That page, plus a few other scattered forum posts, got me to this point: http://kylemcdonald.net/random/ps3eyeTest.zip (drag /libs/ps3eye into the of /libs folder)

But I’m still getting the following error:

  
undefined reference to `__imp___ZN10IPS3EyeLib6CreateEv'  

I asked Theo and Arturo about this, since they’re awesome at getting things like this working… but I’d really appreciate any help I can get :slight_smile: Thanks!

Interesting, I had no idea you could do that …

hey Kyle - I gave it a go today but had similar results.
What I realized today is that the names in the def file are not in the correct format for mingw to recognize.

I saw somewhere that you can put at the bottom of the def file

myFuncAsMingGWExpectsIt=myFuncAsListedInDefFile and that can help point the compiler to the equivilant functions.

The function for example __imp___ZN10IPS3EyeLib6CreateEv is clearly the Create function in the def file - but the name mangling is so much that they seem completely different.

Still because it is C++ and not C it could be possible the MSVC symbols are not accessible from mingw.

in the past, when I’ve ran into this problem, I’ve written a library in c or smartly in c++ compiled from VS (maybe with some compatability flags, etc) that wraps the library that you can’t bring into mingw. I can’t remember all the steps that make it work, but I know that it’s possible and it might prove to be a quick solution if the library doesn’t have too many functions.

take care!
zach

Theo – thanks for giving it a shot, I saw some similar things but didn’t totally understand what it meant.

Zach – I mentioned this possibility to Theo, but I don’t think either of us knew you could compile from VS for GCC? I’ll have to read up on those flags. There are only a few functions that need to be wrapped, so it would be a great solution.

I think you can do it without gcc compiler, but just as a .c / .h library since those names don’t get mangled … there’s some info here:

http://www.nabble.com/CUDA-and-MinGW-co-…-48905.html

and this is immensely valuable if you do need to mix c and c++

http://www.parashift.com/c+±faq-lite/m-…-l#faq-32.6

when I have a chance, I’ll try to dig up and see how I did it. I dont’ think it was too complicated, but took a bit of poking around to find the right way to wrap what I needed.

take care!
zach

Another tip or two on this would be awesome!

Here’s my simple test:

  
  
// PS3EyeMinGW.h  
#pragma once  
#include "IPS3EyeLib.h"  
extern "C" void IPS3EyeLib_Create(IPS3EyeLib* camera);  
  
// PS3EyeMinGW.cpp  
#include "PS3EyeMinGW.h"  
extern "C" void IPS3EyeLib_Create(IPS3EyeLib* camera) {  
	camera = IPS3EyeLib::Create();  
}  
  

I have IPS3EyeLib.h in the “Header Files” folder, and the build configuration specifies DLL as the configuration type and PS3EyeLib.lib as an additional dependency (under Linker>Input). When I build, it spits out a 27 KB DLL (the PS3EyeLib DLL is 15 KB). When I run pexports on the resulting DLL, I don’t see anything. Verbose mode yields only:

  
  
; .textbss: RVA: 00001000, File offset: 00000000  
;    .text: RVA: 00011000, File offset: 00000400  
;   .rdata: RVA: 00015000, File offset: 00003a00  
;    .data: RVA: 00017000, File offset: 00005400  
;   .idata: RVA: 00018000, File offset: 00005600  
;    .rsrc: RVA: 00019000, File offset: 00006000  
;   .reloc: RVA: 0001a000, File offset: 00006400  
  

(Which I don’t understand)

Does anybody have any more hints on this?

I’m kind of stuck, and can’t see what’s wrong. As far as I can tell, the MSVC project is creating a nice DLL for me that’s a reasonable size, but pexports doesn’t see any of the symbols I would expect to see.