使用ncurses在Linux中构建HelloWorld C ++程序 [英] Building HelloWorld C++ Program in Linux with ncurses

查看:77
本文介绍了使用ncurses在Linux中构建HelloWorld C ++程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功运行了sudo apt-get install libncurses5-dev

然后在我的Eclipse窗口中,尝试构建以下HelloWord.cpp程序:

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;
}

我收到以下错误:

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

似乎编译器正在搜索ncurses库,但找不到它?我检查了/usr/lib,该库不存在,所以我需要在那里手动链接ncurses库-我认为get-apt安装程序会自动执行此操作吗?

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?

推荐答案

g++ HelloWorld.cpp -lncurses -o HelloWolrd

如果您使用的是32位计算机,请按gcc compile m32 auto.如果您使用的是64位计算机,而您想编译32位计算机,则

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

这篇关于使用ncurses在Linux中构建HelloWorld C ++程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆