VS Code and Visual Studio C++ IntelliSense may be unable to pick up libraries, especially when working on a large project. We saw the error message “cannot open source file ‘string.h'” (dependency of “wx/wx.h”) when hovering over #include <wx/wx.h> and sometimes, the auto-complete feature fails to respond. In this post, we will see what you can do if VSCode and VS C++ IntelliSense are not working or not picking up libraries.
Why is my IntelliSense not working in C++?
Sometimes, when working with large file sizes, IntelliSense fails to respond in Visual Studio. In that case, we are required to recreate the database. That will refresh the text editor’s database and get your project back on track. We have mentioned instructions to do the same hereinafter.
Fix VSCode and VS C++ IntelliSense not working or picking up libraries
If VSCode and VS C++ IntelliSense are not working or picking up libraries, follow the below solutions to resolve the issue.
- Install the complete C++ extension
- Recreate the database
- Reinstall C/C++
- Install CMake extension in Visual Studio
- Reinstall Visual Studio or VSCode
Let us talk about them in detail.
1] Install the complete C++ extension
Even though it’s not essential to install a C++ extension, if you are facing this issue, we recommend you go ahead and install it. It will install all the required tools lack of which can cause the trouble in question. To install the extension, open Visual Studio Code, go to the Extensions section, enter “C/C++ Extension Package”, and click on the associated Install button. Hopefully, this will do the trick for you.
2] Recreate the database
I have observed that the auto-complete feature in Visual Studio stops functioning properly once the project grows to a certain size, usually around 4,100 lines of code. Jot just that, performance tends to decline as the number of third-party libraries increases, causing namespaces, class attributes, and methods to become invisible. To get things back on track, we are required to recreate the database. Follow the steps mentioned below to do the same.
- Open Tools.
- Go to Options and search for “database”.
- Next up, go to Text Editor > C/C++ > Advanced.
- Finally, set Recreate Database = TRUE.
You can now check if the issue is resolved.
Read: IntelliSense not working in VS Code
3] Reinstall C/C++
Maybe when installing C/C++ you have made some mistakes due to which Intellisense is unable to pick up libraries. In that case, we are supposed to uninstall C/C++ from the device and then install a fresh copy of the same the right way.
4] Install CMake extension in Visual Studio
CMake is an open-source tool for build automation, testing, packaging, and software installation. It generates build scripts for multiple platforms, including Windows, macOS, and Linux. Its flexibility helps developers build projects faster. It is an alternative that you can use in your project if Intellisense is not picking up libraries. To it easier for you, there is a CMake extension that you can install easily.
Follow the steps mentioned below to do the same.
- Open Visual Studio Installer.
- Go to the installed instance of Visual Studio and click on Modify.
- From Workloads, go to Desktop development with C++, under Desktop & Mobile.
- Ensure you select the Linux and embedded development with C++ component on this page to have cross-platform CMake development capabilities.
- Click on Modify to confirm your actions.
Hopefully, this will do the trick for you.
Read: Fix Microsoft Visual Studio Location Simulator Sensor not working
5] Reinstall Visual Studio or VS Code
If all else fails, your last resort is to uninstall Visual Studio or VS Code IDE from your computer and install a fresh version of the same. This will remove corrupted files, if there are any, and replace them with fresh ones. You need to ensure that you include every single library they ask you to install in the package.
Hopefully, you can resolve the issue using the solutions mentioned earlier.
Read: Visual Studio, The system cannot find the file specified
How do you enable IntelliSense in VS Code?
You can activate IntelliSense in any editor window by typing Ctrl+Space or a trigger character, such as a dot in JavaScript. IntelliSense is available in Visual Studio Code for JavaScript, TypeScript, JSON, HTML, CSS, SCSS, and Less by default. While word-based completions are supported for all programming languages, installing a language extension can provide even richer IntelliSense.
Also Read: Best C++ Extensions for Visual Studio Code.