LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Gentoo
User Name
Password
Gentoo This forum is for the discussion of Gentoo Linux.

Notices


Reply
  Search this Thread
Old 04-11-2010, 09:36 PM   #1
the_rastaman
Member
 
Registered: Mar 2010
Posts: 39

Rep: Reputation: 15
Question how to run a .cpp file in terminal?


for a university project i need to run some .cpp files but when i tried this commands in terminal:

gcc -o potencia.cpp
g++ -o potencia.cpp
c++ -o potencia.cpp

gentoo compiles the .cpp files an what i need is in a certain way a executable file like a "a.out" or something like that, so anyone can help me? thanks for any information.
 
Old 04-11-2010, 09:42 PM   #2
umwai
Member
 
Registered: May 2008
Location: Sri Lanka
Distribution: Ubuntu
Posts: 57
Blog Entries: 1

Rep: Reputation: 16
Cool how to run a .cpp file in terminal?

hi if you want a a.out file don't use '-o' option.
ex :- g++ potencia.cpp
-o is used to name the output file. if you want your output file to be named as output you can use the command below
g++ potencia.cpp -o output
OR
g++ -o output potencia.cpp
 
Old 04-11-2010, 09:47 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You don't run c++ source code. Using the same name for the binary as the source, you may have overwritten your input source.

You will want to read an intro article on C++ and using g++. The source may require libraries, or may have a make file. Look for a file named README or install to start.
 
Old 04-11-2010, 10:11 PM   #4
the_rastaman
Member
 
Registered: Mar 2010
Posts: 39

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by umwai View Post
hi if you want a a.out file don't use '-o' option.
ex :- g++ potencia.cpp
i tried that one to, but the problem is that the command line does not generate an "output" or a.out. I can compile mi .cpp file but i cant run it.
 
Old 04-11-2010, 10:19 PM   #5
cola
Senior Member
 
Registered: Sep 2007
Posts: 1,045

Rep: Reputation: 65
Quote:
Originally Posted by the_rastaman View Post
i tried that one to, but the problem is that the command line does not generate an "output" or a.out. I can compile mi .cpp file but i cant run it.
Code:
g++ file1.cpp -o file1
./file1
Or
Code:
c++ file1.cpp
./a.out

Last edited by cola; 04-11-2010 at 10:20 PM.
 
Old 04-11-2010, 10:40 PM   #6
the_rastaman
Member
 
Registered: Mar 2010
Posts: 39

Original Poster
Rep: Reputation: 15
i dont now if i have to laugh or to cry. in one part of the line i put cin>>"n", and that is the way this #%%$^@ wasnt running, thanks for your help and your patient
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++Linking Classes/.cpp files to run one after other? FinalDecap Programming 2 04-12-2010 02:22 AM
small guidance needed: How do I run my school cpp programs in Kdevelop ameyjah Programming 7 04-23-2008 06:10 PM
checking how to run the C preprocessor... /lib/cpp bruxelles Linux - Newbie 5 01-19-2008 10:55 AM
KDE g++ program doesn't run test.cpp richikiki Programming 6 03-17-2006 02:47 PM
How to run MP3 file thru Terminal in K.D.E or Terminal itz2000 Linux - Newbie 5 08-04-2005 09:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Gentoo

All times are GMT -5. The time now is 07:21 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