问题
I have a program I've written in c++ which outputs some simulation results to a .csv excel file.
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).
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.
Thank you.
How I should make a bash script to run a C++ program?
This is one of the links I've looked at, however I could not make heads or tails out of this.
回答1:
i dont know the command you are using to compile your c++ program but this might help you.
- Create a file with ".sh" extension and open it with your favorite text editor.
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 0Now you need to run this script, To do this open a terminal
chmod u+x scriptname.sh
Then run the script by ./scriptname.sh
Hopefully this will compile your program.
回答2:
It sounds like a Makefile is what you are looking for here. Definitely worth getting a handle on if you deal with programming.
来源:https://stackoverflow.com/questions/29090372/creating-a-bash-script-to-compile-a-c