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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-09-2004, 09:10 PM
|
#1
|
Member
Registered: Oct 2004
Location: Canada -> Ontario -> Toronto
Posts: 34
Rep:
|
(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.
|
|
|
10-09-2004, 09:26 PM
|
#2
|
LQ Newbie
Registered: Oct 2004
Location: Buenos Aires, Argentina
Distribution: Fedora Core 2; Debian
Posts: 25
Rep:
|
Not that way
Make is for when you have a Makefile, which you don't. To compile in c++ use g++.
Ignacio
|
|
|
10-09-2004, 09:28 PM
|
#3
|
Member
Registered: Jan 2004
Location: Pakistan
Distribution: OpenSuse 10.2, Slackware 11, Solaris 10
Posts: 415
Rep:
|
Make is only when you have a project with makefile
rather a simple c++ file just go
g++ filename.cpp
|
|
|
10-09-2004, 09:41 PM
|
#4
|
Member
Registered: Oct 2004
Location: Canada -> Ontario -> Toronto
Posts: 34
Original Poster
Rep:
|
All right, this seems to have created "a.out". From there, I am to link it, right? What can I do for that?
|
|
|
10-09-2004, 09:49 PM
|
#5
|
Moderator
Registered: Aug 2002
Posts: 26,127
|
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.
|
|
|
10-09-2004, 09:51 PM
|
#6
|
Member
Registered: Oct 2004
Location: Canada -> Ontario -> Toronto
Posts: 34
Original Poster
Rep:
|
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.
|
|
|
10-09-2004, 09:57 PM
|
#7
|
Moderator
Registered: Aug 2002
Posts: 26,127
|
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).
|
|
|
10-09-2004, 10:00 PM
|
#8
|
Member
Registered: Oct 2004
Location: Canada -> Ontario -> Toronto
Posts: 34
Original Poster
Rep:
|
What can I do to run this new file, on Fedora Core 2?
|
|
|
10-09-2004, 10:00 PM
|
#9
|
Moderator
Registered: Aug 2002
Posts: 26,127
|
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.
|
|
|
10-09-2004, 10:01 PM
|
#10
|
Member
Registered: Oct 2004
Location: Canada -> Ontario -> Toronto
Posts: 34
Original Poster
Rep:
|
Great! Thank you.
|
|
|
10-21-2004, 01:23 AM
|
#11
|
Member
Registered: Jan 2004
Location: India
Distribution: Android 9.0.6
Posts: 123
Rep:
|
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
|
|
|
10-21-2004, 06:13 PM
|
#12
|
LQ Newbie
Registered: Oct 2004
Location: Buenos Aires, Argentina
Distribution: Fedora Core 2; Debian
Posts: 25
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 05:05 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|