Hang at CreateImpl<PXCCapture>

Hang at CreateImpl<PXCCapture>

I am trying to intiailize and run a UtilPipeline from a DLL (details on why below). When I run my depth acquisition code directly in a test application, it initializes and runs fine. But the same code run from my DLL hangs on startup. I've traced the hang to the following line in:


UtilCapture::CreateCapture() {
/*stuff that seems to work fine*/
return m_session->CreateImpl<PXCCapture>(&desc2, capture); // HANG HERE!

It hits that CreateImpl and never comes back. I've printed out the contents of the desc2 structure, and it looks plausible enough:

G(4) SG(3) Alg(0) Iuid(843336531) V(1.0) Accel(255) Merit(201) vend(32902) PCUID(-661186491.0.0.0) Friendly(DepthSense 325 Audio/Video Capture) Reserved(12) (-0-0-0-0-0-0-0-0-0-0-0-0-)

My suspicion is that it has to do with the run-time libraries. To take a variable out of the equation, I've incorporated all of the util_* source and headers into my project (temp test) to ensure they have the same settings as my code. With /MTd they compile and link without any warnings. With /MDd I have to ignore LIBCMTD to get a warning-free link. The run-time behavior is the same in either case, I get the same hang at the same CreateImpl.

My questions are:

Is it known that I need to compile with one or the other of /MT and /MD in order to link with libpxc_d.lib, or should either work?

Has anyone accessed the SDK from a DLL module?

Are there any known situations which would cause a hang at CreateImpl<>, or any other things to try?


Note for those curious about why I would be doing this: I am working on an OpenNI wrapper for the camera, which among other things would open it up for access under projects like kinfu and the many cool libraries of PCL. I've done this for other depth cameras, so I'm pretty confident that the problem is just my build settings or lib compatibilities or the like, rather than a code or hardware problem. If I do manage to get something working, I'd be happy to share what I find.

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Mark,

I had similar problems, until I rebuilt utils library with next settings: (vs2008 ): Characted Set - Use multi-byte Character Set, Runtime Library - Multi-threaded Dll.  After that I used UtilPipeline without any issues.

Hi Yak32!

Thanks for the response.

I tried switching to "multi-byte Character Set" (I have had it set to Unicode), but it wouldn't compile. It looks like pxcCHAR is typedef'd to wchar_t in pxcdefs.h, no matter what the character set is set to. So I get compile errors in util_render.cpp and util_capture_file.cpp when Windows functions are expecting LPCSTR but receiving pxcCHAR==wchar_t. Did you have to do anything else to get these settings to work?

Also, when you switched to Multi-threaded DLL, did you have to ignore any default libraries? It makes me nervous that I am having to, like there is some other incompatible setting somewhere that I am missing.

Thanks again, I think you are right, that I need to make some adjustment to something like the runtimes or the character set, but I haven't found the magic incantation yet.

Oh, and I forgot to specify that I am using VS2010.

Wow, that was painful. I'm posting the solution on the off chance I can save someone else some grief.

I was initializing my system as my DLL was being loaded. While that had worked with other camera SDKs, that didn't work here. Apparently something in the Perceptual SDK wasn't ready yet, so any call to CreateImpl caused a hang (probably some deadlock as it waited for something which wasn't loaded yet).

Anyway, delaying my calls to CreateImpl (well, actually delaying all PXC and PXCUtils calls) until after the DLL was fully loaded broke the contention and it is loading fine now.

Hi Mark,

Yes, I also changed all Windows API function calls and structures aliases to  multi-byte part, for example CreateWindow to CreateWindowA etc. And I didn't ignore any libraries during linkage.

Great info, thanks for the followup!

Leave a Comment

Please sign in to add a comment. Not a member? Join today