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. How to add ncurses library to project?

How to add ncurses library to project?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
compilingqtcreator
5 Posts 4 Posters 6.6k Views 2 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.
  • M Offline
    M Offline
    maydin
    wrote on last edited by A Former User
    #1

    I am trying to start with ncurses library but QtCreator does not compile it. Here is the simple code:

    #include <iostream>
    #include <ncurses.h>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        initscr();			/* Start curses mode 		  */
        printw("Hello World !!!");	/* Print Hello World		  */
        refresh();			/* Print it on to the real screen */
        getch();			/* Wait for user input */
        endwin();			/* End curses mode		  */
    
        return 0;
    }
    

    I added to .pro file these lines but i could not find where i am doing wrong:

    QMAKE_CXXFLAGS += -lncurses
    QMAKE_CXXFLAGS_DEBUG += -lncurses
    

    When I compile it with g++ manually with -lncurses option it works though. QtCreator gives me undefined reference for those functions.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Your *.pro file should contain:

      INCLUDEPATH += /path/to/ncurses/headers/
      LIBS += -L/path/to/ncurses/library/ -lncurses
      
      1 Reply Last reply
      3
      • M Offline
        M Offline
        maydin
        wrote on last edited by maydin
        #3

        @Wieland I have just added this and it works:

        LIBS += -L/usr/include -lncurses
        

        But I dealed with finding include path still, I don't know why only -lncurses is not enough.

        mrjjM jsulmJ 2 Replies Last reply
        0
        • M maydin

          @Wieland I have just added this and it works:

          LIBS += -L/usr/include -lncurses
          

          But I dealed with finding include path still, I don't know why only -lncurses is not enough.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @maydin
          Hi you also need to tell about
          .h files with
          INCLUDEPATH += /path/to/ncurses/headers/
          as @wieland says

          1 Reply Last reply
          1
          • M maydin

            @Wieland I have just added this and it works:

            LIBS += -L/usr/include -lncurses
            

            But I dealed with finding include path still, I don't know why only -lncurses is not enough.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @maydin As libs are not located in include directories it should be:

            LIBS += -L/usr/lib -lncurses
            

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2

            • Login

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