this is my CmakeList.txt "cmakeminimumrequired(VERSION 3.10) project(MyApp)…
- User
this is my CmakeList.txt "cmake_minimum_required(VERSION 3.10) project(MyApp)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON)
Include directories
include_directories("include\") #include_directories("C:\Users\ali\Desktop\yoloCPPWin\include\win\opencv\build\include\opencv2") include_directories("C:\msys64\mingw64\include\opencv2")
include_directories("C:\Users\ali\Desktop\yoloCPPWin\include\win\onnxruntime\include")
Link directories
link_directories("C:\Users\ali\Desktop\yoloCPPWin\include\win\onnxruntime\lib")
Set source files
Add executable target
add_executable(MyApp panel2CnnMain.cpp)
Link OpenCV libraries
#target_link_libraries(MyApp "include\win\opencv\build\x64\vc16\lib") link_directories("C:\cUsers\ali\Desktop\yoloCPPWin\include\win\opencv\build\x64\vc16\lib")
Link ONNX Runtime libraries
target_link_libraries(MyApp onnxruntime)
If ONNX Runtime requires additional libraries, specify them here, for example:
target_link_libraries(MyApp ${ONNXRUNTIME_LIB_DEPENDENCIES})" and i get this errors "C:\Users\ali\Desktop\yoloCPPWin\build>make
[ 50%] Building CXX object CMakeFiles/MyApp.dir/panel2CnnMain.cpp.obj In file included from C:\Users\ali\Desktop\yoloCPPWin\panel2CnnMain.cpp:11: C:/Users/ali/Desktop/yoloCPPWin/include/cnnLayers.hpp: In function 'BoundingBox utils::scaleCoords(const cv::Size&, BoundingBox, const cv::Size&, bool)': C:/Users/ali/Desktop/yoloCPPWin/include/cnnLayers.hpp:227:29: error: 'clamp' is not a member of 'std' 227 | result.x = std::clamp(result.x, 0, imageOriginalShape.width); | ^~~~~ C:/Users/ali/Desktop/yoloCPPWin/include/cnnLayers.hpp:228:29: error: 'clamp' is not a member of 'std' 228 | result.y = std::clamp(result.y, 0, imageOriginalShape.height); | ^~~~~ C:/Users/ali/Desktop/yoloCPPWin/include/cnnLayers.hpp:229:33: error: 'clamp' is not a member of 'std' 229 | result.width = std::clamp(result.width, 0, imageOriginalShape.width - result.x); | ^~~~~ C:/Users/ali/Desktop/yoloCPPWin/include/cnnLayers.hpp:230:34: error: 'clamp' is not a member of 'std' 230 | result.height = std::clamp(result.height, 0, imageOriginalShape.height - result.y); | ^~~~~ In file included from C:/Users/ali/Desktop/yoloCPPWin/include/AnomalyDetector.hpp:13, from C:\Users\ali\Desktop\yoloCPPWin\panel2CnnMain.cpp:12: C:/Users/ali/Desktop/yoloCPPWin/include/MyUtility.hpp: In static member function 'static std::string Utility::GenerateFolder(std::string, std::string)': C:/Users/ali/Desktop/yoloCPPWin/include/MyUtility.hpp:42:14: error: 'std::filesystem' has not been declared 42 | std::filesystem::create_directory(suffix + "/" + dateStream.str() + "/"); | ^~~~~~~~~~ C:/Users/ali/Desktop/yoloCPPWin/include/MyUtility.hpp:46:18: error: 'std::filesystem' has not been declared 46 | if (std::filesystem::exists(folderName)) | ^~~~~~~~~~ C:/Users/ali/Desktop/yoloCPPWin/include/MyUtility.hpp:52:18: error: 'std::filesystem' has not been declared 52 | if (std::filesystem::create_directory(folderName)) | ^~~~~~~~~~ C:\Users\ali\Desktop\yoloCPPWin\panel2CnnMain.cpp: In function 'void DoAction(std::string, bool, float)': C:\Users\ali\Desktop\yoloCPPWin\panel2CnnMain.cpp:82:10: error: 'std::filesystem' has not been declared 82 | std::filesystem::path fs = imagePath; | ^~~~~~~~~~ C:\Users\ali\Desktop\yoloCPPWin\panel2CnnMain.cpp:84:59: error: 'fs' was not declared in this scope 84 | string resultPath = Utility::GenerateFolder("result", fs.filename().string()); | ^~ C:\Users\ali\Desktop\yoloCPPWin\panel2CnnMain.cpp: In function 'void Automode()': C:\Users\ali\Desktop\yoloCPPWin\panel2CnnMain.cpp:135:39: error: 'std::filesystem' has not been declared 135 | for (const auto &entry : std::filesystem::directory_iterator(_cfg[0])) | ^~~~~~~~~~ C:\Users\ali\Desktop\yoloCPPWin\panel2CnnMain.cpp:151:18: error: 'std::filesystem' has not been declared 151 | std::filesystem::remove(_cfg[0] + "/" + jpgName); | ^~~~~~~~~~ make[2]: *** [CMakeFiles/MyApp.dir/panel2CnnMain.cpp.obj] Error 1 make[1]: *** [CMakeFiles/MyApp.dir/all] Error 2 make: *** [all] Error 2"
- Assistant
The errors you're encountering are related to missing C++ standard library features that were introduced in later versions of C++. Specifically, the
clampfunction and thestd::filesystemlibrary were added in C++17. Since yourCMakeLists.txtsets the C++ standard to C++14, these features are not available.Steps to Fix the Errors
-
Update the C++ Standard: To use C++17 features, you should update your CMakeLists to set the C++ standard to C++17:
cmakeset(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
- User
wh i user cmake .. this show and make not working "cmake ..
-- Building for: Ninja -- The C compiler identification is GNU 14.2.0 -- The CXX compiler identification is GNU 14.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/msys64/mingw64/bin/cc.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:/msys64/mingw64/bin/c++.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done (1.6s) -- Generating done (0.0s) -- Build files have been written to: C:/Users/ali/Desktop/yoloCPPWin/build" - Assistant
It seems like your CMake configuration step completed successfully, as indicated by the messages "Configuring done" and "Generating done". At this point, build files have been generated and are ready to be used to compile the application.
The important detail here is that CMake detected
Ninjaas your build tool, which means that you should useninjainstead ofmaketo build your project. Here's how you can proceed:-
Navigate to your build directory and run the command:
-