LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-09-2004, 09:10 PM   #1
Garoth
Member
 
Registered: Oct 2004
Location: Canada -> Ontario -> Toronto
Posts: 34

Rep: Reputation: 15
(Beginner) C++ Compilation?


I am both a new Linux user and a C++ pogrammer. The tutorial I am reading suggests I use Emacs to compile my programs, if that is what I have. So, I have gotten far enough to have a .cpp file that I made w/ Qt Designer, but when I hit compile in the Emacs, it tells me:

Quote:
cd /home/garoth/
make -k
make: *** No targets specified and no makefile found. Stop.

Compilation exited abnormally with code 2 at Sat Oct 9 21:58:30

I would appreciate some help.
 
Old 10-09-2004, 09:26 PM   #2
eternauta3k
LQ Newbie
 
Registered: Oct 2004
Location: Buenos Aires, Argentina
Distribution: Fedora Core 2; Debian
Posts: 25

Rep: Reputation: 15
Not that way

Make is for when you have a Makefile, which you don't. To compile in c++ use g++.
Ignacio
 
Old 10-09-2004, 09:28 PM   #3
irfanhab
Member
 
Registered: Jan 2004
Location: Pakistan
Distribution: OpenSuse 10.2, Slackware 11, Solaris 10
Posts: 415

Rep: Reputation: 34
Make is only when you have a project with makefile

rather a simple c++ file just go

g++ filename.cpp
 
Old 10-09-2004, 09:41 PM   #4
Garoth
Member
 
Registered: Oct 2004
Location: Canada -> Ontario -> Toronto
Posts: 34

Original Poster
Rep: Reputation: 15
All right, this seems to have created "a.out". From there, I am to link it, right? What can I do for that?
 
Old 10-09-2004, 09:49 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,675

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
a.out is the compilers default executable name.

To run the program type the following:
./a.out

To create an executable with the name of your choosing:
g++ -o app_name source.cpp

app_name will be the name of your program.
 
Old 10-09-2004, 09:51 PM   #6
Garoth
Member
 
Registered: Oct 2004
Location: Canada -> Ontario -> Toronto
Posts: 34

Original Poster
Rep: Reputation: 15
Hey, that helps a lot. Thank you very much.

Also, while I am at really humilliating questions, what do I do to run an executable file, that I have created. Is there a terminal command, or an easier way. Clicking at it doesnt seem to do much good. I read that 'Linuxprog' should do it, but it doesnt seem to be Fedora Core 2.

Last edited by Garoth; 10-09-2004 at 09:57 PM.
 
Old 10-09-2004, 09:57 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,675

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
I might also add that ./ is a shortcut for current working directory. Unlike windows, linux only searches the path environment for a command. You can add a directory to the path via your .bash_profile file (assuming your using bash).
 
Old 10-09-2004, 10:00 PM   #8
Garoth
Member
 
Registered: Oct 2004
Location: Canada -> Ontario -> Toronto
Posts: 34

Original Poster
Rep: Reputation: 15
What can I do to run this new file, on Fedora Core 2?
 
Old 10-09-2004, 10:00 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,675

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Quote:
To run the program type the following:
./a.out
i.e in the same terminal console that you compilied the program. Replace a.out with the actual program name.
 
Old 10-09-2004, 10:01 PM   #10
Garoth
Member
 
Registered: Oct 2004
Location: Canada -> Ontario -> Toronto
Posts: 34

Original Poster
Rep: Reputation: 15
Great! Thank you.
 
Old 10-21-2004, 01:23 AM   #11
pradeepmenon777
Member
 
Registered: Jan 2004
Location: India
Distribution: Android 9.0.6
Posts: 123

Rep: Reputation: 16
michaelk
Senior Member

Registered: Aug 2002
Location:
Distribution:
Posts: 3485
HCL Entries: 0
Reviews: 0

( post #5)

a.out is the compilers default executable name.

To run the program type the following:
./a.out

To create an executable with the name of your choosing:
g++ -o app_name source.cpp

app_name will be the name of your program.


I have a small doubt, won't this executable you are talking about now, need the installation of gcc in the system running this executable........

if(question is answered)
{
cout<<" thanks!!!!"
}
else
{
cout<<"Maybe you are fed up with such questions"
}


a newbie has many stupid doubts, so please do bear and answer, who knows these newbies may turn out to be goslings in future
 
Old 10-21-2004, 06:13 PM   #12
eternauta3k
LQ Newbie
 
Registered: Oct 2004
Location: Buenos Aires, Argentina
Distribution: Fedora Core 2; Debian
Posts: 25

Rep: Reputation: 15
Nope

1. gcc is just the compiler, so they won't need it
2. It depends on what libraries you used. If only #include s, then they won't need anything.

By the way, I still haven't managed to switch to cout, so I keep using good old printf :P
 
  


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
beginner needs various help. meeep Linux - Software 44 08-21-2005 12:10 AM
Help this beginner weng Linux - Newbie 5 12-20-2003 08:55 AM
Beginner (Help Me!!) Kylejb2663 Linux - Networking 29 05-15-2003 02:00 AM
I am THE beginner please help me :( statuszero Linux - General 10 05-26-2002 03:44 PM
beginner archangel Linux - Security 11 09-03-2001 05:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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