前提・実現したいこと
C++のソースコードをmakeするところでエラーメッセージが出てしまい,解決方法が分かりません.
発生している問題・エラーメッセージ
saino@DESKTOP-KR80A41:/mnt/d/study_data/libPySeek/example/build$ make [ 50%] Building CXX object CMakeFiles/seek_test_pro.dir/seek_test_pro.o /mnt/d/study_data/libPySeek/example/seek_test_pro.cpp:5:10: fatal error: opencv2/highgui/highgui.hpp: No such file or directory #include <opencv2/highgui/highgui.hpp> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. CMakeFiles/seek_test_pro.dir/build.make:62: recipe for target 'CMakeFiles/seek_test_pro.dir/seek_test_pro.o' failed make[2]: *** [CMakeFiles/seek_test_pro.dir/seek_test_pro.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/seek_test_pro.dir/all' failed make[1]: *** [CMakeFiles/seek_test_pro.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2
該当のソースコード
/* * Test program SEEK Thermal CompactPRO * Author: Maarten Vandersteegen */ #include <opencv2/highgui/highgui.hpp> #include <thSeekThermalPro.h> #include <iostream> int main() { // Instant object thSeekThermalPro pro; // Init camre if (!pro.seekInit()) { std::cout << "failed to open seek cam" << std::endl; return -1; } else{std::cout << "seek cam init done" << std::endl;} // Get frame while(1) { // Get Gray frame if(pro.seekRead()){ cv::imshow("LWIR",pro.seekGetGrayCvFrame() ); } if( cv::waitKey(10) == 27 ) break; // stop capturing by pressing ESC } } //int main(int argc, char** argv) //{ // LibSeek::SeekThermalPro seek(argc == 2 ? argv[1] : ""); // std::cout<< "argv: "<<argv[1]<<std::endl; // cv::Mat frame, grey_frame; // // if (!seek.open()) { // std::cout << "failed to open seek cam" << std::endl; // return -1; // } // // while(1) { // if (!seek.read(frame)) { // std::cout << "no more LWIR img" << std::endl; // return -1; // } // // cv::normalize(frame, grey_frame, 0, 65535, cv::NORM_MINMAX); // //cv::GaussianBlur(grey_frame, grey_frame, cv::Size(7,7), 0); // // cv::imshow("LWIR", grey_frame); // // char c = cv::waitKey(10); // if (c == 's') { // cv::waitKey(0); // } // } //}
試したこと
インクルードパスの設定が正しくできていないと思い,フォルダ"libPySeek"上に".vscode/c_cpp_properties.json",".vscode/tasks.json"を作成し,以下のように編集しました.またopencv2/highgui/highgui.hppは,フォルダ"C:/opencv/build/include"内にあることを確認しました.
c_cpp_properties.json↓
{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**", "C:/opencv/build/include/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "windowsSdkVersion": "10.0.19041.0", "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe", "cStandard": "c17", "cppStandard": "c++17", "intelliSenseMode": "windows-msvc-x64" } ], "version": 4 }
tasks.json↓
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "echo", "type": "shell", "command": "echo Hello", "args": [ "-I", "C:/opencv/build/include/**" ] } ] }
akiruno-oneoneからの回答で,
cmakeで作成したCMakeLists.txt,こちらを変更した方がよいということでしたので,
以下にCmakeLists.txtの内容を表記しておきます.
message (STATUS "OpenCV_INCLUDE_DIRS: ${OpenCV_INCLUDE_DIRS}") message (STATUS "OpenCV_LIBRARIES: ${OpenCV_LIBRARIES}") ## Include directory (header file,.....) include_directories ( ${libPySeek_SOURCE_DIR}/src ${OpenCV_INCLUDE_DIRS} /usr/include/libusb-1.0 ) ## Link libraries link_libraries ( thSeekThermalPro_static #-lboost_program_options ${OpenCV_LIBRARIES} -lusb-1.0 ) ## Target compile file add_executable (seek_test_pro seek_test_pro.cpp) #install (TARGETS # seek_test # seek_test_pro # seek_viewer # seek_create_flat_field # DESTINATION "bin" #)
ソースコードのinclude<opencv2/highgui/highgui.hpp>の箇所をフルパスにした場合の実行結果です(ほぼ同様のエラーとなっています)
saino@DESKTOP-KR80A41:/mnt/d/study_data/libPySeek/example/build$ make Scanning dependencies of target seek_test_pro [ 50%] Building CXX object CMakeFiles/seek_test_pro.dir/seek_test_pro.o /mnt/d/study_data/libPySeek/example/seek_test_pro.cpp:5:10: fatal error: C:/opencv/build/include/opencv2/highgui/highgui.hpp: No such file or directory #include <C:/opencv/build/include/opencv2/highgui/highgui.hpp> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. CMakeFiles/seek_test_pro.dir/build.make:62: recipe for target 'CMakeFiles/seek_test_pro.dir/seek_test_pro.o' failed make[2]: *** [CMakeFiles/seek_test_pro.dir/seek_test_pro.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/seek_test_pro.dir/all' failed make[1]: *** [CMakeFiles/seek_test_pro.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2
補足情報(FW/ツールのバージョンなど)
OSはWindows10です.VScodeで編集しています.
gccのバージョンは以下のように出力されました.
saino@DESKTOP-KR80A41:/mnt/d/study_data/libPySeek/example/build$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
回答2件
あなたの回答
tips
プレビュー