我有OS X Mojave
。
我正在尝试vcpkg,即使我安装了muParser
,并且它存在于Macintosh HD ▸ Users ▸ dchambers ▸ vcpkg ▸ installed ▸ x64-osx ▸ include
上,我在#include "muParser.h"
上也没有出现红色下划线,但在刻意的错字上不要这样做例如#include "muParserX.h"
,我得到了错误:
test.cpp:2:10: fatal error: 'muParser.h' file not found
include "muParser.h"
...当我尝试构建时。
作为测试,我在“正常”路径中包含了标头#include "gmp.h"
:/usr/local/Cellar/gmp/6.1.2_2/include/gmp.h
(实际上是usr/local/include
的别名),一切都很好。
这是我的Visual Studio Code
设置和文件:
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
}
}
]
}
有什么想法吗?
更新:
这是Visual Studio Code
的问题,如here所述。
在命令行中,以下命令可以正常工作,告诉命令库在哪里:
g++ -I ~/vcpkg/installed/x64-osx/include/ test.cpp
。感谢roschuma的回答。
答案 0 :(得分:0)
这是在VSCode中运行的智能感知引擎(为花粉供电)与您实际的编译命令行(为编译错误提供动力)之间的差异:)
具体来说,您需要在第二个文件的g ++参数列表中添加"-I${vcpkgRoot}/x64-osx/include"
。