# Opencv build error C2666

**URL:** https://forum.opencv.org/t/opencv-build-error-c2666/13933
**Category:** C++
**Tags:** dnn, build, cuda
**Created:** [July 19, 2023, 7:15am UTC](https://forum.opencv.org/t/opencv-build-error-c2666/13933 "2023-07-19T07:15:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sangonomiya\_Kokomi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sangonomiya_kokomi/32/8347_2.png) [@Sangonomiya\_Kokomi](https://forum.opencv.org/u/Sangonomiya_Kokomi)
#### Post date: [July 19, 2023, 7:15am UTC](https://forum.opencv.org/t/opencv-build-error-c2666/13933/1 "2023-07-19T07:15:11Z")

</div>

CUDA 12.2  
cudnn 8.9.2  
CMake version 3.26.4  
Visual Studio Enterprise 2022 versioin 17.6.4

```auto
D:\\opencv-4.8.0\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114,17): error C2666: “operator !=”: overloaded functions with similar conversion (Compile source files D:\\opencv-4.8.0\modules\dnn\src\layers\normalize_bbox_layer.cpp)
D:\\opencv-4.8.0\modules\dnn\src\layers\../cuda4dnn/primitives/region.hpp(124,17): error C2666: "operator >": overloaded functions with similar conversion (Compile source files D:\\opencv-4.8.0\modules\dnn\src\layers\region_layer.cpp)

```

build opencv\_world.vcxproj - failed

---

<div class="post-metadata">

### Author: ![cudawarped](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@cudawarped](https://forum.opencv.org/u/cudawarped)
#### Post date: [July 19, 2023, 8:21am UTC](https://forum.opencv.org/t/opencv-build-error-c2666/13933/2 "2023-07-19T08:21:29Z")

</div>

See [Compiling Opencv Error - #3 by cudawarped](https://forum.opencv.org/t/compiling-opencv-error/13798/3)

and

> <https://github.com/opencv/opencv/pull/23948#issuecomment-1633700052>
>
> \> Perhaps original issue is no caused by missing type case, but by ambiguous con…stant type. Try to change to \`1.f\` and \`0.f\`.
> 
> The static cast fixes the issue with CUDA 12.2 but due to the ambiguous constant type you mentioned causes an issue with earlier versions of CUDA.
> 
> The combination of both, i.e.
> \`\`\`
> if (weight != static\_cast\<T\>(1.0f))
> if(nms\_iou\_threshold \> static\_cast\<T\>(0.0f))
> \`\`\`
> or double
> \`\`\`
> if (weight != static\_cast\<T\>(1.0))
> if(nms\_iou\_threshold \> static\_cast\<T\>(0.0))
> \`\`\`
> works on Windows with Visual Studio 2022 for CUDA 12.1 (old math api) and CUDA 12.2.

for the fix. Unfortunately the person who initiated the PR fixing this issue has disapeared.

---

<div class="post-metadata">

### Author: ![sneeder](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sneeder](https://forum.opencv.org/u/sneeder)
#### Post date: [October 3, 2023, 1:25am UTC](https://forum.opencv.org/t/opencv-build-error-c2666/13933/3 "2023-10-03T01:25:21Z")

</div>

Yeah, same problem here, this is now blocking me from working on some important stuff. Has anyone filed a missing person’s report yet?

---

<div class="post-metadata">

### Author: ![cudawarped](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@cudawarped](https://forum.opencv.org/u/cudawarped)
#### Post date: [October 3, 2023, 5:07am UTC](https://forum.opencv.org/t/opencv-build-error-c2666/13933/4 "2023-10-03T05:07:17Z")

</div>

Fixed here

> <https://github.com/opencv/opencv/pull/24104>
>
> https://github.com/opencv/opencv/pull/23948 appears to have gone stale and it ha…s been over a month since CUDA 12.2 was introduced. This PR is to check if the two simple changes proposed there pass on the CI and if so prompt @jiapei100 to amend the PR or 🤞 one of the maintainers to fix it for them.
> 
> @asmorkalov @mshabunin @VadimLevin 
> \### Pull Request Readiness Checklist
> 
> See details at https://github.com/opencv/opencv/wiki/How\_to\_contribute#making-a-good-pull-request
> 
> \- \[x\] I agree to contribute to the project under Apache 2 License.
> \- \[x\] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
> \- \[x\] The PR is proposed to the proper branch
> \- \[x\] There is a reference to the original bug report and related work
> \- \[\] There is accuracy test, performance test and test data in opencv\_extra repository, if applicable
> Patch to opencv\_extra has the same branch name.
> \- \[\] The feature is well documented and sample code can be built with the project CMake
