Makefile Error!

closed account (1RX1wA7f)
$ hoppity.cpp Makefile
/usr/bin/hoppity.cpp: line 4: using: command not found
/usr/bin/hoppity.cpp: line 6: syntax error near unexpected token `('
/usr/bin/hoppity.cpp: line 6: `int main (int argc, char *argv[]) '
total bummer

edit: this might help? http://www.cyberciti.biz/faq/linux-unix-command-not-found-error-and-how-to-get-rid-of-it/

are you using namespace std? maybe try reduce dependencies on std by using std::cout or whatever you're trying to do

hope that was slightly more helpful than my original post
Last edited on
I'm not into *nix systems, but my guess is this:
$ hoppity.cpp Makefile
You try to run hoppity.cpp as bash script with a single argument - "Makefile". Even if that is not what you wanted, this is what you get.
/usr/bin/hoppity.cpp: line 4: using: command not found
Your file probably starts with several #include .. directives. But # is the prefix character for comments. So "include.." is treated as comment and ignored. Then, on the following line you have using namespace std; or something, which among other things runs the "using" command, which is nowhere to be found.

The rest is .. I don't know.

Regards
closed account (1RX1wA7f)
here's my complete code :


#include <fstream>
#include <iostream>

using namespace std;

int main (int argc, char *argv[])
{
ifstream readInput;
readInput.open(argv[1]);
int number;
readInput >> number;
for (int i = 1; i <= number; ++i)
{
if (i % 3 == 0 && i % 5 == 0) cout << "Hop\n";
else if (i % 3 == 0) cout << "Hoppity\n";
else if (i % 5 == 0) cout << "Hophop\n";
}
return 0;
}



can u pls help me out, now?
Well, as I said I'm not competent with *nix. But why do you use the make utility. Why don't you compile with gcc or whatever compiler you use directly like this:
$ gcc hoppity.cpp -o hoppity
$ hoppity
...


Makefiles are a language of their own. They make sense when your project contains more than one implementation file (.cpp).
closed account (1RX1wA7f)
@Ceruleus : Thanx for sharing the Link !!!

@Simeonz : I got the program compiled using the following command :

g++ hoppity.cpp -o hoppity

(g++ ==> since I'm compiling a C++ file & not a C file, for a C file, we use gcc)


& I ran my code using the following command :

./hoppity.exe Input.txt

& the program ran very well & I got my output also..

The thing is, why I require to create a makefile is because I've to submit this code along with its makefile....
maybe this link will help you write a make file?

http://graphics.ucmerced.edu/~mkallmann/courses/cse171-08s/makehelp.html

there really isn't too much involved when you're just compiling one source file
Please don't post a thread more than once
http://cplusplus.com/forum/unices/35274/
$ hoppity.cpp Makefile


Typing that will make the shell think that hippity.cpp is a file that it's supposed to execute. It doesn't recognize using as a shell command and doesn't see the first two because the "#" is a comment. If you want to run a makefile, you can just call it "makefile" (I don't think the make command cares for case, but don't quote me on that), go to the directory of that makefile, and type in "$make".

--edit: don't type the "$"... that was supposed to signify the prompt. Just type "make" in the directory with the makefile (if it's not called "makefile" you have to tell it the name).
Last edited on
Try something like this (where the indentation is a tab, not spaces):

# Makefile
hoppity: hoppity.o
    g++ -o $@ $<
hoppity.o: hoppity.cpp
    g++ -c $<

Topic archived. No new replies allowed.