LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   (Beginner) C++ Compilation? (https://www.linuxquestions.org/questions/linux-software-2/beginner-c-compilation-240786/)

Garoth 10-09-2004 09:10 PM

(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.

eternauta3k 10-09-2004 09:26 PM

Not that way
 
Make is for when you have a Makefile, which you don't. To compile in c++ use g++.
Ignacio

irfanhab 10-09-2004 09:28 PM

Make is only when you have a project with makefile

rather a simple c++ file just go

g++ filename.cpp

Garoth 10-09-2004 09:41 PM

All right, this seems to have created "a.out". From there, I am to link it, right? What can I do for that?

michaelk 10-09-2004 09:49 PM

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.

Garoth 10-09-2004 09:51 PM

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.

michaelk 10-09-2004 09:57 PM

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).

Garoth 10-09-2004 10:00 PM

What can I do to run this new file, on Fedora Core 2?

michaelk 10-09-2004 10:00 PM

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.

Garoth 10-09-2004 10:01 PM

Great! Thank you.

pradeepmenon777 10-21-2004 01:23 AM

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

eternauta3k 10-21-2004 06:13 PM

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 07:05 PM.