LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 01-29-2004, 05:34 PM   #1
njbrain
Member
 
Registered: Jan 2004
Location: Rhinelander, WI, U.S.
Distribution: Slackware
Posts: 416

Rep: Reputation: 30
How do I compile a *.cpp Document in linux?


I am using "C++ Weekend Crash Course", written by Stephen R. Davis. I typed in the code that he listed in his book, saved it, opened up a console and typed, "gcc Conversion.cpp -o Conversion". I just got a page of errors. Then I tried using the code that is on the cd that came with the book, but with the same results.
Thanks in advance,
Noah
 
Old 01-29-2004, 05:42 PM   #2
CycloLink
Member
 
Registered: Jan 2004
Distribution: Redhat 9.0
Posts: 32

Rep: Reputation: 15
I need to know a few things. First if the program is small post the code for it. Second what version of gcc are you using. gcc -v. you may also want to try g++ instead of gcc, i personally prefer it.
 
Old 01-29-2004, 06:03 PM   #3
njbrain
Member
 
Registered: Jan 2004
Location: Rhinelander, WI, U.S.
Distribution: Slackware
Posts: 416

Original Poster
Rep: Reputation: 30
I tried g++ instead, and it worked better. I didn't give me any errors, but it also didn't work. It just put me right back at the command promt.
 
Old 01-29-2004, 06:06 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
why didn't it work? what makes you think it went wrong? what kind of errors were you getting? stabbing in the dark i'd guess you need to include certain library, e.g. "-lm" for the math library.
 
Old 01-29-2004, 06:29 PM   #5
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 59
or maybe since you said that it worked better, but also it didn't work and it put you back to the command prompt, maybe it just compiled successfully and the executable is just sitting there waiting to be ran
 
Old 01-29-2004, 06:48 PM   #6
CycloLink
Member
 
Registered: Jan 2004
Distribution: Redhat 9.0
Posts: 32

Rep: Reputation: 15
that would be my guess. successful compile and program is just waiting to be run. if you just used g++ filename.cpp then the program is a.out but if you used g++ -o filename filename.cpp then the program is filename. try running it.
 
Old 01-29-2004, 06:56 PM   #7
njbrain
Member
 
Registered: Jan 2004
Location: Rhinelander, WI, U.S.
Distribution: Slackware
Posts: 416

Original Poster
Rep: Reputation: 30
Duh!, the executible was sitting there waiting to be ran. I guesse I have to learn somehow! Even though I was being stupid, thanks for your help!
 
Old 01-29-2004, 06:56 PM   #8
njbrain
Member
 
Registered: Jan 2004
Location: Rhinelander, WI, U.S.
Distribution: Slackware
Posts: 416

Original Poster
Rep: Reputation: 30
By the way, it worked perfectly
 
Old 01-29-2004, 07:00 PM   #9
CycloLink
Member
 
Registered: Jan 2004
Distribution: Redhat 9.0
Posts: 32

Rep: Reputation: 15
 
Old 01-29-2004, 08:43 PM   #10
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
General rule in Unix and Linux: If the program is quiet, it worked.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to compile a C++ file (.cpp) with allegro? RHLinuxGUY Programming 5 11-29-2005 03:06 AM
How To Compile Cpp Source And Header? kike_coello Programming 10 09-08-2005 04:22 AM
compile programs in c and cpp Manjula.S Linux - Software 2 10-15-2003 02:06 AM
Problems when trying to compile cpp files using qt headers siphiuel Linux - Software 2 08-12-2003 05:41 AM
to compile cpp on linux mandrake manpreet Programming 1 04-26-2001 01:45 AM


All times are GMT -5. The time now is 01:01 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration