虽然,我已经成功地安装了带有homebrew
的GSL库。
brew info gsl
==> gsl: stable 2.7.1 (bottled)
Numerical library for C and C++
https://www.gnu.org/software/gsl/
/opt/homebrew/Cellar/gsl/2.7.1 (290 files, 9.8MB) *
Poured from bottle on 2022-10-12 at 19:30:40
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/gsl.rb
License: GPL-3.0-or-later
==> Analytics
install: 3,814 (30 days), 10,911 (90 days), 50,876 (365 days)
install-on-request: 1,590 (30 days), 4,514 (90 days), 22,602 (365 days)
build-error: 0 (30 days)
现在我想在VSCode中运行这个简单的程序,以确保库按预期工作。我在c_cpp_properties.json
中添加了includePath
,但无法正确包含*.h
"我的剧本"
#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>
int
main (void)
{
double x = 5.0;
double y = gsl_sf_bessel_J0 (x);
printf ("J0(%g) = %.18e\n", x, y);
return 0;
}
- c_cpp_属性. json**
"configurations": [
{
"name": "Mac",
"includePath": [
"/opt/homebrew/Cellar/gsl/2.7.1/include"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64"
}
],
"version": 4
}
- 任务. json**
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang build active file",
"command": "/usr/bin/gcc",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
- 启动. json**
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}
我收到错误消息fatal error: 'gsl/gsl_sf_bessel.h' file not found
1条答案
按热度按时间wh6knrhe1#
我设法用以下命令从命令行编译它:
此外,在VSCode中,必须相应地修改task.json以将库链接到include路径。
编辑:c_cpp_properties. json实际上并不相关。task. json的参数很重要。