Building HelloWorld C++ Program in Linux with ncurses

二次信任 提交于 2019-12-06 04:13:13

问题


I successfully ran sudo apt-get install libncurses5-dev

Within my Eclipse window I then try to build the following HelloWord.cpp program:

#include <ncurses.h>

int main()
{
    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 get the following error:

Invoking: GCC C++ Linker
g++ -m32 -lncurses -L/opt/lib -o "Test_V"  ./src/curseTest.o ./src/trajectory.o ./src/xJus-epos.o   -lEposCmd
/usr/bin/ld: cannot find -lncurses
collect2: error: ld returned 1 exit status
make: *** [Test_V] Error 1

It looks like the compiler is searching for the ncurses library and can't find it? I checked /usr/lib and the library does not exist there so do I need to manually link the ncurses library there - I thought the get-apt installer would automatically do this?


回答1:


g++ HelloWorld.cpp -lncurses -o HelloWolrd

If you have a 32-bit machine, gcc compile m32 auto. If you have a 64-bit machine and you want to compile 32bits you



来源:https://stackoverflow.com/questions/15078001/building-helloworld-c-program-in-linux-with-ncurses

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!