How to set CMAKE_PREFIX_PATH and place DLLs when compiling NxView

General Information

  • Product: C57-6-M
  • Ensenso SDK Version: 4.1.1023
  • Operating System: Windows 10 Pro
  • Visual Studio 2022 community
  • Qt 5.15.2
  • OpenCV 4.10.0
  • Data Attachments?
    • Screenshots

Problem / Question

I am building NxView from source code with reference to the above topic.
https://community.ensenso.com/t/error-occurs-when-nxview-source-code-build/896

Q1.Does
“Set the cmake variable CMAKE_PREFIX_PATH to the OpenCV library folder
(e.g. C:\Users\user.name\opencv\build)”
in the C:\Program Files\Ensenso\development\examples\C++\nxView\Readme.txt
file mean to set it as shown in the image below?

Q2.When I ran the build with the above settings,
a dialog box was displayed saying that the DLL could not be found.
I was able to run the program by copying opencv_world4110d.dll to
\Ensenso\development\examples\C++\nxView\out\build\x64-Debug\bin\Debug
Did I make a mistake in the settings?

Could you please tell me more about that?
Thank you in advance.
K.N.

Hi K.N.,

I do not quite understand the paths in your screenshot, so let me try to tell you what I did to reproduce your problem:

  1. I downloaded the Windows installer for OpenCV 4.10.0.
  2. I unpacked OpenCV directly into the Download folder.
  3. I opened the NxView project file with Visual Studio 2022.
  4. I added -DCMAKE_PREFIX_PATH=C:\Users\raphael\Downloads\opencv\build to the CMake command arguments.

After that I was able to compile and run NxView without it complaining about a missing OpenCV DLL. CMake had copied opencv_world4100d.dll to the right location, which in my case was C:\Program Files\Ensenso\development\examples\C++\nxView\out\build\x64-Debug\bin, right next to NxView.exe.

Having typed all that I just noticed that my DLL is called opencv_world4100d.dll, which would be consistent with your mention of OpenCV 4.10.0, while further down you refer to opencv_world4110d.dll. We also seem to require the DLL in different locations, or is your NxView.exe also located in \Ensenso\development\examples\C++\nxView\out\build\x64-Debug\bin\Debug?

I am not sure how to proceed. Maybe we can try to clarify the discrepancies and you could try again?

Regards,
Raphael

1 Like

Hi Raphael

Thank you for your reply.
Sorry. I wrote the wrong version of OpenCV.(4.11.0)
The steps I took, including paths, are as follows:

  1. I am experimenting by copying the development folder from
    when the SDK was installed to C:\hoge
    and renaming it to “development-SDKv411023”.
    C:\hoge\development-SDKv411023\examples
  2. Download opencv-4.11.0-windows.exe and run it to generate the “opencv” folder
    which will be placed in C:\opencv.
  3. In VS2022, select Open Local Folder
    C:\hoge\development-SDKv411023\examples\C++\nxView
  4. In VS2022, select Project-CMake Settings for NxViewExample from the menu.
    Add -DCMAKE_PREFIX_PATH=C:/opencv/build
    to the CMake command arguments.
  5. In VS2022, select Build-Build ALL from the menu.
  6. NxView.exe will be generated in
    C:\hoge\development-SDKv411023\examples\C++\nxView\out\build\x64-Debug\bin\Debug
    and the plugins folder and the following DLLs will be copied to
    C:\hoge\development-SDKv411023\examples\C++\nxView\out\build\x64-Debug\bin
    • opencv_world4110d.dll
    • Qt5Concurrentd.dll
    • Qt5Cored.dll
    • Qt5Networkd.dll
    • Qt5Widgetsd.dll
  7. When you select Debug-Start Debugging from the menu in VS2022, a dialog box appears stating that opencv_world4110d.dll cannot be found.
  8. If I run opencv_world4110d.dll in
    C:\hoge\development-SDKv411023\examples\C++\nxView\out\build\x64-Debug\bin\Debug, it will run without any problems.

Are there any steps that might be causing problems?
Thank you in advance.
K.N.