g++ not using curses library even with -lcurses

I am trying to compile some code that uses curses to clear the screen, on my personal machine (Debian sid) it works, but in Cygwin and a Ubuntu 14.04 VM it doesn't compile. I have tried using both -lcurses and -lncurses, and I'm including ncurses.h in the program, even with these, it gives me the following error:

1
2
3
4
5
6
7
  g++ -std=c++11 -g -Wall -lncurses -fpermissive -O2 main.o turn.o clearscreen.o endcheck.o parse.o randevents.o -o CWS

clearscreen.o: In function `clearScreen()':
/home/czar/Downloads/CWS/clearscreen.cpp:9: undefined reference to `cur_term'
/home/czar/Downloads/CWS/clearscreen.cpp:18: undefined reference to `tigetstr'
/home/czar/Downloads/CWS/clearscreen.cpp:18: undefined reference to `putp'
/home/czar/Downloads/CWS/clearscreen.cpp:12: undefined reference to `setupterm' 
Bumping, sorry if this is too soon, I don't know how many pages people will go to here.
Last bump
Do you have curses installed on the Ubuntu machine?
Try putting -lncurses last.
Er, put it first for GCC.

You must apt-get install ncurses-dev (or whatever the package is called) before you can use NCurses.

Hope this helps.
cmiiw, I think that the order matters if you are using an static library, and in that case the one that needs the symbols should appear before the one that defines them.
@Duoas, You'll get a 'file not found' error if you link to something that isn't there.

My guess is that there are flags you need on those other machines, try:
$ pkg-config --libs ncurses

If it outputs something other than -lncurses ( and works too ), then make your compile line:

g++ -std=c++11 -g -Wall `pkg-config --libs ncurses` -fpermissive -O2 main.o turn.o clearscreen.o endcheck.o parse.o randevents.o -o CWS

Note that those are back ticks, not single quotes.
Topic archived. No new replies allowed.