c++ - 带有 Visual Studio Code 的 FLTK 库
问题描述
我正在尝试从编程原理和实践中安装第 12 章的 FLTK 库,但无法识别构建命令。我应该怎么办?谢谢!
PS D:\3. Programming\C++\GUI\fltk-1.3.5> make
make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ make
+ ~~~~
+ CategoryInfo : ObjectNotFound: (make:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
解决方案
我通常对 Makefile 感觉更舒服,所以我设置了 VS Code 以在我的项目中使用 Makefile。我在安装 FLTK 后完成了以下步骤。
我创建了一个目录,其中包含我所有的源文件、头文件等。假设我有一个
FLTK_ex
文件夹hello.cpp
及其Makefile
我打开 VS Code,然后
File->Open
选择文件夹FLTK_ex
从
Terminal
菜单中,我选择Configure Default Build Task...
:在出现的菜单中,我选择Create tasks.json file from template
然后Others
出现一个默认的json文件,我修改为
{ "version": "2.0.0", "tasks": [ { "label": "Build", "type": "shell", "command": "Make", "problemMatcher": [], "group": { "kind": "build", "isDefault": true } } ]
}
要编译,请转到
Terminal
菜单并选择Run Build Task...
要运行程序,请在
Run
菜单中选择Run without debugging
,C++
出现一个
launch.json
文件:修改为(myprogram
可执行文件名在哪里){ "version": "0.2.0", "configurations": [ { "name": "(lldb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/myprogram", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb" } ] }
为了有效地运行程序,在
Run
菜单中再次选择Run without debugging
。
我有 FLTK 1.3.5、macOS Catalina 10.15.5、clang 版本 11.0.3、VS Code 1.47。
为了在 VS Code 中使用 FLTK,我只是按照说明 (in Readme.OSX.txt
) 来简单地安装 FLTK 库,Windows 系统有一个类似的文件 ( README.MSWindows.txt
)。
编写Makefile
forFLTK
的指南在此处,如果您需要更多关于Makefile
s 的见解,您可以在此处找到完整指南或在此处找到更简短的介绍。
推荐阅读
- pytorch - 直接设置 Pytorch 模型变量和优化器参数应该考虑哪些因素?
- php - 商店路线不会将 POST 作为一种方法
- google-app-engine - 示例 Hello World 应用程序的 502 响应
- python - 循环遍历 Pandas 数据框中的列
- python - F 带特殊字符的字符串
- makefile - 在 makefile 中包含 ITK 头文件和链接库
- python - 结束这个 Python 循环的惯用方式是什么?
- c++ - 构造函数初始化列表和静态成员(私有与受保护)
- wordpress - WordPress Gutenberg 自定义块获取所有帖子
- python-3.x - 当调用表格遇到错误时:无法创建文件 C:\Users