"identifier "IUnknown" is undefined" error Vista+Visual studio 2005

Hi,
I’m developping a real-time tracking motion filter using cuda. Unfortunately, while compiling with nvcc, I have this error :

1>C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\objbase.h(240): error:
1> identifier “IUnknown” is undefined

I’m developpping under VS2005.
My code compiled fine without the cuda part and with the default VS2005 compilator.

Does anyone know where can it comes from ?


Hypnoce

You better do it other way, take cuda sample that you think is most close to your application, verify it compiles and runs, and THEN start adding your files to THAT project.

We’ve been doing some GPGPU motion tracking filtering too. You can benchmark your card for this purpose here [url=“http://www.pawlin.com/content/view/94/9/”]http://www.pawlin.com/content/view/94/9/[/url]

Thanks for replying. I finally decided to separate my host code from my device code. Now it works fine.
I use directshow to extract frames from my video and it appears that cuda doesn’t like the COM programming. Maybe I’m wrong but that is what occured to me.

Hypnoce

try using intel OpenCV library (cvcam sublibrary) for directshow, they have nice wrapping for com and it’s free for commercial usage

don’t mix .cu files and cpp files. Make all your gpgpu stuff in cu-files and directshow in cpp files. Declare extern c gpgpu methods in cu files and access them from cpp area only by declarations.

also have a look at “cpp-integration” sample from SDK

The error comes from including COM root interface IUnknown (in objbase.h) into your project when VS is not installed correctly. I had that error when VS Express installation went bad. Huh nvcc included objbase.h??

Don’t mix cu and cpp files? Could you point out what problem I would have if I mix them together? Because currently I put some method of a class in one cpp file and some other method related to cuda in another cu file, and both are compiled using the FindCUDA cmake script (CUDA_ADD_LIBRARY(someclass_impl.cu someclass_base.cpp)…) At least, so far It works fine for me…so I am wondering what are the potential problems?

In my case, I install both VS 2005 and 2008. I use 2008 to handle the whole project. And apply 2005 bin for nvcc use. I met the same problem.

My solution is:

in the custom build command line: adding

-I “C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include”

All is fine.

I think the reason is my 2005 uses this SDK. But 2008 use “C:\Program Files\Microsoft SDKs\Windows\v6.0A”. There is something confusing introduced.

Explicitly indicating to nvcc which SDK is critical.

I had the same problem.

The way I got past the problem is by adding includes just before the IID_PPV_ARGS_Helper template that references IUnknown in objbase.h:

// [dino]: added these includes to battle the identifier “IUnknown” is undefined error
#include <wtypes.h>
#include <unknwn.h>

May not be the most kosher solution, but does it for me for now.

Able to compile all SDK in 32 bit mode on WXP-64, VS 2005 Express, NVIDIA toolkit and SDK for WXP (not the 64 bit version), Windows Platform SDK, DirectX, and glew…
(all but the OpenMP compiler dependent sample code…)

Thanks skribtsov, i was trying to compile cuda with opencv and was stuck at this until i found your post.

There is another way to avoid the IUnknown error, which seems to work fairly consistently.

[codebox]ifdef _WIN32

define WIN32_LEAN_AND_MEAN

endif[/codebox]

I just installed CUDA 4.0 final release. When compiling my project in VS2010, I ran into the “IUnknown is undefined” problem, this time in Windows SDK 7.0A.

Adding

[font=arial, verdana, tahoma, sans-serif]#define WIN32_LEAN_AND_MEAN[/font]

[font=“arial, verdana, tahoma, sans-serif”]at the top of my only .cu file solved the problem.[/font]

[font=“arial, verdana, tahoma, sans-serif”]

[/font]

[font=“arial, verdana, tahoma, sans-serif”]But it is interesting that this error happens, because the only 2 header files included were:[/font]

[font=“arial, verdana, tahoma, sans-serif”]

#include <cutil_inline.h>

#include <cutil_math.h>[/font]

I have a simalar error with OpenCV and CUDA on a Windows7 x64 System
I solve it.

I add
if (WIN32)
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
endif (WIN32)
to the CMakeList.txt in the failing modules.

opencv_cudafeatures2d
opencv_cudaimgproc
(HINT: for opencv untick the world module to ad the direction only to the failing moduls)

1 Like

How to solve this error

C:\Program Files (x86)\Windows Kits\8.1\include\um\combaseapi.h(229): error: identifier “IUnknown” is undefined

C:\Program Files (x86)\Windows Kits\8.1\include\um\combaseapi.h(229): warning: expression has no effect

1 error detected in the compilation of “C:/Users/HOME/AppData/Local/Temp/tmpxft_00001f50_00000000-9_data.cpp4.ii”.

–error 0x2 –

Error using vl_compilenn>nvcc_compile (line 540)
Command “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc” -c
“E:\PHASE1\matconvnet-1.0-beta24\matconvnet-1.0-beta24\matlab\src\bits\data.cu” -v -DNDEBUG -DENABLE_GPU -DENABLE_DOUBLE -D__SSSE3__
-gencode=arch=compute_50,code="sm_50,compute_50" -I"C:\Program Files\MATLAB\R2017a\extern\include" -I"C:\Program
Files\MATLAB\R2017a\toolbox\distcomp\gpu\extern\include" -gencode=arch=compute_50,code="sm_50,compute_50" -O3 -Xcompiler /MD
–compiler-bindir “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC..\VC\bin” -o
“E:\PHASE1\matconvnet-1.0-beta24\matconvnet-1.0-beta24\matlab\mex.build\bits\data.obj” failed.

Error in vl_compilenn (line 485)
nvcc_compile(opts, srcs{i}, objfile, flags.nvcc) ;