1. 程式人生 > >在ubuntu下用sublime text3編譯C++和pascal

在ubuntu下用sublime text3編譯C++和pascal

amp cto windows ase wall ubuntu class dir sca

編譯C++:

選擇Tools -> Build System -> New Build System,把下面代碼拷貝進去,保存,自己起個名字。

然後打開C++文件,選擇Tools -> Builid System ->你剛才保存的名字,按Ctrl + B就可以編譯了。

{
"cmd": ["g++", "-Wall", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}"], // For GCC On Windows and Linux
//"cmd": ["CL", "/Fo${file_base_name}", "/O2", "${file}"], // For CL on Windows Only
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",

"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ ‘${file}‘ -o ‘${file_path}/${file_base_name}‘ && ‘${file_path}/${file_base_name}‘"] // Linux Only
//"cmd": ["CMD", "/U", "/C", "g++ -std=c++11 ${file} -o ${file_base_name} && ${file_base_name}"] // For GCC On Windows Only
//"cmd": ["CMD", "/U", "/C", "CL /Fo${file_base_name} /O2 ${file} && ${file_base_name}"] // For CL On Windows Only
}
]
}

編譯pascal:

{
"cmd": ["fpc", "-wv", "-g", "${file}", "${file_path}/${file_base_name}"], // For GCC On Windows and Linux
//"cmd": ["CL", "/Fo${file_base_name}", "/O2", "${file}"], // For CL on Windows Only
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.pascal",

"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "fpc ‘${file}‘ ‘${file_path}/${file_base_name}‘ && ‘${file_path}/${file_base_name}‘"] // Linux Only
//"cmd": ["CMD", "/U", "/C", "g++ -std=c++11 ${file} -o ${file_base_name} && ${file_base_name}"] // For GCC On Windows Only
//"cmd": ["CMD", "/U", "/C", "CL /Fo${file_base_name} /O2 ${file} && ${file_base_name}"] // For CL On Windows Only
}
]
}

在ubuntu下用sublime text3編譯C++和pascal