<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 4.0.0 beta</li>
<li>Operating System / Platform =&gt; Windows 7 64 Bit</li>
<li>Compiler =&gt; Visual Studio 2015 build tool , cmake, nmake</li>
</ul>
<h5 dir="auto">Detailed description</h5>

<p dir="auto">the code in <a href="https://github.com/opencv/opencv/blob/master/modules/stitching/src/blenders.cpp">modules\stitching\src\blenders.cpp</a></p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
#ifdef HAVE_CUDA
    namespace cv { namespace cuda { namespace device {
        namespace blend
        {
            void addSrcWeightGpu16S(const PtrStep&lt;short&gt; src, const PtrStep&lt;short&gt; src_weight,
                                    PtrStep&lt;short&gt; dst, PtrStep&lt;short&gt; dst_weight, cv::Rect &amp;rc);
            void addSrcWeightGpu32F(const PtrStep&lt;short&gt; src, const PtrStepf src_weight,
                                    PtrStep&lt;short&gt; dst, PtrStepf dst_weight, cv::Rect &amp;rc);
            void normalizeUsingWeightMapGpu16S(const PtrStep&lt;short&gt; weight, PtrStep&lt;short&gt; src,
                                               const int width, const int height);
            void normalizeUsingWeightMapGpu32F(const PtrStepf weight, PtrStep&lt;short&gt; src,
                                               const int width, const int height);
        }
    }
	 }
	  }
#endif"><pre class="notranslate">#<span class="pl-k">ifdef</span> HAVE_CUDA
    <span class="pl-k">namespace</span> <span class="pl-en">cv</span> { <span class="pl-k">namespace</span> <span class="pl-en">cuda</span> { <span class="pl-k">namespace</span> <span class="pl-en">device</span> {
        <span class="pl-k">namespace</span> <span class="pl-en">blend</span>
        {
            <span class="pl-k">void</span> <span class="pl-en">addSrcWeightGpu16S</span>(<span class="pl-k">const</span> PtrStep&lt;<span class="pl-k">short</span>&gt; src, <span class="pl-k">const</span> PtrStep&lt;<span class="pl-k">short</span>&gt; src_weight,
                                    PtrStep&lt;<span class="pl-k">short</span>&gt; dst, PtrStep&lt;<span class="pl-k">short</span>&gt; dst_weight, cv::<span class="pl-c1">Rect</span> &amp;rc);
            <span class="pl-k">void</span> <span class="pl-en">addSrcWeightGpu32F</span>(<span class="pl-k">const</span> PtrStep&lt;<span class="pl-k">short</span>&gt; src, <span class="pl-k">const</span> PtrStepf src_weight,
                                    PtrStep&lt;<span class="pl-k">short</span>&gt; dst, PtrStepf dst_weight, cv::<span class="pl-c1">Rect</span> &amp;rc);
            <span class="pl-k">void</span> <span class="pl-en">normalizeUsingWeightMapGpu16S</span>(<span class="pl-k">const</span> PtrStep&lt;<span class="pl-k">short</span>&gt; weight, PtrStep&lt;<span class="pl-k">short</span>&gt; src,
                                               <span class="pl-k">const</span> <span class="pl-k">int</span> width, <span class="pl-k">const</span> <span class="pl-k">int</span> height);
            <span class="pl-k">void</span> <span class="pl-en">normalizeUsingWeightMapGpu32F</span>(<span class="pl-k">const</span> PtrStepf weight, PtrStep&lt;<span class="pl-k">short</span>&gt; src,
                                               <span class="pl-k">const</span> <span class="pl-k">int</span> width, <span class="pl-k">const</span> <span class="pl-k">int</span> height);
        }
    }
	 }
	  }
#<span class="pl-k">endif</span></pre></div>
<p dir="auto">arose an error c3083,<br>
'device': the symbol to the left of a '::' must be a type<br>
'blend': is not a member of 'cv::cuda'</p>
<p dir="auto">guess the #ifdef was broken, HAVE_CUDA was ineffective, but in other cuda related modules no error occured</p>
<p dir="auto">seems the compiler prefers the "\contrib\modules\cudafeatures2d\include\opencv2\cudafeatures2d.hpp" to be the definition; while "modules\stitching\src\cuda\multiband_blend.cu" was the definition of functions</p>
<p dir="auto">the cmake.txt was simple, i did not notice anything related to the cu file</p>
<p dir="auto">what should i do now?</p>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">using cmake-gui and nmake , simply chechk the cuda stuffs and extra packages<br>
wait until 93% was done, and enounter the error</p>
<p dir="auto">the screen was like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Scanning dependencies of target opencv_stitching
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/blenders.cpp.obj
blenders.cpp
D:\download\opencv4\modules\stitching\src\blenders.cpp(473): error C3083: 'device': the symbol to the left of a '::' must be a type
D:\download\opencv4\modules\stitching\src\blenders.cpp(473): error C2039: 'blend': is not a member of 'cv::cuda'
D:\download\opencv4\contrib\modules\cudafeatures2d\include\opencv2/cudafeatures2d.hpp(61): note: see declaration of 'cv::cuda'
D:\download\opencv4\modules\stitching\src\blenders.cpp(473): error C2871: 'blend': a namespace with this name does not exist
D:\download\opencv4\modules\stitching\src\blenders.cpp(476): error C3861: 'addSrcWeightGpu32F': identifier not found
D:\download\opencv4\modules\stitching\src\blenders.cpp(480): error C3861: 'addSrcWeightGpu16S': identifier not found
D:\download\opencv4\modules\stitching\src\blenders.cpp(620): error C3083: 'device': the symbol to the left of a '::' must be a type
D:\download\opencv4\modules\stitching\src\blenders.cpp(620): error C2039: 'blend': is not a member of 'cv::cuda'
D:\download\opencv4\contrib\modules\cudafeatures2d\include\opencv2/cudafeatures2d.hpp(61): note: see declaration of 'cv::cuda'
D:\download\opencv4\modules\stitching\src\blenders.cpp(620): error C2871: 'blend': a namespace with this name does not exist
D:\download\opencv4\modules\stitching\src\blenders.cpp(623): error C3861: 'normalizeUsingWeightMapGpu32F': identifier not found
D:\download\opencv4\modules\stitching\src\blenders.cpp(627): error C3861: 'normalizeUsingWeightMapGpu16S': identifier not found
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe&quot;' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe&quot;' : return code '0x2'
Stop.

"><pre class="notranslate"><code class="notranslate">Scanning dependencies of target opencv_stitching
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/blenders.cpp.obj
blenders.cpp
D:\download\opencv4\modules\stitching\src\blenders.cpp(473): error C3083: 'device': the symbol to the left of a '::' must be a type
D:\download\opencv4\modules\stitching\src\blenders.cpp(473): error C2039: 'blend': is not a member of 'cv::cuda'
D:\download\opencv4\contrib\modules\cudafeatures2d\include\opencv2/cudafeatures2d.hpp(61): note: see declaration of 'cv::cuda'
D:\download\opencv4\modules\stitching\src\blenders.cpp(473): error C2871: 'blend': a namespace with this name does not exist
D:\download\opencv4\modules\stitching\src\blenders.cpp(476): error C3861: 'addSrcWeightGpu32F': identifier not found
D:\download\opencv4\modules\stitching\src\blenders.cpp(480): error C3861: 'addSrcWeightGpu16S': identifier not found
D:\download\opencv4\modules\stitching\src\blenders.cpp(620): error C3083: 'device': the symbol to the left of a '::' must be a type
D:\download\opencv4\modules\stitching\src\blenders.cpp(620): error C2039: 'blend': is not a member of 'cv::cuda'
D:\download\opencv4\contrib\modules\cudafeatures2d\include\opencv2/cudafeatures2d.hpp(61): note: see declaration of 'cv::cuda'
D:\download\opencv4\modules\stitching\src\blenders.cpp(620): error C2871: 'blend': a namespace with this name does not exist
D:\download\opencv4\modules\stitching\src\blenders.cpp(623): error C3861: 'normalizeUsingWeightMapGpu32F': identifier not found
D:\download\opencv4\modules\stitching\src\blenders.cpp(627): error C3861: 'normalizeUsingWeightMapGpu16S': identifier not found
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.


</code></pre></div>

<p dir="auto">further if i remove the preprocesser token, and hard code the namespaces and the functions ,</p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//#ifdef HAVE_CUDA  

    namespace cv { namespace cuda { namespace device {
        namespace blend
        {
            void addSrcWeightGpu16S(const PtrStep&lt;short&gt; src, const PtrStep&lt;short&gt; src_weight,
                                    PtrStep&lt;short&gt; dst, PtrStep&lt;short&gt; dst_weight, cv::Rect &amp;rc);
            void addSrcWeightGpu32F(const PtrStep&lt;short&gt; src, const PtrStepf src_weight,
                                    PtrStep&lt;short&gt; dst, PtrStepf dst_weight, cv::Rect &amp;rc);
            void normalizeUsingWeightMapGpu16S(const PtrStep&lt;short&gt; weight, PtrStep&lt;short&gt; src,
                                               const int width, const int height);
            void normalizeUsingWeightMapGpu32F(const PtrStepf weight, PtrStep&lt;short&gt; src,
                                               const int width, const int height);
        }
    }
	 }
	  }
//#endif
"><pre class="notranslate"><span class="pl-c"><span class="pl-c">//</span>#ifdef HAVE_CUDA  </span>

    <span class="pl-k">namespace</span> <span class="pl-en">cv</span> { <span class="pl-k">namespace</span> <span class="pl-en">cuda</span> { <span class="pl-k">namespace</span> <span class="pl-en">device</span> {
        <span class="pl-k">namespace</span> <span class="pl-en">blend</span>
        {
            <span class="pl-k">void</span> <span class="pl-en">addSrcWeightGpu16S</span>(<span class="pl-k">const</span> PtrStep&lt;<span class="pl-k">short</span>&gt; src, <span class="pl-k">const</span> PtrStep&lt;<span class="pl-k">short</span>&gt; src_weight,
                                    PtrStep&lt;<span class="pl-k">short</span>&gt; dst, PtrStep&lt;<span class="pl-k">short</span>&gt; dst_weight, cv::<span class="pl-c1">Rect</span> &amp;rc);
            <span class="pl-k">void</span> <span class="pl-en">addSrcWeightGpu32F</span>(<span class="pl-k">const</span> PtrStep&lt;<span class="pl-k">short</span>&gt; src, <span class="pl-k">const</span> PtrStepf src_weight,
                                    PtrStep&lt;<span class="pl-k">short</span>&gt; dst, PtrStepf dst_weight, cv::<span class="pl-c1">Rect</span> &amp;rc);
            <span class="pl-k">void</span> <span class="pl-en">normalizeUsingWeightMapGpu16S</span>(<span class="pl-k">const</span> PtrStep&lt;<span class="pl-k">short</span>&gt; weight, PtrStep&lt;<span class="pl-k">short</span>&gt; src,
                                               <span class="pl-k">const</span> <span class="pl-k">int</span> width, <span class="pl-k">const</span> <span class="pl-k">int</span> height);
            <span class="pl-k">void</span> <span class="pl-en">normalizeUsingWeightMapGpu32F</span>(<span class="pl-k">const</span> PtrStepf weight, PtrStep&lt;<span class="pl-k">short</span>&gt; src,
                                               <span class="pl-k">const</span> <span class="pl-k">int</span> width, <span class="pl-k">const</span> <span class="pl-k">int</span> height);
        }
    }
	 }
	  }
<span class="pl-c"><span class="pl-c">//</span>#endif</span>
</pre></div>
<p dir="auto">it will compile this file, but link will throw an error like this:<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="376676037" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/13019" data-hovercard-type="issue" data-hovercard-url="/opencv/opencv/issues/13019/hovercard?comment_id=435289395&amp;comment_type=issue_comment" href="https://github.com/opencv/opencv/issues/13019#issuecomment-435289395">#13019 (comment)</a></p>
<p dir="auto">the screen was like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Scanning dependencies of target opencv_stitching
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/blenders.cpp.obj
blenders.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/camera.cpp.obj
camera.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/exposure_compensate.cpp.obj
exposure_compensate.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/matchers.cpp.obj
matchers.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/motion_estimators.cpp.obj
motion_estimators.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/seam_finders.cpp.obj
seam_finders.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/stitcher.cpp.obj
stitcher.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/timelapsers.cpp.obj
timelapsers.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/util.cpp.obj
util.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/warpers.cpp.obj
warpers.cpp
[ 94%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/warpers_cuda.cpp.obj
warpers_cuda.cpp
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(451) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(202) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(203) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(204) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(497) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(244) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(245) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(288) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(246) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(529) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(289) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(290) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(443) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(470) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(539) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(507) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(461) : warning C4702: unreachable code
[ 94%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/opencl_kernels_stitching.cpp.obj
opencl_kernels_stitching.cpp
[ 94%] Building RC object modules/stitching/CMakeFiles/opencv_stitching.dir/vs_version.rc.res
Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17336
Copyright (C) Microsoft Corporation.  All rights reserved.

[ 94%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/opencv_stitching_main.cpp.obj
opencv_stitching_main.cpp
[ 94%] Linking CXX shared library ..\..\bin\opencv_stitching400.dll
   Creating library ..\..\lib\opencv_stitching400.lib and object ..\..\lib\opencv_stitching400.exp
blenders.cpp.obj : error LNK2019: unresolved external symbol &quot;void __cdecl cv::cuda::device::blend::addSrcWeightGpu16S(struct cv::cuda::PtrStep&lt;s
hort&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,class cv::Rect_&lt;int&gt; &amp;)&quot; (?addSrcWeightGpu1
6S@blend@device@cuda@cv@@YAXU?$PtrStep@F@34@0U534@1AEAV?$Rect_@H@4@@Z) referenced in function &quot;public: virtual void __cdecl cv::detail::MultiBand
Blender::feed(class cv::_InputArray const &amp;,class cv::_InputArray const &amp;,class cv::Point_&lt;int&gt;)&quot; (?feed@MultiBandBlender@detail@cv@@UEAAXAEBV_In
putArray@3@0V?$Point_@H@3@@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol &quot;void __cdecl cv::cuda::device::blend::addSrcWeightGpu32F(struct cv::cuda::PtrStep&lt;s
hort&gt;,struct cv::cuda::PtrStep&lt;float&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;float&gt;,class cv::Rect_&lt;int&gt; &amp;)&quot; (?addSrcWeightGpu3
2F@blend@device@cuda@cv@@YAXU?$PtrStep@F@34@U?$PtrStep@M@34@U534@U634@AEAV?$Rect_@H@4@@Z) referenced in function &quot;public: virtual void __cdecl cv
::detail::MultiBandBlender::feed(class cv::_InputArray const &amp;,class cv::_InputArray const &amp;,class cv::Point_&lt;int&gt;)&quot; (?feed@MultiBandBlender@deta
il@cv@@UEAAXAEBV_InputArray@3@0V?$Point_@H@3@@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol &quot;void __cdecl cv::cuda::device::blend::normalizeUsingWeightMapGpu16S(struct cv::cuda
::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,int,int)&quot; (?normalizeUsingWeightMapGpu16S@blend@device@cuda@cv@@YAXU?$PtrStep@F@34@U534@HH@Z) re
ferenced in function &quot;public: virtual void __cdecl cv::detail::MultiBandBlender::blend(class cv::_InputOutputArray const &amp;,class cv::_InputOutput
Array const &amp;)&quot; (?blend@MultiBandBlender@detail@cv@@UEAAXAEBV_InputOutputArray@3@0@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol &quot;void __cdecl cv::cuda::device::blend::normalizeUsingWeightMapGpu32F(struct cv::cuda
::PtrStep&lt;float&gt;,struct cv::cuda::PtrStep&lt;short&gt;,int,int)&quot; (?normalizeUsingWeightMapGpu32F@blend@device@cuda@cv@@YAXU?$PtrStep@M@34@U?$PtrStep@F@
34@HH@Z) referenced in function &quot;public: virtual void __cdecl cv::detail::MultiBandBlender::blend(class cv::_InputOutputArray const &amp;,class cv::_
InputOutputArray const &amp;)&quot; (?blend@MultiBandBlender@detail@cv@@UEAAXAEBV_InputOutputArray@3@0@Z)
..\..\bin\opencv_stitching400.dll : fatal error LNK1120: 4 unresolved externals
LINK failed. with 1120
NMAKE : fatal error U1077: '&quot;C:\Program Files\cmake\bin\cmake.exe&quot;' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe&quot;' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe&quot;' : return code '0x2'
Stop."><pre class="notranslate"><code class="notranslate">Scanning dependencies of target opencv_stitching
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/blenders.cpp.obj
blenders.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/camera.cpp.obj
camera.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/exposure_compensate.cpp.obj
exposure_compensate.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/matchers.cpp.obj
matchers.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/motion_estimators.cpp.obj
motion_estimators.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/seam_finders.cpp.obj
seam_finders.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/stitcher.cpp.obj
stitcher.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/timelapsers.cpp.obj
timelapsers.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/util.cpp.obj
util.cpp
[ 93%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/warpers.cpp.obj
warpers.cpp
[ 94%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/warpers_cuda.cpp.obj
warpers_cuda.cpp
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(451) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(202) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(203) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(204) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(497) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(244) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(245) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(288) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(246) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(529) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(289) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\src\warpers_cuda.cpp(290) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(443) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(470) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(539) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(507) : warning C4702: unreachable code
d:\download\opencv4\modules\stitching\include\opencv2\stitching\detail\warpers.hpp(461) : warning C4702: unreachable code
[ 94%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/opencl_kernels_stitching.cpp.obj
opencl_kernels_stitching.cpp
[ 94%] Building RC object modules/stitching/CMakeFiles/opencv_stitching.dir/vs_version.rc.res
Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17336
Copyright (C) Microsoft Corporation.  All rights reserved.

[ 94%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/opencv_stitching_main.cpp.obj
opencv_stitching_main.cpp
[ 94%] Linking CXX shared library ..\..\bin\opencv_stitching400.dll
   Creating library ..\..\lib\opencv_stitching400.lib and object ..\..\lib\opencv_stitching400.exp
blenders.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cuda::device::blend::addSrcWeightGpu16S(struct cv::cuda::PtrStep&lt;s
hort&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,class cv::Rect_&lt;int&gt; &amp;)" (?addSrcWeightGpu1
6S@blend@device@cuda@cv@@YAXU?$PtrStep@F@34@0U534@1AEAV?$Rect_@H@4@@Z) referenced in function "public: virtual void __cdecl cv::detail::MultiBand
Blender::feed(class cv::_InputArray const &amp;,class cv::_InputArray const &amp;,class cv::Point_&lt;int&gt;)" (?feed@MultiBandBlender@detail@cv@@UEAAXAEBV_In
putArray@3@0V?$Point_@H@3@@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cuda::device::blend::addSrcWeightGpu32F(struct cv::cuda::PtrStep&lt;s
hort&gt;,struct cv::cuda::PtrStep&lt;float&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;float&gt;,class cv::Rect_&lt;int&gt; &amp;)" (?addSrcWeightGpu3
2F@blend@device@cuda@cv@@YAXU?$PtrStep@F@34@U?$PtrStep@M@34@U534@U634@AEAV?$Rect_@H@4@@Z) referenced in function "public: virtual void __cdecl cv
::detail::MultiBandBlender::feed(class cv::_InputArray const &amp;,class cv::_InputArray const &amp;,class cv::Point_&lt;int&gt;)" (?feed@MultiBandBlender@deta
il@cv@@UEAAXAEBV_InputArray@3@0V?$Point_@H@3@@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cuda::device::blend::normalizeUsingWeightMapGpu16S(struct cv::cuda
::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,int,int)" (?normalizeUsingWeightMapGpu16S@blend@device@cuda@cv@@YAXU?$PtrStep@F@34@U534@HH@Z) re
ferenced in function "public: virtual void __cdecl cv::detail::MultiBandBlender::blend(class cv::_InputOutputArray const &amp;,class cv::_InputOutput
Array const &amp;)" (?blend@MultiBandBlender@detail@cv@@UEAAXAEBV_InputOutputArray@3@0@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cuda::device::blend::normalizeUsingWeightMapGpu32F(struct cv::cuda
::PtrStep&lt;float&gt;,struct cv::cuda::PtrStep&lt;short&gt;,int,int)" (?normalizeUsingWeightMapGpu32F@blend@device@cuda@cv@@YAXU?$PtrStep@M@34@U?$PtrStep@F@
34@HH@Z) referenced in function "public: virtual void __cdecl cv::detail::MultiBandBlender::blend(class cv::_InputOutputArray const &amp;,class cv::_
InputOutputArray const &amp;)" (?blend@MultiBandBlender@detail@cv@@UEAAXAEBV_InputOutputArray@3@0@Z)
..\..\bin\opencv_stitching400.dll : fatal error LNK1120: 4 unresolved externals
LINK failed. with 1120
NMAKE : fatal error U1077: '"C:\Program Files\cmake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
</code></pre></div>
<p dir="auto">finally it come to the question,</p>
<ul dir="auto">
<li>how to make sure of HAVE_CUDA<br>
and</li>
<li>why unresolved <strong>external</strong> symbol in the same file when the compiled code should be there</li>
</ul>
<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 4.0.0 beta</li>
<li>Operating System / Platform =&gt; Windows 7 64 Bit</li>
<li>Compiler =&gt; Visual Studio 2015  build tool   with cmake and nmake</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">compilation fails</p>
<p dir="auto">the earliest fail i've forgot the scene,<br>
it was in file "modules\cudaoptflow\src\farneback.cpp"<br>
in line 48 ,the FarnebackOpticalFlow was reported by compiler to be ambiguous<br>
i removed these code since the code was in #if !defined HAVE_CUDA || defined(CUDA_DISABLER) and i will use cuda</p>
<p dir="auto">in file   "modules\stitching\src\blenders.cpp"<br>
in line 40 or somewhere the namespace   cv::cuda::device::blend don't exist.  Obviously the #ifdef HAVE_CUDA did not work.<br>
i modified it by removing the #ifdef  , expose the code to the outer, for the same reason since i will use cuda<br>
it worked</p>
<p dir="auto">problem continues and maybe worse:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[ 88%] Linking CXX executable ..\..\bin\opencv_perf_cudaoptflow.exe

perf_optflow.cpp.obj : error LNK2019: unresolved external symbol 

&quot;public: static struct cv::Ptr&lt;class cv::cuda::FarnebackOpticalFlow&gt; __cdecl cv::cuda::FarnebackOpticalFlow::create(int,double,bool,int,int,int,double,int)&quot; 

(?create@FarnebackOpticalFlow@cuda@cv@@SA?AU?$Ptr@VFarnebackOpticalFlow@cuda@cv@@@3@HN_NHHHNH@Z) 

referenced in function 

&quot;protected: virtual void __cdecl
opencv_test::`anonymous namespace'::ImagePair_FarnebackOpticalFlow::PerfTestBody(void)&quot; (?PerfTestBody@ImagePair_FarnebackOpticalFlow@?A0x63873ea8@opencv_test@@MEAAXXZ)

..\..\bin\opencv_perf_cudaoptflow.exe : fatal error LNK1120: 1 unresolved externals
LINK failed. with 1120
NMAKE : fatal error U1077: '&quot;C:\Program Files\cmake\bin\cmake.exe&quot;' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe&quot;' : return code '0x2'

Stop.
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe&quot;' : return code '0x2'

Stop."><pre class="notranslate"><code class="notranslate">[ 88%] Linking CXX executable ..\..\bin\opencv_perf_cudaoptflow.exe

perf_optflow.cpp.obj : error LNK2019: unresolved external symbol 

"public: static struct cv::Ptr&lt;class cv::cuda::FarnebackOpticalFlow&gt; __cdecl cv::cuda::FarnebackOpticalFlow::create(int,double,bool,int,int,int,double,int)" 

(?create@FarnebackOpticalFlow@cuda@cv@@SA?AU?$Ptr@VFarnebackOpticalFlow@cuda@cv@@@3@HN_NHHHNH@Z) 

referenced in function 

"protected: virtual void __cdecl
opencv_test::`anonymous namespace'::ImagePair_FarnebackOpticalFlow::PerfTestBody(void)" (?PerfTestBody@ImagePair_FarnebackOpticalFlow@?A0x63873ea8@opencv_test@@MEAAXXZ)

..\..\bin\opencv_perf_cudaoptflow.exe : fatal error LNK1120: 1 unresolved externals
LINK failed. with 1120
NMAKE : fatal error U1077: '"C:\Program Files\cmake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'

Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'

Stop.
</code></pre></div>
<p dir="auto">i re-run cmake, unchecked perf-test, and rerun nmake</p>
<p dir="auto">the perf_cudaoptflow.exe was "avoided", but bug was not fixed, i got this soon:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="----------------------------------------------------------------------------------
[ 94%] Linking CXX shared library ..\..\bin\opencv_stitching400.dll
   Creating library ..\..\lib\opencv_stitching400.lib and object ..\..\lib\opencv_stitching400.exp
blenders.cpp.obj : error LNK2019: unresolved external symbol &quot;void __cdecl cv::cuda::device::blend::addSrcWeightGpu16S(struct
 cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,cla
ss cv::Rect_&lt;int&gt; &amp;)&quot; (?addSrcWeightGpu16S@blend@device@cuda@cv@@YAXU?$PtrStep@F@34@0U534@1AEAV?$Rect_@H@4@@Z) referenced in
function &quot;public: virtual void __cdecl cv::detail::MultiBandBlender::feed(class cv::_InputArray const &amp;,class cv::_InputArray
 const &amp;,class cv::Point_&lt;int&gt;)&quot; (?feed@MultiBandBlender@detail@cv@@UEAAXAEBV_InputArray@3@0V?$Point_@H@3@@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol &quot;void __cdecl cv::cuda::device::blend::addSrcWeightGpu32F(struct
 cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;float&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;float&gt;,cla
ss cv::Rect_&lt;int&gt; &amp;)&quot; (?addSrcWeightGpu32F@blend@device@cuda@cv@@YAXU?$PtrStep@F@34@U?$PtrStep@M@34@U534@U634@AEAV?$Rect_@H@4
@@Z) referenced in function &quot;public: virtual void __cdecl cv::detail::MultiBandBlender::feed(class cv::_InputArray const &amp;,cl
ass cv::_InputArray const &amp;,class cv::Point_&lt;int&gt;)&quot; (?feed@MultiBandBlender@detail@cv@@UEAAXAEBV_InputArray@3@0V?$Point_@H@3@
@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol &quot;void __cdecl cv::cuda::device::blend::normalizeUsingWeightMapGp
u16S(struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,int,int)&quot; (?normalizeUsingWeightMapGpu16S@blend@device@c
uda@cv@@YAXU?$PtrStep@F@34@U534@HH@Z) referenced in function &quot;public: virtual void __cdecl cv::detail::MultiBandBlender::blen
d(class cv::_InputOutputArray const &amp;,class cv::_InputOutputArray const &amp;)&quot; (?blend@MultiBandBlender@detail@cv@@UEAAXAEBV_Inp
utOutputArray@3@0@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol &quot;void __cdecl cv::cuda::device::blend::normalizeUsingWeightMapGp
u32F(struct cv::cuda::PtrStep&lt;float&gt;,struct cv::cuda::PtrStep&lt;short&gt;,int,int)&quot; (?normalizeUsingWeightMapGpu32F@blend@device@c
uda@cv@@YAXU?$PtrStep@M@34@U?$PtrStep@F@34@HH@Z) referenced in function &quot;public: virtual void __cdecl cv::detail::MultiBandBl
ender::blend(class cv::_InputOutputArray const &amp;,class cv::_InputOutputArray const &amp;)&quot; (?blend@MultiBandBlender@detail@cv@@UE
AAXAEBV_InputOutputArray@3@0@Z)
..\..\bin\opencv_stitching400.dll : fatal error LNK1120: 4 unresolved externals
LINK failed. with 1120
NMAKE : fatal error U1077: '&quot;C:\Program Files\cmake\bin\cmake.exe&quot;' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe&quot;' : return code '0x2'

Stop.
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe&quot;' : return code '0x2'

Stop."><pre class="notranslate"><code class="notranslate">----------------------------------------------------------------------------------
[ 94%] Linking CXX shared library ..\..\bin\opencv_stitching400.dll
   Creating library ..\..\lib\opencv_stitching400.lib and object ..\..\lib\opencv_stitching400.exp
blenders.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cuda::device::blend::addSrcWeightGpu16S(struct
 cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,cla
ss cv::Rect_&lt;int&gt; &amp;)" (?addSrcWeightGpu16S@blend@device@cuda@cv@@YAXU?$PtrStep@F@34@0U534@1AEAV?$Rect_@H@4@@Z) referenced in
function "public: virtual void __cdecl cv::detail::MultiBandBlender::feed(class cv::_InputArray const &amp;,class cv::_InputArray
 const &amp;,class cv::Point_&lt;int&gt;)" (?feed@MultiBandBlender@detail@cv@@UEAAXAEBV_InputArray@3@0V?$Point_@H@3@@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cuda::device::blend::addSrcWeightGpu32F(struct
 cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;float&gt;,struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;float&gt;,cla
ss cv::Rect_&lt;int&gt; &amp;)" (?addSrcWeightGpu32F@blend@device@cuda@cv@@YAXU?$PtrStep@F@34@U?$PtrStep@M@34@U534@U634@AEAV?$Rect_@H@4
@@Z) referenced in function "public: virtual void __cdecl cv::detail::MultiBandBlender::feed(class cv::_InputArray const &amp;,cl
ass cv::_InputArray const &amp;,class cv::Point_&lt;int&gt;)" (?feed@MultiBandBlender@detail@cv@@UEAAXAEBV_InputArray@3@0V?$Point_@H@3@
@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cuda::device::blend::normalizeUsingWeightMapGp
u16S(struct cv::cuda::PtrStep&lt;short&gt;,struct cv::cuda::PtrStep&lt;short&gt;,int,int)" (?normalizeUsingWeightMapGpu16S@blend@device@c
uda@cv@@YAXU?$PtrStep@F@34@U534@HH@Z) referenced in function "public: virtual void __cdecl cv::detail::MultiBandBlender::blen
d(class cv::_InputOutputArray const &amp;,class cv::_InputOutputArray const &amp;)" (?blend@MultiBandBlender@detail@cv@@UEAAXAEBV_Inp
utOutputArray@3@0@Z)
blenders.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cuda::device::blend::normalizeUsingWeightMapGp
u32F(struct cv::cuda::PtrStep&lt;float&gt;,struct cv::cuda::PtrStep&lt;short&gt;,int,int)" (?normalizeUsingWeightMapGpu32F@blend@device@c
uda@cv@@YAXU?$PtrStep@M@34@U?$PtrStep@F@34@HH@Z) referenced in function "public: virtual void __cdecl cv::detail::MultiBandBl
ender::blend(class cv::_InputOutputArray const &amp;,class cv::_InputOutputArray const &amp;)" (?blend@MultiBandBlender@detail@cv@@UE
AAXAEBV_InputOutputArray@3@0@Z)
..\..\bin\opencv_stitching400.dll : fatal error LNK1120: 4 unresolved externals
LINK failed. with 1120
NMAKE : fatal error U1077: '"C:\Program Files\cmake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'

Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'

Stop.
</code></pre></div>
<p dir="auto">i did not dive into code yet, was this encountered yet or was it only my fault???</p>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">the real problem was "unresolved external symbol"</p>