0

I'm having a bit of a problem using the curses.h header file, and yes, I'm still a tad new at coding in C++. The problem is that when I try to compile, it gives the error:

    C:\Users\james\AppData\Local\Temp\cc0VxbfM.o:main.cpp:(.text+0x82): undefined reference to `PDC_chadd'

Here's the code:

    #include <conio.h>
    #include <curses.h>

    int main()
    {
        initscr();

        int nPlayerX = 40, nPlayerY = 12;

        while(true)
        {
            move(nPlayerY, nPlayerX); //Moves the console cursor on the Y and X axis
            addch('Y'); //Add a character
        }

}

  • How are you building this program? The most likely explanation is that you are not including the curses library when you link. You have to link with the library as well as include the header file. – john Aug 27 '13 at 15:56
  • I'm using g++ to build the program, with the command: `g++ Test.cpp -lpdcurses -o` – James Alexander Gardner Aug 27 '13 at 16:07
  • I think (no expert) that there's some kind of versioning issue. PDC_chadd was removed from pdcurses in version 3.0. Maybe you have an incompatibility between the version of the header you are compiling with and the library you are linking with. – john Aug 27 '13 at 16:22
  • I don't believe that would be it, I only downloaded the files just today, Library, header and .DLL included. I'll take a look at the .lib file and see if there's something that isn't supposed to be there. – James Alexander Gardner Aug 27 '13 at 16:25
  • DLL? You are building on Windows with g++? I see from the path that you clearly are. – john Aug 27 '13 at 16:27
  • Oh yeah.. I'm using Mingw, silly me. – James Alexander Gardner Aug 27 '13 at 16:29

1 Answers1

0

I had same problem. Try to link curses.lib. (append LDFLAG -lcurses)

take
  • 1