Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QT creator and MinGW project in C doesn't recognize ncurses.h
Forum Updated to NodeBB v4.3 + New Features

QT creator and MinGW project in C doesn't recognize ncurses.h

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
9 Posts 4 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ale.fdezsuarez
    wrote on last edited by
    #1

    Hi, I'd like to know if anyone knows what I should include in my .pro file to be able to use:

    #include <ncurses.h>
    

    I tried with this but it doen't work. Thank you so much.

    #include <ncurses.h> /* ncurses.h includes stdio.h */
    #include <string.h>
    int main()
    {
        char mesg[]="Just a string"; /* message to be appeared on the screen */
        int row,col; /* to store the number of rows and *
     * the number of colums of the screen */
        initscr(); /* start the curses mode */
        getmaxyx(stdscr,row,col); /* get the number of rows and columns */
        mvprintw(row/2,(col−strlen(mesg))/2,"%s",mesg);
        /* print the message at the center of the screen */
        mvprintw(row−2,0,"This screen has %d rows and %d columns\n",row,col);
        printw("Try resizing your window(if possible) and then run this program again");
        refresh();
        getch();
        endwin();
        return 0;
    }
    
    
    JonBJ 1 Reply Last reply
    0
    • A ale.fdezsuarez

      Hi, I'd like to know if anyone knows what I should include in my .pro file to be able to use:

      #include <ncurses.h>
      

      I tried with this but it doen't work. Thank you so much.

      #include <ncurses.h> /* ncurses.h includes stdio.h */
      #include <string.h>
      int main()
      {
          char mesg[]="Just a string"; /* message to be appeared on the screen */
          int row,col; /* to store the number of rows and *
       * the number of colums of the screen */
          initscr(); /* start the curses mode */
          getmaxyx(stdscr,row,col); /* get the number of rows and columns */
          mvprintw(row/2,(col−strlen(mesg))/2,"%s",mesg);
          /* print the message at the center of the screen */
          mvprintw(row−2,0,"This screen has %d rows and %d columns\n",row,col);
          printw("Try resizing your window(if possible) and then run this program again");
          refresh();
          getch();
          endwin();
          return 0;
      }
      
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @ale-fdezsuarez said in QT creator and MinGW project in C doesn't recognize ncurses.h:

      I tried with this but it doen't work.

      What does this mean? Didn't compile? Didn't link? Didn't run? Didn't do what you want? Did you really get no error message anywhere, just "didn't work"? We are not guess-experts...!

      For my guess: either it didn't find /usr/include/ncurses.h to include (doubtful), or you need to tell it which libncurses... to link against.

      EDIT
      OK, sorry, I only just just noticed your this word was a link :) So that said:

      INCLUDEPATH += /path/to/ncurses/headers/
      LIBS += -L/path/to/ncurses/library/ -lncurses
      

      which looks about right. What paths did you put there, and did you check there is a ncurses.h file in the INCLUDEPATH directory and a libncurses.a file in the LIBS directory? And still we need to know: did it fail at compile time (INCLUDEPATH) or at link time (LIBS), and with what message?

      A 1 Reply Last reply
      0
      • A Offline
        A Offline
        ale.fdezsuarez
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • JonBJ JonB

          @ale-fdezsuarez said in QT creator and MinGW project in C doesn't recognize ncurses.h:

          I tried with this but it doen't work.

          What does this mean? Didn't compile? Didn't link? Didn't run? Didn't do what you want? Did you really get no error message anywhere, just "didn't work"? We are not guess-experts...!

          For my guess: either it didn't find /usr/include/ncurses.h to include (doubtful), or you need to tell it which libncurses... to link against.

          EDIT
          OK, sorry, I only just just noticed your this word was a link :) So that said:

          INCLUDEPATH += /path/to/ncurses/headers/
          LIBS += -L/path/to/ncurses/library/ -lncurses
          

          which looks about right. What paths did you put there, and did you check there is a ncurses.h file in the INCLUDEPATH directory and a libncurses.a file in the LIBS directory? And still we need to know: did it fail at compile time (INCLUDEPATH) or at link time (LIBS), and with what message?

          A Offline
          A Offline
          ale.fdezsuarez
          wrote on last edited by
          #4

          @JonB First of all thank you for you answer.

          No, I couldn't check if they are on the INCLUDEPATH routes because I don't know where those routes are in QT (I just started using it).

          The error is given to me in the .c file that underlines the

          #include <ncurses.h>
          ``` and puts me:
          
          

          principal.c:2:10: error: 'ncurses.h' file not found

          JonBJ 1 Reply Last reply
          0
          • A ale.fdezsuarez

            @JonB First of all thank you for you answer.

            No, I couldn't check if they are on the INCLUDEPATH routes because I don't know where those routes are in QT (I just started using it).

            The error is given to me in the .c file that underlines the

            #include <ncurses.h>
            ``` and puts me:
            
            

            principal.c:2:10: error: 'ncurses.h' file not found

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @ale-fdezsuarez said in QT creator and MinGW project in C doesn't recognize ncurses.h:

            principal.c:2:10: error: 'ncurses.h' file not found

            OK, that's a bit more helpful! :)

            So, I don't know where it is on the PC, presumably somewhere in the MinGW installed area(?), you need to find a file named ncurses.h. And then you need to go like that answer said in your .pro file:

            INCLUDEPATH += /path/to/ncurses/headers/
            

            And then similarly for the LIBS line for the path to a file named libncurses.a.

            A 1 Reply Last reply
            1
            • JonBJ JonB

              @ale-fdezsuarez said in QT creator and MinGW project in C doesn't recognize ncurses.h:

              principal.c:2:10: error: 'ncurses.h' file not found

              OK, that's a bit more helpful! :)

              So, I don't know where it is on the PC, presumably somewhere in the MinGW installed area(?), you need to find a file named ncurses.h. And then you need to go like that answer said in your .pro file:

              INCLUDEPATH += /path/to/ncurses/headers/
              

              And then similarly for the LIBS line for the path to a file named libncurses.a.

              A Offline
              A Offline
              ale.fdezsuarez
              wrote on last edited by
              #6

              @JonB So in my case:

              ncurses.png libncurses.png

              And if I go to the .pro file I write:

              INCLUDEPATH += C:\Qt\Tools\mingw810_32\opt\include\ncursesw
              LIBS += -LC:\Qt\Tools\mingw810_32\opt\lib
              

              And I get two errors when I compile it :(

              :-1: error: error: LC:\Qt\Tools\mingw810_32\opt\include\ncursesw: Invalid argument
              :-1: error: [Makefile.Debug:68: debug/Test_curses_002.exe] Error 1
              
              JonBJ 1 Reply Last reply
              0
              • A ale.fdezsuarez

                @JonB So in my case:

                ncurses.png libncurses.png

                And if I go to the .pro file I write:

                INCLUDEPATH += C:\Qt\Tools\mingw810_32\opt\include\ncursesw
                LIBS += -LC:\Qt\Tools\mingw810_32\opt\lib
                

                And I get two errors when I compile it :(

                :-1: error: error: LC:\Qt\Tools\mingw810_32\opt\include\ncursesw: Invalid argument
                :-1: error: [Makefile.Debug:68: debug/Test_curses_002.exe] Error 1
                
                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @ale-fdezsuarez said in QT creator and MinGW project in C doesn't recognize ncurses.h:

                LIBS += -LC:\Qt\Tools\mingw810_32\opt\lib

                Why do you write this when the solution you read, and what I pasted above, reads:

                LIBS += -L/path/to/ncurses/library/ -lncurses
                

                ? I just don't get it. There is a reason people paste answers, you have to read and follow, not just ignore bits of it and then wonder why it doesn't work....

                P.S.

                :-1: error: error: LC:\Qt\Tools\mingw810_32\opt\include\ncursesw: Invalid argument

                Could you explain how you get this error message from what you show you added into the .pro. Where does that leading L come from? Or, is that error message actually from writing something different from what you show?

                mzimmersM 1 Reply Last reply
                2
                • JonBJ JonB

                  @ale-fdezsuarez said in QT creator and MinGW project in C doesn't recognize ncurses.h:

                  LIBS += -LC:\Qt\Tools\mingw810_32\opt\lib

                  Why do you write this when the solution you read, and what I pasted above, reads:

                  LIBS += -L/path/to/ncurses/library/ -lncurses
                  

                  ? I just don't get it. There is a reason people paste answers, you have to read and follow, not just ignore bits of it and then wonder why it doesn't work....

                  P.S.

                  :-1: error: error: LC:\Qt\Tools\mingw810_32\opt\include\ncursesw: Invalid argument

                  Could you explain how you get this error message from what you show you added into the .pro. Where does that leading L come from? Or, is that error message actually from writing something different from what you show?

                  mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by
                  #8

                  @JonB I notice the OP is using backslashes in his path. As I recall, this causes problems in a project file. The other thing is that the -L/-l convention comes from Linux; does this actually work with Windows libraries? I seem to recall trying to use that once, and ran into issues I can't remember anymore.

                  aha_1980A 1 Reply Last reply
                  0
                  • mzimmersM mzimmers

                    @JonB I notice the OP is using backslashes in his path. As I recall, this causes problems in a project file. The other thing is that the -L/-l convention comes from Linux; does this actually work with Windows libraries? I seem to recall trying to use that once, and ran into issues I can't remember anymore.

                    aha_1980A Offline
                    aha_1980A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @mzimmers

                    I notice the OP is using backslashes in his path. As I recall, this causes problems in a project file.

                    Correct. Using forward slashes is the way to go.

                    The other thing is that the -L/-l convention comes from Linux; does this actually work with Windows libraries? I seem to recall trying to use that once, and ran into issues I can't remember anymore.

                    Using -L and -l is cross-platform and should be used on Windows with MSVC and MinGW also. Qt Creator recognizes this syntax and extends the library search paths when running the app.

                    If you have problems here, then you probably messed up the syntax - which I had in former times also ;)

                    Regards

                    Qt has to stay free or it will die.

                    1 Reply Last reply
                    1

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved