linux - Why can't ld find libcurses.so even though it is in `/usr/lib` directory? -
on arch linux
, when build something, ld
complains can't find curses
library:
/usr/bin/ld: cannot find -lcurses collect2: error: ld returned 1 exit status
but /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 libncurses.so
, , libncurses.so
this:
# cat /usr/lib/libncurses.so input(-lncursesw)
i try link -lncursesw
directly, there still link error:
/usr/bin/ld: cannot find -lncursesw collect2: error: ld returned 1 exit status
why can't ld
find libcurses.so
though in /usr/lib
directory?
update:
i building bpftrace project, , link error following:
[ 29%] linking cxx executable bpftrace cd /root/project/bpftrace/build/src && /usr/bin/cmake -e cmake_link_script cmakefiles/bpftrace.dir/link.txt --verbose=1 /usr/bin/c++ -g -static -rdynamic cmakefiles/bpftrace.dir/ast.cpp.o cmakefiles/bpftrace.dir/attached_probe.cpp.o cmakefiles/bpftrace.dir/bpftrace.cpp.o cmakefiles/bpftrace.dir/codegen_llvm.cpp.o cmakefiles/bpftrace.dir/driver.cpp.o cmakefiles/bpftrace.dir/irbuilderbpf.cpp.o cmakefiles/bpftrace.dir/main.cpp.o cmakefiles/bpftrace.dir/map.cpp.o cmakefiles/bpftrace.dir/mapkey.cpp.o cmakefiles/bpftrace.dir/printer.cpp.o cmakefiles/bpftrace.dir/printf.cpp.o cmakefiles/bpftrace.dir/semantic_analyser.cpp.o cmakefiles/bpftrace.dir/types.cpp.o -o bpftrace arch/libarch.a ../libparser.a /usr/lib/libllvmbpfcodegen.a /usr/lib/libllvmipo.a /usr/lib/libllvmirreader.a /usr/lib/libllvmmcjit.a ../bcc-prefix/src/bcc-build/src/cc/libbpf.a ../bcc-prefix/src/bcc-build/src/cc/libbcc-loader-static.a ../bcc-prefix/src/bcc-build/src/cc/libbcc.a -lelf /usr/lib/libllvmasmprinter.a /usr/lib/libllvmdebuginfocodeview.a /usr/lib/libllvmdebuginfomsf.a /usr/lib/libllvmbpfdesc.a /usr/lib/libllvmbpfasmprinter.a /usr/lib/libllvmbpfinfo.a /usr/lib/libllvmselectiondag.a /usr/lib/libllvmcodegen.a /usr/lib/libllvmasmparser.a /usr/lib/libllvmbitwriter.a /usr/lib/libllvminstrumentation.a /usr/lib/libllvmlinker.a /usr/lib/libllvmscalaropts.a /usr/lib/libllvminstcombine.a /usr/lib/libllvmvectorize.a /usr/lib/libllvmtransformutils.a /usr/lib/libllvmexecutionengine.a /usr/lib/libllvmtarget.a /usr/lib/libllvmanalysis.a /usr/lib/libllvmprofiledata.a /usr/lib/libllvmruntimedyld.a /usr/lib/libllvmobject.a /usr/lib/libllvmbitreader.a /usr/lib/libllvmcore.a /usr/lib/libllvmmcparser.a /usr/lib/libllvmmc.a /usr/lib/libllvmsupport.a -lrt -ldl -lcurses -lpthread -lz -lm /usr/lib/libllvmdemangle.a /usr/lib/libllvmsupport.a(dynamiclibrary.cpp.o): in function `llvm::sys::dynamiclibrary::getpermanentlibrary(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)': (.text._zn4llvm3sys14dynamiclibrary19getpermanentlibraryepkcpnst7__cxx1112basic_stringicst11char_traitsicesaiceee+0x6e): warning: using 'dlopen' in statically linked applications requires @ runtime shared libraries glibc version used linking /usr/bin/ld: cannot find -lcurses collect2: error: ld returned 1 exit status
i suppose problem here:
/usr/bin/c++ -g -static
you use -static
, mean:
on systems support dynamic linking, prevents linking shared libraries. on other systems, option has no effect.
so successefull link need libcurses**.a**, not .so
Comments
Post a Comment