简体   繁体   中英

Edit C++ project in VSCode and OpenCV without installing the whole library

I am working in a C++ project with OpenCV in Windows and VSCode. The project is meant to be built and run in a Docker Container, thus I do not need OpenCV in Windows. If needed, I use OpenCV as installed in WSL.

VSCode complains all the time in #include <opencv2/opencv.hpp> about not being able to find the library, and consequently it refuses to look for errors along the rest of the file.

I do not need OpenCV and I know that the compiling process can become tedious over Windows, so I would like VSCode to ignore this error and go on checking the rest of the files. Having IntelliSense working with OpenCV classes would be ideal.

Is there some way to have this without installing OpenCV in Windows?

This sounds like a good use case for VS Code Dev Containers . Dev containers let you use a docker file to define an isolated linux based development environment—including which tools and libraries are installed—in a reproducible way that does not effect your local machine.

Check out the Dev Container docs and the example c++ dev container for help getting started. If you already have an OpenCV docker image, you can use this as the base for your dev cotntainer

If you are using VSCode on Windows and would like it to OpenCV that is in WSL, you will need to install an extension on VSCode called Remote - WSL , developed by Microsoft.

You'll be able to use Linux specific toolchains, utilities and even run Linux-based applications directly from VSCode on Windows..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM