The property includePath
, referenced in your question, resides in the file c_cpp_properties.json
, primarily utilized by the Microsoft C/C++ extension to configure IntelliSense, which provides functionalities such as code completion, syntax highlighting, etc. It's important to note that in VSCode, this is decoupled from compiling and linking, which are typically handled in tasks.json
. For instance, includePath
does not affect the behavior of the compiler called in tasks.json
. Instead, one must manually pass command-line arguments to the compiler within the args
section of tasks.json
. The same applies to libraries. There is no property like libraryPath
in c_cpp_properties.json
because IntelliSense typically does not require that kind of information to perform its tasks.
For a specific example, consider compiling a single-file C++ program dependent on a library named foo
, residing in /usr/lib
(one of the standard directories). In this scenario, appending -lfoo
(-l<library>
) to the args
in the auto-generated tasks.json
suffices:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/sbin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-lfoo" // <- Instruct GCC to search libfoo.a or libfoo.so
],
// Other auto-generated fields omitted
}
],
"version": "2.0.0"
}
In cases where libraries are not located in standard search directories, the option -L<dir>
can be used to specify additional search directories. Often, the above process is considered verbose and error-prone, especially for larger projects, and a build system such as CMake is a better choice.
<AdditionalLibraryDirectories>$(ProjectDir)\3rdParty\WpdPack\Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
– Hassi