1

gcc と gnu ld を使用して、libfoo などのライブラリに依存するバイナリ (この場合は共有オブジェクト) をコンパイルしています。libfoo は、同じディレクトリに .a と .so の両方のファイルとして提供されます。

静的または動的のどちらが使用されているかを知ることはできますか?

4

2 に答える 2

3

私のLinux(Ubuntu 12.10ボックス)のGNUldは、最初にファイルをロードし.soます。

からman ld:

   -l namespec
   --library=namespec
       Add the archive or object file specified by namespec to the list of
       files to link.  This option may be used any number of times.  If
       namespec is of the form :filename, ld will search the library path
       for a file called filename, otherwise it will search the library
       path for a file called libnamespec.a.

       On systems which support shared libraries, ld may also search for
       files other than libnamespec.a.  Specifically, on ELF and SunOS
       systems, ld will search a directory for a library called
       libnamespec.so before searching for one called libnamespec.a.  (By
       convention, a ".so" extension indicates a shared library.)  Note
       that this behavior does not apply to :filename, which always
       specifies a file called filename.
于 2013-05-28T20:26:40.127 に答える