Are you a spammer

Please note, that the first 3 posts you make, will need to be approved by a forum Administrator or Moderator before they are publicly viewable.
Each application to join this forum is checked at the Stop Forum Spam website. If the email or IP address appears there when checked, you will not be allowed to join this forum.
If you get past this check and post spam on this forum, your posts will be immediately deleted and your account inactivated.You will then be banned and your IP will be submitted to your ISP, notifying them of your spamming. So your spam links will only be seen for an hour or two at most. In other words, don't waste your time and ours.

This forum is for the use and enjoyment of the members and visitors looking to learn about and share information regarding the topics listed. It is not a free-for-all advertising venue. Your time would be better spent pursuing legitimate avenues of promoting your websites.

Programming problems!!!

Source code I have written openly published for your viewing pleasure.


Programming problems!!!

Postby Theo9909 » Thu Oct 16, 2008 8:59 pm

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!!!
Theo9909
U.E. Newbie
U.E. Newbie
 
Posts: 22
Joined: Sat Mar 01, 2008 1:07 am
Operating System: Ultimate Edition 3.2 32 BIT



Re: Programming problems!!!

Postby tuxsax » Fri Oct 24, 2008 12:20 pm

I don't know squat about C programming, but once I had a similar problem with a script, I think it was in perl or bash, can't remember, anyway, what solved me the problem was actually removing the last empty line, if your 12 lines of codes end at "exit 0" then let it be the last line, don't leave a blank line after it.

Ziv
______________________________
Two things I love: Linux and my sax
tuxsax
U.E. Master
U.E. Master
 
Posts: 790
Joined: Sat Apr 26, 2008 4:15 am
Age: 53
Operating System: Ultimate Edition Beta Tester



Re: Programming problems!!!

Postby red_team316 » Fri Oct 24, 2008 7:27 pm

I also have had an odd problem once with newlines at the end of a file, can't say it was C based though...

Are you sure g++ is installed and/or cpp? It may be a simple question but the first line that appears to be going wrong is that it cannot find g++. Other than that, g++ will report "g++: no input files" if your path is incorrect or missing. Try using full paths, it's possible that you are trying to use a relative path and just not working right.

***Moved topic to programming***
Core i7 920(working on a decent OC), x58 ASUS P6T Deluxe V2, 6GB DDR3 1600, EVGA 8800GTS512, Silencer 750W PSU, CoolerMaster V8, Red Antec900
Image
User avatar
red_team316
U.E. College Professor
U.E. College Professor
 
Posts: 288
Joined: Mon Jan 07, 2008 12:37 am
Age: 39
Operating System: Ultimate Edition 3.2 64 BIT



Re: Programming problems!!!

Postby 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.
User avatar
TheeMahn
Site Admin
 
Posts: 4201
Joined: Fri Oct 12, 2007 10:02 am
Location: U.S.A.
Age: 53
Operating System: Ultimate Edition Developer


Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests