I figure out that you are trying to build on debug mode, but the dlls present in the OTB 8.0.0 folder are in release mode. Maybe the problem is there, can you try to compile your helloworld by Adding -DCMAKE_BUILD_Type=Release?
Thank you for your help.
I re-built a release version by:
C:\otb8\mycode\Tutorials\buildf>cmake -DOTB_DIR=C:/otb8/OTB-8.0.0-Win64/lib/cmake/OTB-8.0/ …
– Building for: Visual Studio 16 2019
– Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
– The C compiler identification is MSVC 19.29.30143.0
– The CXX compiler identification is MSVC 19.29.30143.0
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
– Detecting C compile features
– Detecting C compile features - done
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
– Detecting CXX compile features
– Detecting CXX compile features - done
– Found OpenGL: opengl32
– Configuring done
– Generating done
– Build files have been written to: C:/otb8/mycode/Tutorials/buildf
C:\otb8\mycode\Tutorials\buildf>cmake --build . --config Release
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Checking Build System
Building Custom Rule C:/otb8/mycode/Tutorials/CMakeLists.txt
HelloWorldOTB.cxx
HelloWorldOTB.vcxproj → C:\otb8\mycode\Tutorials\buildf\Release\HelloWorldOTB.exe
Building Custom Rule C:/otb8/mycode/Tutorials/CMakeLists.txt
Created a Release folder and the .exe app. But the problem is still there, I cannot run, and errors are same.
I am not sure the “Check for working CXX compiler” message is correct or not.
– Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
I changed another PC with Win10, repeated everything and ran “HelloWorldOTB.exe”。 It works!
So,there is something wrong with my previous PC, or Win10 I guess。
Good to hear that it works, sometimes the Path is messed up on Windows and things can get tricky to fix. If you find the difference between the two windows PCs, it would be nice to tell the other users if someone encounters the same problem
So the situation is:
With the 1st PC, I can build source code but cannot run HelloWorldOTB
With the 2nd PC, I can run HelloWorldOTB.exe which was built from the released bin package, but cannot build source code.
The problem is nothing to do with build. It’s simply the PATH variable you set was not right. Before you run the HelloWorldOTB.exe, you can run the otbenv.bat file in your c:\otb8\OTB-8.0.0-Win64 directory. It will add the c:\otb8\OTB-8.0.0-Win64\bin directory to you PATH variable temporary. Then excute