Reputation: 145
I'm fairly new to C++ and I'm trying to set up ncurses, but I can't get it to work. Here's the code:
#include <iostream>
#include <string>
#include <ncurses.h>
int main(){
initscr();
printw("Hello World !!!");
refresh();
getch();
endwin();
return 0;
}
With this file I get 'undefined reference' errors
And here is the makefile:
main.o: main.cpp ncurses.h
g++ main.cpp -o crawler -lncurses
The error I get with the makefile is :
make: *** No rule to make target `ncurses.h', needed by `main.o'. Stop.
Thanks for your help!
Note: I am using Ubuntu 12.04 with Geany and g++
Upvotes: 1
Views: 907
Reputation: 1190
You should remove ncurses.h
dependency from Makefile. You Makefile should look like this:
main.o: main.cpp
g++ main.cpp -o crawler -lncurses
make
tries to find ncurses.h
in current working directory, but it is not available there. So make
indicates error.
Also, there is no need of iostream
and string
headers in your code, because string
header is included by iostream
and you are not using any functions from both of headers.
Upvotes: 1