我正在尝试使用gcc编译代码并运行可执行文件,但它抛出错误:
gcc somefile.c -o somefile
Run Code Online (Sandbox Code Playgroud)
编译顺利完成.但是,当我尝试执行它时:
$sh somefile
Run Code Online (Sandbox Code Playgroud)
它导致:语法错误:"("意外.在输出文件中,我没有看到somefile.o,但相反,我看到somefile.c~
文件内容:
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("hi");
}
Run Code Online (Sandbox Code Playgroud)
上下文:我是linux新手编程的新手,想从简单的程序开始.我在虚拟机上运行ubuntu 64位,安装了gcc,g ++等.之后我创建了一个如上所述的示例文件("somefile.c"),并尝试了上面提到的步骤,但无法执行.我的目标是使用gcc或g ++在ubuntu上编译和执行示例C或Cpp代码.请帮忙.