启动C++程序时出现问题

Trouble starting C++ Program

本文关键字:问题 C++ 程序 启动      更新时间:2023-10-16

我有一个C++-Makefile项目,我构建并链接了它,一切都很顺利。

-- Configuring done
-- Generating done
-- Build files have been written to: /folder/build/

首先,我使用bash用cmake配置项目,然后我在eclipse中将该项目加载为"现有的makefileproject"并构建它。构建也很顺利,但在尝试运行该程序时,我得到了一个错误:

Error starting process.
Exec_tty error:Cannot run program "/folder/build/programname": Unknown reason
Exec_tty error:Cannot run program "/folder/build/programname": Unknown reason
Exec_tty error:Cannot run program "/folder/build/programname": Unknown reason

我也试着从bash运行该项目,但最终得到的错误消息是:

If 'programname' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf programname

我使用ls -l programname来获取有关该文件的信息。

-rw-r--r-- 1 username users 6411620 Apr 27 13:54 programname

当我尝试用改变读写方式时

chmod 777 programname

什么也没发生,程序名信息保持不变。

我的项目建设出了什么问题?

以下是一些尝试:

  • 尝试一个简单的程序(例如helloworld)来确保您的环境设置正确。如果你做helloworld,一定要放一个sleep(5);语句或类似的东西,这样它就会在屏幕上停留足够长的时间来观看它
  • 尝试在Eclipse中构建程序,并让它为您生成make文件
  • 请确保您的权限设置正确(这是您使用chmod时所做的),但请执行其他ls-l操作以确保您对权限的更改有效。我建议chmod 760 programname更加符合安全策略
  • 要在Linux中运行程序,可以cd到包含该程序的目录,然后键入./programname

希望其中一个对你有用!