Statically link ncurses to program

前端 未结 3 1595
眼角桃花
眼角桃花 2020-12-06 18:15

I\'m having some problems statically linking ncurses to one of my programs

Here\'s a really simple sample program:

#include


int ma         


        
3条回答
  •  不思量自难忘°
    2020-12-06 18:32

    Edit:

    I think the real problem is that you need to specify your -l option at the end of the command. I just tried it the way you had it and reproduced your error. If I put -l:libncurses.a at the end of the line then it works. All without the -static option BTW.


    I think what is happening is that you have a dynamic library for ncurses but you have used the -static option which means to not use any dynamic libraries. I suspect you do not actually have a static version of the ncurses library i.e. one ending with a .a suffix.

    If you want to link with the static version (.a) of ncurses rather than the dynamic version (.so) then temporarily remove the symlink for libncurses.so so that the linker picks up the .a file instead. Alternatively copy the .a file somewhere else and add that to an earlier search path.

    Alternatively if your linker supports it (eg. ld) then you could specify -l:libncurses.a instead of -lncurses.

提交回复
热议问题