【问题标题】:statically linking libs. c compilation静态链接库。 c编译
【发布时间】:2014-02-13 23:43:59
【问题描述】:

我正在开发一个使用 ncurses 的程序,该程序将用于嵌入式系统。由于这些系统不会安装 ncurses,我需要静态链接库。但是,如果我尝试像这样构建它

gcc -static ncurs.c -o ncurs -l:libncurses.a

gcc -static ncurs.c -o ncurs -lncurses

我遇到很多这样的错误:

(.text+0x48): undefined reference to `SP'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncurses.a(lib_slktouch.o): In function `slk_touch':

正常编译工作正常。

我已经搜索了几个小时,但找不到任何好的信息...

开发平台被剥离了debian系统。

【问题讨论】:

    标签: c linux static libraries ncurses


    【解决方案1】:

    我猜你可能需要额外的库,你可以试试-lncurses -ltinfo

    您可以使用命令在您的系统上检查ncurses 的链接器库标志是什么

    pkg-config --static --libs ncurses
    

    在我的系统上,我得到了

    -lncurses -ltinfo
    

    【讨论】:

    • 哇,谢谢,这是我的问题的解决方案,您介意解释一下 -ltinfo 的用途吗?
    • 这是另一个库,libtinfo
    【解决方案2】:

    尝试在命令行末尾添加-ltinfo

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 2015-07-15
      • 1970-01-01
      相关资源
      最近更新 更多