NOOBIE C++ Question
Code:
#include <iostream> Code:
[Donald@localhost ~]$ cd Desktop/C++ |
Do you even have a Makefile created in ~/C++ ?
|
no it did not create a executable
|
A makefile is a kind of a template. It tells gcc how to build a application. It tells gcc what kind of command line options to use, what kind of objects to compile, and other things such as where to look for headers files and shared libraries. If you don't want to bother to learn 'make' you can do as many do, install an IDE such as Eclipse. That is what I did.
|
a make file? i didnt use it for my previous program to compile why do i need it now? they are just console programs
|
You don't really have to have one (it makes it easier if you have a lot of objects that are being compiled and linked into the final program) if you are just compiling one source file, you can use g++ on the comand line if you use the right options.
|
By the way, I compiled your program and it had an error in it. I'll let you figure out what it is when you get it to compile. That the 'fun' part of learning to program.
|
So, why are you running make?
|
Quote:
|
When you run "make", it tries to read a file (called a makefile, usually named "Makefile"). This file contains information on how to compile a program.
Since you have no Makefile, make does not know how to compile the program. You could either do it manually, with g++, or you can write a Makefile (there's also cmake, autotools, and several other pieces of software I don't know how to use.) "g++" is the C++ compiler. You can invoke it to compile this program with: Code:
g++ addition.cpp -o addition A makefile contains targets. For example, to compile a program named "main" from the file "main.cpp", you could add as a rule (make is picky on tabs vs. spaces): Code:
main: main.cpp Code:
all: main Code:
clean: And, as alan99 said, there is an error in the program. You'll figure it out. Post any issues you have if you try to write a Makefile for this project. EDIT: you found the error with "end1" vs "endl" |
Quote:
Thank you so much for your time for writing all this up!!! So your saying if i want to by-pass these problems i can just use Code:
g++ addition.cpp -o addition |
If you need to compile the C++ file, just use g++ if it's one file, like so:
Code:
$ g++ -Wall -Wextra -o addition addition.cpp |
Quote:
Glad I could help. Good luck learning C++. |
Also, make compiles only the files that changed, saving time for big multi-file projects.
|
[Donald@localhost ~]$ cd Desktop/C++
[Donald@localhost C++]$ ls addition.cpp printingLineofText [Donald@localhost C++]$ g++ addition.cpp -o addition g++: addition.cpp: No such file or directory g++: no input files [Donald@localhost C++]$ ^C [Donald@localhost C++]$ so above paste shows that i have navigated to the right directory and showing that the file is thereand then i try to compile and shows no such file |
All times are GMT -5. The time now is 10:29 PM. |