Search code examples
c++intellisensevisual-studio-2022

In VS 2022 (C++), how do I tell Intellisense where to find external library sources?


I tried the following:

Project Properties -> VC++ Directories -> Set "Source Directories" to:

$(VC_SourcePath);C:\Users\logix\Desktop\code_\libs\misc\cinder_0.9.2\src\cinder;$(SourcePath)

But still, when I F12 ("Go to definition") on a libcinder method called in my code, I get the relevant header, not the relevant libcinder cpp file.

ChatGPT advised me to include the entire libcinder source tree (via the "Add existing" menu option) into my project. But that would mean my .vcxproj file would be cluttered with several thousand additional files. I'd like to avoid that for the following reasons:

  • VS's speed and memory usage would probably be impacted quite a bit.
  • I'm pretty sure this scenario used to "just work" when I tried it about 10 years ago. So I feel like I'm missing some much cleaner/simpler solution here.

Some things I suspect may be preventing my approach from working:

  • C:\Users\logix\Desktop\code_\libs\misc\cinder_0.9.2\src\cinder contains just the cpp files of the library, not its headers
  • The cpp files are actually located in a structured filesystem tree - they're not in a single "flat" dir
  • Maybe I should specify the following path instead: C:\Users\logix\Desktop\code_\libs\misc\cinder_0.9.2\src\
  • Or maybe: C:\Users\logix\Desktop\code_\libs\misc\cinder_0.9.2\

...Though I did try those last 2 paths, to no avail.

I also tried deleting my project's .vs dir to make IntelliSense rebuild its database.


Solution

  • Found an (almost) perfect solution:

    I added the external library's .vcxproj project to my .sln solution. That's all! It did not involve adding files to my project, so I'm really happy with this.