LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-06-2002, 02:35 AM   #1
nautilus_1987
Member
 
Registered: Aug 2002
Distribution: Slackware 8.1
Posts: 750

Rep: Reputation: 30

Yes you are
To compile win10.cpp - gcc -o test win10.cpp
Then chmod 777 win10
To execute write : ./win10
I think you got it
 
Old 10-06-2002, 02:37 AM   #2
underdog
LQ Newbie
 
Registered: Oct 2002
Posts: 2

Rep: Reputation: 0
Red face problem running progs compiled with g++

My computer is having a problem running programs I compiled using g++. For example, I compiled a program called win10.cpp. It compiles fine, and the binary is called win10. When I type win10, the computer says:

bash: win10: command not found

I even compiled my program on another computer (via ssh). It ran fine, so I downloaded the compiled program to my computer. When I tried to run it on my computer, I got the same old error message.

Any ideas what I'm doing wrong?
 
Old 10-06-2002, 05:45 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you shouldn't normally need to use the chmod command. and of course in your example, you called the output file "test" so ./win10 will obviously not exist. and also gcc is primarily a c compiler, not c++, but that doesn't matter really.
 
Old 10-06-2002, 05:56 AM   #4
nautilus_1987
Member
 
Registered: Aug 2002
Distribution: Slackware 8.1
Posts: 750

Original Poster
Rep: Reputation: 30
Oh I am very sorry............
Ofcourse it should be ./test
thnx acid!!!
 
Old 10-06-2002, 06:20 AM   #5
adam_boz
Member
 
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538

Rep: Reputation: 30
do this (i don't know if this is all clear yet or not?)

g++ -o win10 win10.cpp
./win10

It should work o.k. (assuming that your code is correct ;-)

by the way... watch out with gcc 3.1.... There is a (at least one) bug in it with using the header <string.h> and the getline function from that
 
Old 10-06-2002, 08:23 AM   #6
jetblackz
Member
 
Registered: Mar 2002
Location: Debian Galaxy
Distribution: Debian
Posts: 711

Rep: Reputation: 30
"assuming that your code is correct" and if it isn't and you got it compiled, I'd like to ask how. ;-)

Or you mean logic errors.
 
Old 10-06-2002, 10:52 AM   #7
adam_boz
Member
 
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538

Rep: Reputation: 30
Can't you make "logic errors" and still get it to compile? It just seems to me (newbie) that the two terms mean the same thing.

what IS the difference?
 
Old 10-06-2002, 10:54 AM   #8
adam_boz
Member
 
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538

Rep: Reputation: 30
p.s. do you all see nautilus as the first message here?
 
Old 10-06-2002, 11:00 AM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
yes, it's been reported to jeremy.

a logic error is going to be something like

var = 3 * 4 * bignumber * 0;

or somethign equally stupid.
 
Old 10-06-2002, 12:34 PM   #10
jetblackz
Member
 
Registered: Mar 2002
Location: Debian Galaxy
Distribution: Debian
Posts: 711

Rep: Reputation: 30
Thanks.

A logic error is not a problem to the computer, like acid pointed out. But it IS a problem to the end user. For example, you want to calculate the average salary, instead you put in a code that does hourly rate. You get it compiled.

In short, a logic error is an unexpected result.

Design-time errors can't get past compilers.

And there are run-time errors. Like legal code, but it produces a number bigger than your variable can hold. Boom!
 
Old 10-06-2002, 02:01 PM   #11
underdog
LQ Newbie
 
Registered: Oct 2002
Posts: 2

Rep: Reputation: 0
Thumbs up

OK. Chmod didn't do anything because win10 was already -rwxrwxrwx. So I
tried ./win10 and it worked!!!! I am so happy. Thanks to everyone for your
help.

underdog

Oh, by the way. Does anyone know why this works? Is it possible to change
some settings so that I don't have to type ./ every time?
 
Old 10-06-2002, 02:16 PM   #12
adam_boz
Member
 
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538

Rep: Reputation: 30
"./" just means to stay in the current directory when looking for the executable. if you are not in the directory, and it is in, say... /home/adam/programs/ you would type"/home/adam/programs/win10" basically, a "." means current directory, and ".." means one directory up on the filesystem (hence cd ..)
If you don't want to do this, you can put the program somewhere in your $PATH. to see which directories these are, do

"echo $PATH"
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I make it so I don't have to type './$filename' run compiled C++ progs Nalorin Linux - Newbie 2 03-12-2005 11:12 PM
a linux program running windows progs..!,help cheater1034 Linux - Software 10 08-05-2004 11:34 PM
monitor goes black when running progs boris54321 Linux - Hardware 0 12-05-2003 01:59 PM
How to I know what progs running and what's installed? ReSync Linux - Newbie 7 06-29-2002 07:10 AM
What's the best program for running some windows progs on linux? piranha Linux - General 12 03-03-2002 07:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration