【问题标题】:Trying to port windows build system to linux试图将 windows 构建系统移植到 linux
【发布时间】:2020-09-01 18:10:43
【问题描述】:

此构建系统用于在 c++ 中对 3 列视图中的 sublime 文本进行竞争性编码

{
"cmd": ["g++.exe","-std=c++17", "${file}", "-o", "${file_base_name}.exe", "&&" , "./${file_base_name}.exe<inputf.in>outputf.in"],
"shell":true,
"working_dir":"$file_path",
"selector":"source.cpp"
}

为移植所做的修改

{
"cmd": ["g++","-std=c++17", "${file}", "-o", "${file_base_name}", "&&" , "./${file_base_name}<inputf.in>outputf.in"],
"shell":true,
"working_dir":"$file_path",
"selector":"source.cpp"
}

错误

g++: fatal error: no input files
compilation terminated.
[Finished in 0.0s with exit code 1]
[cmd: ['g++', '-std=c++17', '/home/xxx/Documents/CP/file.cpp', '-o', 'file', '&&', './file<inputf.in>outputf.in']]
[dir: /home/xxx/Documents/CP]
[path: /usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl]


为端口 v2 所做的修改


{ 
"cmd": ["g++ -std=c++17 ${file} -o ${file_base_name}"," && ", "./${file_base_name}<inputf.in>outputf.in"],
"shell":true,
"working_dir":"$file_path",
}

使用新的 v2 构建系统解决了无输入文件问题并编译了文件,但 outputf.in 文件中仍然没有输出

只使用终端中的命令

g++ -std=c++17 file.cpp -o file &amp;&amp; ./file&lt;inputf.in&gt;outputf.in

在 outputf.in 文件中产生输出

【问题讨论】:

  • 文件/home/xxx/Documents/CP/file.cpp 似乎不存在。
  • 它确实首先检查了该问题
  • 您是否打开了命令行并验证该命令在那里工作?
  • g++ -std=c++17 file.cpp -o file.o./file.o &lt;inputf.in&gt;outputf.in 工作正常
  • 到底为什么你的最终可执行文件会被赋予.o 扩展名?该扩展名应保留给它们默认拥有的中间对象文件。

标签: c++ linux sublimetext3 build-system sublime-build


【解决方案1】:
"cmd": ["g++ -std=c++17 ${file} -o ${file_base_name} && ./${file_base_name}<inputf.in>outputf.in"]

这个构建命令似乎对我有用,它对我来说工作得很好,我不知道为什么以及如何工作,但确实如此。

这个构建文件的灵感来自于博客文章

https://blog.codingblocks.com/2019/setting-up-a-c-competitive-programming-environment/

【讨论】:

    猜你喜欢
    • 2010-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多