You are not logged in.

#1 2017-07-28 08:39:03

nanxiao
Member
Registered: 2017-07-27
Posts: 21

[Solved]Why can't ld find curses.so even in `/usr/lib` directory?

When I build something, ld complains can't find curses library:

/usr/bin/ld: cannot find -lcurses
collect2: error: ld returned 1 exit status

But my /usr/lib indeed contains curses related library:

# ls -lt /usr/lib/libcurse*
lrwxrwxrwx 1 root root 13 May 29 14:50 /usr/lib/libcurses.so -> libncurses.so
-rw-r--r-- 1 root root 18 May 29 14:50 /usr/lib/libcursesw.so
# ls -lt /usr/lib/libncurse*
-rw-r--r-- 1 root root     20 May 29 14:50 /usr/lib/libncurses++.so
lrwxrwxrwx 1 root root     18 May 29 14:50 /usr/lib/libncurses++w.so -> libncurses++w.so.6
lrwxrwxrwx 1 root root     20 May 29 14:50 /usr/lib/libncurses++w.so.6 -> libncurses++w.so.6.0
-rwxr-xr-x 1 root root  77264 May 29 14:50 /usr/lib/libncurses++w.so.6.0
-rw-r--r-- 1 root root     18 May 29 14:50 /usr/lib/libncurses.so
-rwxr-xr-x 1 root root 444776 May 29 14:50 /usr/lib/libncursesw.so.6.0
lrwxrwxrwx 1 root root     16 May 29 14:50 /usr/lib/libncursesw.so -> libncursesw.so.6
lrwxrwxrwx 1 root root     18 May 29 14:50 /usr/lib/libncursesw.so.6 -> libncursesw.so.6.0

We can see libcurses.so points to libncurses.so, and libncurses.so is like this:

# cat  /usr/lib/libncurses.so
INPUT(-lncursesw)

I try to link -lncursesw directly, but there is still link error:

/usr/bin/ld: cannot find -lncursesw
collect2: error: ld returned 1 exit status

Why can't ld find libcurses.so even though it is in /usr/lib directory?

Last edited by nanxiao (2017-07-28 09:51:12)

Offline

#2 2017-07-28 09:05:13

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,877

Re: [Solved]Why can't ld find curses.so even in `/usr/lib` directory?

ldconfig -p | grep curses

Offline

#3 2017-07-28 09:07:33

nanxiao
Member
Registered: 2017-07-27
Posts: 21

Re: [Solved]Why can't ld find curses.so even in `/usr/lib` directory?

@seth

    # ldconfig -p | grep curses
        libncursesw.so.6 (libc6,x86-64) => /usr/lib/libncursesw.so.6
        libncursesw.so (libc6,x86-64) => /usr/lib/libncursesw.so
        libncurses++w.so.6 (libc6,x86-64) => /usr/lib/libncurses++w.so.6
        libncurses++w.so (libc6,x86-64) => /usr/lib/libncurses++w.so

Offline

#4 2017-07-28 09:09:52

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,877

Re: [Solved]Why can't ld find curses.so even in `/usr/lib` directory?

and what do you take from that?

Offline

#5 2017-07-28 09:15:40

nanxiao
Member
Registered: 2017-07-27
Posts: 21

Re: [Solved]Why can't ld find curses.so even in `/usr/lib` directory?

@seth

> and what do you take from that?

I don't know why link -lncursesw also generate error. Could u give some clues? Thx!

Offline

#6 2017-07-28 09:49:53

nanxiao
Member
Registered: 2017-07-27
Posts: 21

Re: [Solved]Why can't ld find curses.so even in `/usr/lib` directory?

Offline

#7 2017-07-28 13:28:34

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,877

Re: [Solved]Why can't ld find curses.so even in `/usr/lib` directory?

Yeah, sorry. First for the delay, second because I missed that you actually had tried the correct symbol as well.

(ftr: the actual compiler call/output would have been my question w/o the library name distraction, that's why there is https://bbs.archlinux.org/viewtopic.php?id=57855 ;-)

Offline

Board footer

Powered by FluxBB