Skip to content

Instantly share code, notes, and snippets.

@kinchungwong
Last active April 7, 2022 16:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinchungwong/adf613f0c5544e125085644b8e8125b4 to your computer and use it in GitHub Desktop.
Save kinchungwong/adf613f0c5544e125085644b8e8125b4 to your computer and use it in GitHub Desktop.
Using VSCode to browse OpenCV code on Ubuntu

Using VSCode to browse OpenCV code on Ubuntu

Audience: beginners

This guide is mainly written for my own reference. There may be mistakes. It is written so that I can start from scratch (e.g. get a computer, get internet access, install Ubuntu, etc). This guide does assume a bit of Linux familiarity, which most university students already have.

Getting started (step-by-step for first time)

Install CMake

Install VSCode

Install VSCode Extensions

  • YES: C/C++ extension by Microsoft
  • YES: CMake extension
  • YES: CMake Tools extension
  • NO: CMake Tools Helper extension
    • This extension has been found to clobber "c_cpp_properties.json", causing loss of all settings

Git clone OpenCV from github

Launch VSCode and open to OpenCV folder

Keystrokes to change VSCode C++ extensions settings

  • Ctrl-Shift-P, then type "C/CPP", then choose "Select Configurations"
    • Choose Linux
  • Ctrl-Shift-P, then type "C/CPP", then choose "Edit Configurations"
    • Find the section corresponding to Linux
    • Add the following to "includePath"
    • (This list has been updated to include information from microsoft/vscode-cpptools#1041 )
                "/usr/include/c++/5",
                "/usr/include/x86_64-linux-gnu/c++/5",
                "/usr/include/c++/5/backward",
                "/usr/lib/gcc/x86_64-linux-gnu/5/include",
                "/usr/local/include",
                "/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
                "/usr/include/x86_64-linux-gnu",
                "/usr/include",
                "${workspaceRoot}",
                "${workspaceRoot}/modules/core/include",
                "${workspaceRoot}/modules/imgproc/include",
                "${workspaceRoot}/include",
                "${workspaceRoot}/build",
                "${workspaceRoot}/build/3rdparty/ippicv",
                "${workspaceRoot}/build/3rdparty/ippicv/ippicv_lnx/include",
                "${workspaceRoot}/build/3rdparty/ippicv/ippiw_lnx/include",
                "${workspaceRoot}/build/3rdparty/ippiw",
                "${workspaceRoot}/build/modules/core",
                "${workspaceRoot}/build/modules/imgproc"

References

Recommended "read me first"

https://www.codeproject.com/Articles/1184735/Quick-Start-to-Use-Visual-Studio-Code-for-Cplusplu

https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/FAQ.md

Other references

https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/Getting%20started%20with%20IntelliSense%20configuration.md

https://stackoverflow.com/questions/41843794/visual-studio-code-with-opencv-libraries/42088436

https://code.visualstudio.com/docs/editor/multi-root-workspaces

https://github.com/vector-of-bool/vscode-cmake-tools

https://vector-of-bool.github.io/docs/vscode-cmake-tools/getting_started.html#configuring-your-project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment