vscode里面如何配置库

您所在的位置:网站首页 vscode创建动态链接库 vscode里面如何配置库

vscode里面如何配置库

2023-10-02 23:04| 来源: 网络整理| 查看: 265

配置VS code在C语言中调用gsl库文件

先确认gsl库,gcc都已正确安装,命令行

g++ -L/usr/local/lib hello.c -o hello -lgsl -lgslcblas -lm

没有错误则可以配置VS code

tasks.json要配置args字段

launch.json要配置environment字段

c_cpp_properties.json要配置includePath字段

tasks.json

{

"version": "2.0.0",

"tasks": [

{ "type": "shell",

"label": "C/C++: g++ build active file",

"command": "/usr/bin/g++",

"args": [

"-g",

"${file}",

"-L/usr/local/lib",

"-lgsl", "-lgslcblas", "-lm",

"-o",

"${fileDirname}/${fileBasenameNoExtension}"

],

launch.json

"cwd": "${workspaceFolder}",

"environment": [

{

"name": "LD_LIBRARY_PATH",

"value": "/usr/local/lib",

}

c_cpp_properties.json

"includePath": [

"${workspaceFolder}/**",

"/usr/include/gsl"

],

主文件hello.c编译链接成功

#include

#include

int main()

{

double x1 = 5.0;

double y1 = gsl_sf_bessel_J0(x1);

printf("J0(%g) = %.18e\n", x1, y1);

return 0;

}



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3