通过Sublime Text编译C ++并在Mac Terminal中运行

时间:2018-11-24 14:47:29

标签: c++ macos terminal sublimetext3

我正在使用Sublime Text 3及其集成的构建系统来编译C ++程序。我设法编写了一个编译系统来编译整个项目(目录中的所有.cpp文件),然后在Mac Terminal中运行,但是问题是Terminal的工作目录不是当前文件夹,因此我无法使用C ++程序中的相对路径(例如)。有办法解决这个问题吗?

{
    "shell_cmd": "g++ -std=c++14 ${file_path}/*.cpp -o '${file_path}/${file_base_name}'",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c++, source.cpp, source.cc, source.cxx",

    "variants":
    [
        {
            "name": "Run in Terminal",
            "shell_cmd": "g++ -std=c++14 ${file_path}/*.cpp -o '${file_path}/${file_base_name}' &&  open -a Terminal ./'${file_base_name}'",
            "shell": true,
        },
    ]
}

0 个答案:

没有答案