Mac环境下VScode配置Eigen
做个记录帖子
做一下自己记录的帖子防止以后不记得怎么配置了
安装brew
brew的安装网上有很多帖子,不造轮子了
下载Eigen
下载安装Eigen
在terminal里输入:sudo brew install eigen
VScode配置Eigen
新建任何工程,按住shift+command+P
输入edit configuration
在c_cpp_properties.json里面找到一项目录includePath。
在includePath下填上Eigen的地址。
Eigen的地址
一般由brew直接安装的包都放在/usr/local/Cellar/
但是由于直接在.json里这样写并不能读取到Eigen的头文件
所以我们要把地址完善。
使用如下地址/usr/local/Cellar/eigen/3.3.8_1/include
c_cpp_properties.json
c_cpp_properties.json
的代码如下
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/Cellar/eigen/3.3.8_1/include"
],
"defines": [],
"macFrameworkPath": [],
"compilerPath": "/usr/local/bin/gcc-10",
"cStandard": "gnu17",
"intelliSenseMode": "macos-gcc-x64",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
运行结果
后记
我发现这样以后重启又会出现红色波浪线,但是编译和运行都是没有问题的,所以又看了一下地址。
sudo ln -s /usr/local/Cellar/eigen/3.3.8_1/include/eigen3/Eigen /usr/local/include/Eigen
其中eigen/3.3.8_1可能因为不同版本而改变,自己改改就好
版权声明:本文为weixin_39977764原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。