语法错误:"("想不到 [英] Syntax error: "(" unexpected

查看:199
本文介绍了语法错误:"("想不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用gcc来编译code和运行可执行文件,但它引发的错误:

I am trying to compile code using gcc and run the executable, but it is throwing error:

gcc somefile.c -o somefile

编纂经过成功。但是,当我尝试执行它:

compilation goes through successfully. But, when I try to execute it:

$sh somefile

它导致:语法错误:(意外在输出文件,我没有看到somefile.o,而是,我看到somefile.c〜

It results in: Syntax error: "(" unexpected. Among the output files, I dont see somefile.o, but instead, I see somefile.c~

该文件的内容:

#include <stdio.h>
int main(int argc, char *argv[])
{
    printf("hi");
}

上下文:我是新来编程的Linux,并希望用简单的程序开始了。我在虚拟机上运行Ubuntu 64位,与海湾合作委员会,G ++等安装。从那以后,我创建了上面(somefile.c)作为提及的样本文件,并试图上述步骤,但无法执行。我的目标是编译和执行上使用gcc或g ++ Ubuntu的一个示例C或cpp code。请帮助。

Context: I am new to programming in linux, and wanted to start out with simple programs. I am running ubuntu 64 bit on a virtual machine, with gcc, g++, etc installed. After that I created a sample file as mentioned above ("somefile.c"), and tried the steps mentioned above, but could not execute. My goal is to compile and execute a sample C or Cpp code on ubuntu using gcc or g++. Please help.

推荐答案

somefile 是二进制可执行文件,这不是shell脚本。你应该执行它:

your somefile is executable binary, it's not shell script. you should execute it by:

$./somefile

这篇关于语法错误:&QUOT;(&QUOT;想不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆