[英]How to compile and execute C program on Visual Studio 2012 for Windows 8?
[英]Compile and execute C program in Python using Windows
我需要通过 Python 迭代地编辑、重新编译和运行名为sum_subgiants.c
的 C 程序(在 Windows 上使用 Spyder)。 我正在使用以前在我同事的 Mac 上工作过的 python 代码。 我是 python 的新手,对 C 没有经验。
有一个makefile
和所有相关文件存储在与sum_subgiants.c
相同的文件夹中。 我努力了
subprocess.run('make sum_subgiants', shell=True)
编译然后
subprocess.call('sum_subgiants', stdin=input_file, stdout=output_fh, shell=True)
这些命令似乎没有做任何事情。 任何我能理解的帮助将不胜感激。
我注意到 Windows 上没有make
命令,这解释了错误。 是否有可以在 Windows 上运行的替代命令?
在我整理好make
之后,我是否应该期望subprocess.call
能够轻松运行?
由于您在 Windows 上,所以一切都很困难。
make
。makefile
中的操作,您可能还需要安装其他工具。您可以考虑安装 MSYS2 和 MinGW,它们为 Windows 提供类 Unix 环境。
但我会质疑整个过程:为什么需要在运行时动态构建 C 程序? 这将非常复杂,因此寻找替代解决方案可能更可取。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.