[RK_2014_0920]ubuntu下,使用ldconfig解决:er

系统 2361 0

一、问题描述
编写一个与libpcap有关的程序:test_libpcap.cpp,编译test_libpcap.o成功。

注:之前已经成功安装libpcap,libpcap.so.1.5.3的路径是:/home/test/work/lib;
test_libpcap.cpp的路径是/home/test/work/test_libpcap。

运行test_libpcap.o出现以下提示:

      test_libpcap.o: error 
      
        while
      
       loading shared libraries: libpcap.so.
      
        1.5
      
      .
      
        3
      
      : cannot open shared 
      
        object
      
       file: No such file or directory
    

 

二、问题解决
注:以下操作均需要root权限
1.定位“libpcap.so.1.5.3”的路径

      # locate libpcap.so.
      
        1.5
      
      .
      
        3
      
      

/home/test/work/lib/libpcap.so.
      
        1.5
      
      .
      
        3
      
      

/usr/lib/i386-linux-gnu/libpcap.so.
      
        1.5
      
      .
      
        3
      
      

/usr/local/lib/libpcap.so.
      
        1.5
      
      .
      
        3
      
    

2.将上述路径中的“/home/test/work/lib/libpcap.so.1.5.3”加入“/etc/ld.so.conf.d”中

      # cd /etc/
      
        ld.so.conf.d

# ls

i686
      
      -linux-
      
        gnu.conf libc.conf

# echo 
      
      
        "
      
      
        # libpcap default configuration
      
      
        "
      
       >>
      
         libpcap.conf

# echo 
      
      
        "
      
      
        /home/test/work/lib/libpcap.so.1.5.3
      
      
        "
      
       >> libpcap.conf
    

3.运行ldconfig命令

      # /sbin/ldconfig
    

4.再次运行test_libpcap.o,成功。

 

三、参考信息

1.man locate

        locate(
        
          1
        
        )                   General Commands Manual                  locate(
        
          1
        
        
          )







NAME

       locate 
        
        -
        
           find files by name





SYNOPSIS

       locate [OPTION]... PATTERN...





DESCRIPTION

       locate  reads  one or more databases prepared by updatedb(
        
        
          8
        
        
          ) and writes

       file names matching at least one of the PATTERNs  to  standard  output,

       one per line.



       If  
        
        --regex 
        
          is
        
        
           not specified, PATTERNs can contain globbing characters.

       If any PATTERN contains no globbing characters, locate  behaves  
        
        
          as
        
        
          if
        
        
          

       the pattern were 
        
        *PATTERN*
        
          .



       By 
        
        
          default
        
        , locate does not check whether files found 
        
          in
        
        
           database still

       exist (but it does require all parent directories to exist 
        
        
          if
        
        
           the data‐

       
        
        
          base
        
          was built with --require-
        
          visibility no).  locate can never report

       files created after the most recent update of the relevant database.





EXIT STATUS

       locate exits with status 
        
        
          0
        
        
          if
        
         any match was  found  or  
        
          if
        
        
            locate  was

       invoked  with  one  of the 
        
        --limit 
        
          0
        
        , --help, --statistics or --
        
          version

       options.  If no match was found  or  a  fatal  error  was  encountered,

       locate exits with status 
        
        
          1
        
        
          .



       Errors  encountered 
        
        
          while
        
        
           reading a database are not fatal, search con‐

       tinues 
        
        
          in
        
         other specified databases, 
        
          if
        
        
           any.





OPTIONS

       
        
        -A, --
        
          all

              Print only entries that match all PATTERNs instead of  requiring

              only one of them to match.





       
        
        -b, --
        
          basename

              Match  only  the 
        
        
          base
        
        
           name against the specified patterns.  This

              
        
        
          is
        
         the opposite of --
        
          wholename.





       
        
        -c, --
        
          count

              Instead of writing file names on standard output, write the num‐

              ber of matching entries only.





       
        
        -d, --
        
          database DBPATH

              Replace  the  
        
        
          default
        
         database with DBPATH.  DBPATH 
        
          is
        
         a :-
        
          sepa‐

              rated list of database file names.  If more than one  
        
        --
        
          database

              option  
        
        
          is
        
          specified,  the resulting path 
        
          is
        
        
           a concatenation of

              the separate paths.



              An empty database file name 
        
        
          is
        
         replaced by the 
        
          default
        
        
           database.

              A  database file name 
        
        -
        
           refers to the standard input.  Note that

              a database can be read 
        
        
          from
        
        
           the standard input only once.





       
        
        -e, --
        
          existing

              Print only entries that refer to  files  existing  at  the  time

              locate 
        
        
          is
        
        
           run.





       
        
        -L, --
        
          follow

              When  checking  whether files exist (
        
        
          if
        
         the --existing option 
        
          is
        
        
          

              specified), follow trailing symbolic links.  This causes  broken

              symbolic links to be omitted 
        
        
          from
        
        
           the output.



              This  
        
        
          is
        
          the  
        
          default
        
        
            behavior.  The opposite can be specified

              
        
        
          using
        
         --
        
          nofollow.





       
        
        -h, --
        
          help

              Write a summary of the available options to standard output  and

              exit successfully.





       
        
        -i, --ignore-
        
          case
        
        
          

              Ignore 
        
        
          case
        
        
           distinctions when matching patterns.





       
        
        -l, --limit, -
        
          n LIMIT

              Exit  successfully  after finding LIMIT entries.  If the 
        
        --
        
          count

              option 
        
        
          is
        
         specified, the resulting  count  
        
          is
        
        
            also  limited  to

              LIMIT.





       
        
        -m, --
        
          mmap

              Ignored, 
        
        
          for
        
        
           compatibility with BSD and GNU locate.





       
        
        -P, --nofollow, -
        
          H

              When  checking  whether files exist (
        
        
          if
        
         the --existing option 
        
          is
        
        
          

              specified), 
        
        
          do
        
        
           not follow trailing symbolic links.  This  causes

              broken symbolic links to be reported like other files.



              This 
        
        
          is
        
         the opposite of --
        
          follow.





       
        
        -
        
          0
        
        , --
        
          null
        
        
          

              Separate  the  entries  on  output 
        
        
          using
        
        
           the ASCII NUL character

              instead of writing each entry on a separate line.   This  option

              
        
        
          is
        
          designed  
        
          for
        
         interoperability with the --
        
          null
        
        
           option of GNU

              xargs(
        
        
          1
        
        
          ).





       
        
        -S, --
        
          statistics

              Write statistics about each read  database  to  standard  output

              instead of searching 
        
        
          for
        
        
           files and exit successfully.





       
        
        -q, --
        
          quiet

              Write  no  messages  about  errors encountered 
        
        
          while
        
        
           reading and

              processing databases.





       
        
        -r, --
        
          regexp REGEXP

              Search 
        
        
          for
        
         a basic regexp REGEXP.  No PATTERNs  are  allowed  
        
          if
        
        
          this
        
          option  
        
          is
        
         used, but 
        
          this
        
        
           option can be specified multiple

              times.





       
        
        --
        
          regex

              Interpret all PATTERNs 
        
        
          as
        
        
           extended regexps.





       
        
        -s, --
        
          stdio

              Ignored, 
        
        
          for
        
        
           compatibility with BSD and GNU locate.





       
        
        -V, --
        
          version

              Write information about the version and  license  of  locate  on

              standard output and exit successfully.





       
        
        -w, --
        
          wholename

              Match only the whole path name against the specified patterns.



              This  
        
        
          is
        
          the  
        
          default
        
        
            behavior.  The opposite can be specified

              
        
        
          using
        
         --
        
          basename.





EXAMPLES

       To search 
        
        
          for
        
         a file named exactly NAME (not *NAME*
        
          ), use

              locate 
        
        -b 
        
          '
        
        
          \NAME
        
        
          '
        
        
          

       Because \ 
        
        
          is
        
         a globbing character, 
        
          this
        
         disables the 
        
          implicit
        
        
            replace‐

       ment of NAME by 
        
        *NAME*
        
          .





FILES

       
        
        /
        
          var
        
        /lib/mlocate/
        
          mlocate.db

              The database searched by 
        
        
          default
        
        
          .





ENVIRONMENT

       LOCATE_PATH

              Path  to  additional databases, added after the 
        
        
          default
        
        
           database

              or the databases specified 
        
        
          using
        
         the --
        
          database option.





NOTES

       The order 
        
        
          in
        
         which the requested databases are  processed  
        
          is
        
        
            unspeci‐

       fied,  which  allows  locate  to reorder the database path 
        
        
          for
        
        
           security

       reasons.



       locate attempts to be compatible to slocate (without the  options  used

       
        
        
          for
        
          creating  databases)  and  GNU locate, 
        
          in
        
         that order.  This 
        
          is
        
        
           the

       reason 
        
        
          for
        
         the impractical 
        
          default
        
         --follow option and 
        
          for
        
        
           the  confus‐

       ing 
        
        
          set
        
         of --regex and --
        
          regexp options.



       The  
        
        
          short
        
          spelling  of  the  -r option 
        
          is
        
        
           incompatible to GNU locate,

       
        
        
          where
        
         it corresponds to the --regex option.  Use the 
        
          long
        
        
           option  names

       to avoid confusion.



       The  LOCATE_PATH  environment variable replaces the 
        
        
          default
        
         database 
        
          in
        
        
          

       BSD and GNU locate, but it 
        
        
          is
        
         added to other databases 
        
          in
        
        
          this
        
        
            imple‐

       mentation and slocate.





AUTHOR

       Miloslav Trmac 
        
        <mitr@redhat.com>
        
          





SEE ALSO

       updatedb(
        
        
          8
        
        
          )







mlocate                            Sep 
        
        
          2012
        
                                  locate(
        
          1
        
        )
      
View Code

2.man ldconfig

        LDCONFIG(
        
          8
        
        )                Linux Programmer
        
          '
        
        
          s Manual               LDCONFIG(8)
        
        
          





NAME

       ldconfig 
        
        - configure dynamic linker run-
        
          time bindings



SYNOPSIS

       
        
        /sbin/ldconfig  [  -nNvXV ] [ -f conf ] [ -C cache ] [ -
        
          r root ] direc‐

       tory ...

       
        
        /sbin/ldconfig -l [ -
        
          v ] library ...

       
        
        /sbin/ldconfig -
        
          p



DESCRIPTION

       ldconfig creates the necessary links  and  cache  to  the  most  recent

       shared  libraries  found  
        
        
          in
        
        
            the  directories specified on the command

       line, 
        
        
          in
        
         the file /etc/ld.so.conf, and 
        
          in
        
         the trusted directories (/
        
          lib

       and  
        
        /usr/lib).  The cache 
        
          is
        
         used by the run-time linker, ld.so or ld-
        
          

       linux.so.  ldconfig checks the header and filenames of the libraries it

       encounters  when  determining  which  versions  should have their links

       updated.



       ldconfig will attempt to deduce the type of ELF libs  (i.e.,  libc5  or

       libc6
        
        /glibc)  based  on  what  C  libs,  
        
          if
        
        
           any, the library was linked

       against.



       Some existing libs 
        
        
          do
        
        
           not  contain  enough  information  to  allow  the

       deduction  of  their  type.  Therefore, the 
        
        /etc/
        
          ld.so.conf file format

       allows the specification of an expected type.  This 
        
        
          is
        
          used  only  
        
          for
        
        
          

       those   ELF   libs   which   we  can  not  work  
        
        
          out
        
        .   The  format  
        
          is
        
        
          "
        
        
          dirname=TYPE
        
        
          "
        
        , 
        
          where
        
        
           TYPE can be libc4, libc5, or libc6.  (This syntax

       also works on the command line.)  Spaces are not allowed.  Also see the

       
        
        -p option.  ldconfig should normally be run by the superuser 
        
          as
        
        
           it  may

       require write permission on some root owned directories and files.



OPTIONS

       
        
        -
        
          v     Verbose  mode.   Print  current version number, the name of each

              directory 
        
        
          as
        
         it 
        
          is
        
        
           scanned, and  any  links  that  are  created.

              Overrides quiet mode.



       
        
        -n     Only  process  directories specified on the command line.  Don
        
          '
        
        
          t
        
        

              process the trusted directories (/lib and  /usr/
        
          lib)  nor  those

              specified 
        
        
          in
        
         /etc/ld.so.conf.  Implies -
        
          N.



       
        
        -N     Don
        
          '
        
        
          t rebuild the cache.  Unless -X is also specified, links are
        
        
                        still updated.



       
        
        -X     Don
        
          '
        
        
          t update links.  Unless -N is also specified, the  cache  is
        
        
                        still rebuilt.



       
        
        -
        
          f conf

              Use conf instead of 
        
        /etc/
        
          ld.so.conf.



       
        
        -
        
          C cache

              Use cache instead of 
        
        /etc/
        
          ld.so.cache.



       
        
        -
        
          r root

              Change to and use root 
        
        
          as
        
        
           the root directory.



       
        
        -l     Library mode.  Manually link individual libraries.  Intended 
        
          for
        
        
          

              use by experts only.



       
        
        -p     Print the lists of directories and candidate libraries stored 
        
          in
        
        
          

              the current cache.



FILES

       
        
        /lib/ld.so          run-time linker/
        
          loader

       
        
        /etc/ld.so.conf     File  containing  a list of colon, space, tab, 
        
          new
        
        
          ‐

                           line, or comma
        
        -separated directories  
        
          in
        
        
            which  to

                           search 
        
        
          for
        
        
           libraries.

       
        
        /etc/
        
          ld.so.cache    File  containing an ordered list of libraries found

                           
        
        
          in
        
         the directories specified 
        
          in
        
         /etc/ld.so.conf, 
        
          as
        
        
          

                           well 
        
        
          as
        
         those found 
        
          in
        
         /lib and /usr/
        
          lib.



SEE ALSO

       ldd(
        
        
          1
        
        ), ld.so(
        
          8
        
        
          )



COLOPHON

       This  page  
        
        
          is
        
          part of release 
        
          3.54
        
         of the Linux man-
        
          pages project.  A

       description of the project, and information about reporting  bugs,  can

       be found at http:
        
        
          //
        
        
          www.kernel.org/doc/man-pages/.
        
        
          





GNU                               
        
        
          2012
        
        -
        
          05
        
        -
        
          10
        
                               LDCONFIG(
        
          8
        
        )
      
View Code

 

四、原文网址[原文发布于2014-09-20 09:56]

  http://www.cnblogs.com/tom-and-jerry/p/3978092.html

 

【完结】                      

[RK_2014_0920]ubuntu下,使用ldconfig解决:error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or directory


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论