Compilation error (VS 2008, 64 bit, Windows 7) [closed]

asked 2013-03-30 04:00:58 -0600

Alok gravatar image

Hi all,

I have successfully compiled OpenCV 2.4.4 for 64-bits using Visual Studio 2008 on Windows 7 x64.

When I create sample application now, I get compilation errors in one of the OpenCV header files:

\modules\core\include\opencv2/core/operations.hpp(1456) : error C2065: 'val' : undeclared identifier

The following is relevant piece of the code, where 'val' is claimed to be undeclared.

template<> inline Vec<float, 3> Vec<float, 3>::cross(const Vec<float, 3>& v) const
    return Vec<float,3>(val[1]*v.val[2] - val[2]*v.val[1],
                     val[2]*v.val[0] - val[0]*v.val[2],
                     val[0]*v.val[1] - val[1]*v.val[0]);

template<> inline Vec<double, 3> Vec<double, 3>::cross(const Vec<double, 3>& v) const
    return Vec<double,3>(val[1]*v.val[2] - val[2]*v.val[1],
                     val[2]*v.val[0] - val[0]*v.val[2],
                     val[0]*v.val[1] - val[1]*v.val[0]);

I do see 'val' in the base class of Vec, Matx, so not sure why is this error coming. Possibly some issue with template specialization?

If I comment out the code in the above two functions, compilation succeeds.

Please help!

Thanks and best regards,


edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-07 18:30:41.711477


are you using precompiled headers ?

berak gravatar imageberak ( 2013-03-30 04:08:42 -0600 )edit

@berak, I am not using pre-compiled headers. The Visual Studio solution is generated using Cmake. After struggling with this a bit, I find that the code compiles correctly if I prepare VS project by hand. Something is wrong in the Cmake files. It is discovering OpenCV includes and libs by itself, but maybe not from the correct place.

Alok gravatar imageAlok ( 2013-03-30 21:47:24 -0600 )edit

Getting to the bottom of the issue, this compilation error happens with Microsoft-specific language extensions are "disabled". This is compiler flag "/Za". Using this option is normally good to ensure the code will compile across platforms (since Microsoft-specific extensions are not available outside of Windows), but somehow there is some issue with OpenCV code even though it is cross-platform.

Alok gravatar imageAlok ( 2013-03-31 23:24:39 -0600 )edit

Hello Alok, Could you please help me with OpenCV installation? I have Windows 7, 64-bit. I am finding it difficult to install it. I have VS 2008 (i don't know if its for 32-bit/64-bit) and which version of OpenCV should i install? Could you please explain.....I want to learn lot of things but this installation is troubling a lot! thanks n best regards, shekhar

learner123 gravatar imagelearner123 ( 2013-04-01 14:53:03 -0600 )edit

@shekar, since your problem might be total different from this one, please dare to start a new question !

berak gravatar imageberak ( 2013-04-01 15:11:48 -0600 )edit