"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
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

#1
Posted 05/22/2008 11:31 PM   
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]
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 http://www.pawlin.com/content/view/94/9/

#2
Posted 05/23/2008 04:26 AM   
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
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

#3
Posted 05/23/2008 10:49 AM   
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
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

#4
Posted 05/26/2008 04:15 AM   
[quote name='hypnoce' date='May 22 2008, 03:31 PM']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
[right][snapback]381480[/snapback][/right]
[/quote]

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??
[quote name='hypnoce' date='May 22 2008, 03:31 PM']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

[snapback]381480[/snapback]






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??

#5
Posted 05/27/2008 07:27 PM   
[quote name='Skribtsov' date='May 25 2008, 08:15 PM']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
[right][snapback]383305[/snapback][/right]
[/quote]
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?
[quote name='Skribtsov' date='May 25 2008, 08:15 PM']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

[snapback]383305[/snapback]




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?

#6
Posted 05/27/2008 11:54 PM   
[quote name='hypnoce' date='May 23 2008, 07:31 AM']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
[right][snapback]381480[/snapback][/right]
[/quote]

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.
[quote name='hypnoce' date='May 23 2008, 07:31 AM']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

[snapback]381480[/snapback]






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.

#7
Posted 07/03/2008 12:24 PM   
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...)
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...)

#8
Posted 10/10/2008 12:01 AM   
[quote name='Skribtsov' post='383305' date='May 26 2008, 05:15 AM']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[/quote]

Thanks skribtsov, i was trying to compile cuda with opencv and was stuck at this until i found your post.
[quote name='Skribtsov' post='383305' date='May 26 2008, 05:15 AM']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



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

#9
Posted 02/16/2009 02:58 AM   
[quote name='newbs' post='506304' date='Feb 16 2009, 12:58 PM']Thanks skribtsov, i was trying to compile cuda with opencv and was stuck at this until i found your post.[/quote]

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]
[quote name='newbs' post='506304' date='Feb 16 2009, 12:58 PM']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]

#10
Posted 02/16/2009 04:04 AM   
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
[color=#1C2837][font=arial, verdana, tahoma, sans-serif][size=2]#define WIN32_LEAN_AND_MEAN[/size][/font][/color]
[font="arial, verdana, tahoma, sans-serif"][size="2"][color="#1c2837"]at the top of my only .cu file solved the problem.[/color][/size][/font]
[font="arial, verdana, tahoma, sans-serif"][size="2"][color="#1c2837"]
[/color][/size][/font]
[font="arial, verdana, tahoma, sans-serif"][size="2"][color="#1c2837"]But it is interesting that this error happens, because the only 2 header files included were:[/color][/size][/font]
[font="arial, verdana, tahoma, sans-serif"][size="2"][color="#1c2837"]
#include <cutil_inline.h>
#include <cutil_math.h>[/color][/size][/font]
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]

at the top of my only .cu file solved the problem.





But it is interesting that this error happens, because the only 2 header files included were:



#include <cutil_inline.h>

#include <cutil_math.h>

#11
Posted 05/26/2011 02:48 PM   
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)
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)

#12
Posted 12/07/2017 11:50 AM   
Scroll To Top

Add Reply