gcc - 从 TCL 执行 cpp/exe
问题描述
我会从 TCL 调用 call_c_code cpp/exe。我尝试了以下代码:
#!/usr/bin/tclsh
set scripts_path call_c_code.exe
exec gcc -c $scripts_path >@stdout 2>@stderr
但我有以下错误:
% source "tcl_to_call_C.tcl"
gcc.exe: warning: call_c_code.exe: linker input file unused because linking not done
call_c_code.exe 是一个基本的 HelloWorld:
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
}
这是从 TCL 调用“.exe”的正确方法吗?
解决方案
正在做
set scripts_path call_c_code.exe exec gcc -c $scripts_path >@stdout 2>@stderr
你做
gcc -c call_c_code.exe
哪个不对,需要指明源文件编译
所以可能是这样的
gcc -c call_c_code.c
然后
set scripts_path call_c_code.c
exec gcc -c $scripts_path >@stdout 2>@stderr
但是使用-c
您只生成对象而不是可执行文件的选项,可能是您想要的
set scripts_path call_c_code.c
exec gcc $scripts_path >@stdout 2>@stderr
如果你真的想要扩展exe甚至在 Windows 之外添加选项-o
set scripts_path call_c_code
exec gcc -o $scripts_path.exe $scripts_path.c >@stdout 2>@stderr
无论如何隐藏编译器产生的可能消息不是一个好主意,最好删除重定向,相反添加选项-Wall
以要求编译器发出更多信号
推荐阅读
- vector - 如何根据 Vector 中某个项目的信息修改 Vector?
- javascript - 如何在反应中过滤复杂的对象
- java - 如何从 ActionListener 返回 Int?
- reactjs - 在 React Native 中垂直拉伸字体
- vue.js - 如何将 Vue 资产存储在谷歌云存储上?
- websphere - WebSphere App Server 在停止时超时(ADMU3060E:等待服务器关闭超时)
- swift - 通过 UIViewRepresentable 调整 SCNView 大小时的内存问题?
- go - 模拟系统调用错误
- reactjs - 如何在带有 Typescript 的 React 项目中组织类型定义
- python - 如何更有效地找到节点之间的边?