I have OS X Mojave
.
I'm trying out vcpkg and even though I installed muParser
and it exists at Macintosh HD ▸ Users ▸ dchambers ▸ vcpkg ▸ installed ▸ x64-osx ▸ include
AND I get no red underlining on #include "muParser.h"
but DO on a deliberate typo such as #include "muParserX.h"
I get the error:
test.cpp:2:10: fatal error: 'muParser.h' file not found
include "muParser.h"
...when I try to build.
As a test, I included a header #include "gmp.h"
from the 'normal' path: /usr/local/Cellar/gmp/6.1.2_2/include/gmp.h
(actually an alias from usr/local/include
) and all is fine for that.
Here's my Visual Studio Code
setup and the file:
test.cpp:
#include <iostream>
#include "muParser.h"
#include "gmp.h"
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}
c_cpp_properties.json:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"${vcpkgRoot}/x64-osx/include"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "g++",
"args": [
"test.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Any ideas?
UPDATE:
This is a problem with Visual Studio Code
, described here.
From the command line, the following works fine, telling the command where the libs are:
g++ -I ~/vcpkg/installed/x64-osx/include/ test.cpp
. Thanks to roschuma for his answer.
This is a discrepancy between the intellisense engine running in VSCode (which powers the squiggles) and your actual compilation command line (which powers the compile errors) :)
Specifically, you'll need to add
"-I${vcpkgRoot}/x64-osx/include"
to the list of g++ arguments in the second file.