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?
Forum Updated to NodeBB v4.3 + New Features

How to add ncurses library to project?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
compilingqtcreator
5 Posts 4 Posters 6.1k 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 14 Mar 2017, 19:31 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 14 Mar 2017, 19:44 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 14 Mar 2017, 20:06 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.

        M J 2 Replies Last reply 14 Mar 2017, 20:09
        0
        • M maydin
          14 Mar 2017, 20:06

          @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.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 14 Mar 2017, 20:09 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
            14 Mar 2017, 20:06

            @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.

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 15 Mar 2017, 05:30 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

            5/5

            15 Mar 2017, 05:30

            • Login

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