Created
September 3, 2018 23:31
-
-
Save gavincangan/bb98579e7e88d31cf4849a641406e5d2 to your computer and use it in GitHub Desktop.
Build and run a C++ file using g++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cpp_file_to_build=$1 | |
output_file=$(pwd)/${cpp_file_to_build/\.cpp/\.o} | |
rename_output_file=$(pwd)/zz_${cpp_file_to_build/\.cpp/\.o}ld | |
mv $output_file $rename_output_file | |
g++ -std=gnu++11 -Wall $cpp_file_to_build -o $output_file; | |
if [ -f $output_file ]; then | |
$output_file | |
else | |
echo Output binary not found! Build must have failed! | |
fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment