by TheeMahn » Mon Oct 27, 2008 4:12 pm
Theo9909 wrote:I'm trying to compile a program in terminal. I have a script that has worked for ten years and I can't get it to work in 1.9 here is the script code
#!/bin/bash
#
echo "...Compiling C++ Program "$1"..."
g++ -Wall -time -Wno-deprecated -o object $1
rc=$?
echo "...Compilation for $0 Completed with RC=$?..."
if [ $rc -eq 0 ]; then
cp object $1.object
fi
exit 0
there are twelve lines of code here. Yet it gives me this error:
porsche@porsche-laptop:~$ bash cplus newfile.cc
...Compiling C++ Program newfile.cc...
: command not found
: No such file or directory
g++: no input files
...Compilation for cplus Completed with RC=0...
cplus: line 13: syntax error: unexpected end of file
the code source is in my homefolder, yet nothing works. any help would be great! Thanks!!!
First I would make sure "build essential" is installed:
- Code: Select all
sudo apt-get install build-essential
I have taken your script and droped it on my desktop as follows:
- Code: Select all
theemahn@SledgeHammer:~/Desktop$ cat test.sh
#!/bin/bash
#
echo "...Compiling C++ Program "$1"..."
g++ -Wall -time -Wno-deprecated -o object $1
rc=$?
echo "...Compilation for $0 Completed with RC=$?..."
if [ $rc -eq 0 ]; then
cp object $1.object
fi
#exit 0 unnecessary
theemahn@SledgeHammer:~/Desktop$
Wrote a simple c++ program:
- Code: Select all
theemahn@SledgeHammer:~/Desktop$ cat test.cpp
// my first program in C++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
theemahn@SledgeHammer:~/Desktop$
and compiled it:
- Code: Select all
theemahn@SledgeHammer:~/Desktop$ ./test.sh test.cpp
...Compiling C++ Program test.cpp...
# cc1plus 0.16 0.01
# as 0.00 0.00
# collect2 0.05 0.00
...Compilation for ./test.sh Completed with RC=0...
theemahn@SledgeHammer:~/Desktop$
Home of Ultimate Edition. Got a question? Please review the
F.A.Q. Browse the
How to section.
Main O/S: Builder of O/S Guess.
Mainboard: ASUS Hero VI (AM4)
CPU: AMD 1700X water cooled (Deepcool Captain Genome Cooling tower)
Ram: 16 GB GSkill Trident RGB Series Dual Channel DDR4 3200
Video: MSI RX470 8GB Gaming card.
Hard Disks: MASSIVE on the network.(10 Gigabit, 48 port, multiple servers)
Monitors: Dual 4K 43" LG, 4K Samsung 28"
750 Watt modular PSU (Rosswell)
1100 Watt Amp & 4 X 600 Watt speakers
Servers in the basement.