简体   繁体   English

C程序可执行文件帮助-Linux

[英]Help with C Program Executable - Linux

I just recently made the move to Linux, and now looking to program on it as well. 我最近才转向Linux,现在也希望对其进行编程。

However, for some reason I cannot get an executable to work. 但是,由于某种原因,我无法使可执行文件正常工作。

Here's what I've done: 这是我所做的:

  1. Downloaded Code::Blocks 下载代码::块
  2. Made a new Console Project in Workspace 1 with C source. 使用C源代码在Workspace 1中创建了一个新的Console项目。
  3. Added a getchar() before return(0); return(0);之前添加了getchar() return(0);
  4. Ran and Compiled - Which works perfectly INSIDE Code::Blocks Ran和编译-可以在内部代码:: Blocks中完美运行
  5. Went to the bin/release folder in which the file is saved, tried double clicking, right clicking and selecting: open, open with, tried using terminal to run the name of my program. 转到保存文件的bin / release文件夹,尝试双击,右键单击并选择:打开,打开方式,尝试使用终端运行我的程序的名称。 I copied the folder URL, and then name of the file.. I just can't seem to get the created file to execute! 我复制了文件夹URL,然后复制了文件名。。我似乎无法使创建的文件执行!

In windows it made a .exe, I know there is no ending (?) in linux. 在Windows中,它制作了一个.exe,我知道linux中没有结尾(?)。 (Could be wrong). (可能是错误的)。

I'm currently running Ubuntu 11.04. 我当前正在运行Ubuntu 11.04。

Most Linux distributions don't include the current directory in the PATH variable that determines where to search for executables. 大多数Linux发行版都没有在PATH变量中包含当前目录,该目录确定了在哪里搜索可执行文件。 Try opening a terminal, changing to the bin/release directory and explicitly qualifying your executable for the current directory: 尝试打开终端,切换到bin / release目录,并明确限定当前目录的可执行文件:

./myprogram

This is in contrast to Windows, where you can simply type "myprogram.exe". 这与Windows相反,在Windows中,您只需键入“ myprogram.exe”即可。

您可能需要授予程序权限才能作为可执行文件运行:

sudo chmod +x yourProgram

In the terminal emulator, go to (cd) the folder where the executable is created. 在终端仿真器中,转到(cd)创建可执行文件的文件夹。

Type ./programname 键入./programname

Where programname is the name of the executable file (./ tells the shell to look in the current directory for the program to run) 其中programname是可执行文件的名称(./告诉外壳程序在当前目录中查找要运行的程序)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM