创建一个bash脚本来编译c ++ [英] Creating a bash script to compile a c++

查看:131
本文介绍了创建一个bash脚本来编译c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,我在c ++中输出一些模拟结果到.csv excel文件。

I have a program I've written in c++ which outputs some simulation results to a .csv excel file.

根据一些说明,我需要创建一个简单的bash脚本,它将运行.cpp文件给定命令$ run_program($不是命令的一部分)。

According to some instructions I need to create a simple bash script that would run the .cpp file given the command "$ run_program" ($ is not a part of the command).

我看过Stackoverflow和其他网站但我没有找到一个具体的答案帮助我。我非常感谢,如果那些回答可以花一些时间来解释参数的意义。

I've looked on Stackoverflow and other sites however I have not found a concrete answer to help me. I would also greatly appreciate it if those who answer can take some time to explain what the parameters mean.

谢谢。

我应该如何制作bash脚本来运行一个C ++程序?

这是我看过的链接之一,但是我不能做出头部或尾部。

This is one of the links I've looked at, however I could not make heads or tails out of this.

推荐答案

我不知道你用来编译你的c ++程序的命令,但这可能会有帮助。

i dont know the command you are using to compile your c++ program but this might help you.


  1. 创建一个扩展名为.sh的文件,并用您喜欢的文本编辑器打开。

  1. Create a file with ".sh" extension and open it with your favorite text editor.
  2. Paste this code (change compiling line with line you are using to compile your progam)

#!/bin/bash
#Run this in terminal
#+ Command to compile c++ program. here i used common one
g++ filename.cpp -o anyname
exit 0


  • 现在您需要运行此脚本,为此打开一个终端

  • Now you need to run this script, To do this open a terminal

    chmod u + x scriptname.sh

    chmod u+x scriptname.sh

    然后通过 ./ scriptname.sh
    运行脚本希望这将编译您的程序。

    Then run the script by ./scriptname.sh Hopefully this will compile your program.

    这篇关于创建一个bash脚本来编译c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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