无法链接到`libPocoFoundation` Poco C ++ Framework

时间:2013-11-17 20:54:55

标签: c++ linker g++ shared-libraries poco

在我的Linux工作站上安装Poco后(我尝试了两者 - 来自apt-get软件包管理器的源代码和旧版本的最新版本)我无法链接到libPocoFoundation

当我尝试使用g++编译任何代码时,如果附加了-lPocoFoundation标记,我会收到如下错误:

$ g++ -std=c++0x -lPocoFoundation main.cpp -o main
    main.cpp:(.text+0xc6): undefined reference to `Poco::ThreadPool::joinAll()
    main.cpp:(.text+0xb1): undefined reference to `Poco::ThreadPool::available()

我明确检查了libPocoFoundation.so目录中是否存在/usr/local/lib/,这没关系。

为什么链接器找不到Poco共享库?

以下是来自readelf -s的DUMP的摘录:

Symbol table '.dynsym' contains 5732 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 00000000     0 FUNC    GLOBAL DEFAULT  UND waitpid@GLIBC_2.0 (2)
     2: 00000000     0 OBJECT  GLOBAL DEFAULT  UND _ZTIi@CXXABI_1.3 (3)
     3: 00000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_destroy@GLIBC_2.0 (2)
     4: 00000000     0 FUNC    GLOBAL DEFAULT  UND _ZNSo3putEc@GLIBCXX_3.4 (4)
     5: 00000000     0 FUNC    GLOBAL DEFAULT  UND chmod@GLIBC_2.0 (5)
     6: 00000000     0 FUNC    GLOBAL DEFAULT  UND getrusage@GLIBC_2.0 (5)
     7: 00000000     0 FUNC    GLOBAL DEFAULT  UND pthread_getspecific@GLIBC_2.0 (2)
     8: 00000000     0 FUNC    GLOBAL DEFAULT  UND _ZNSt15basic_streambufIcS@GLIBCXX_3.4 (4)
     9: 00000000     0 FUNC    GLOBAL DEFAULT  UND _Znwj@GLIBCXX_3.4 (4)
    10: 00000000     0 FUNC    GLOBAL DEFAULT  UND _ZNSt8__detail15_List_nod@GLIBCXX_3.4.15 (6)
   206: 00000000     0 FUNC    GLOBAL DEFAULT  UND pthread_join@GLIBC_2.0 (2)
   211: 00000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_rdlock@GLIBC_2.1 (8)
   223: 00000000     0 FUNC    GLOBAL DEFAULT  UND pthread_setschedparam@GLIBC_2.0 (2)
   224: 00000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_timedwait@GLIBC_2.3.2 (16)
   227: 00000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_wait@GLIBC_2.3.2 (16)
   246: 00000000     0 FUNC    GLOBAL DEFAULT  UND pthread_self@GLIBC_2.0 (2)

readelf -S

There are 29 section headers, starting at offset 0x1a1cdc:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .note.gnu.build-i NOTE            00000114 000114 000024 00   A  0   0  4
  [ 2] .gnu.hash         GNU_HASH        00000138 000138 00a4d8 04   A  3   0  4
  [ 3] .dynsym           DYNSYM          0000a610 00a610 016640 10   A  4   1  4
  [ 4] .dynstr           STRTAB          00020c50 020c50 03677f 00   A  0   0  1
  [ 5] .gnu.version      VERSYM          000573d0 0573d0 002cc8 02   A  3   0  2
  [ 6] .gnu.version_r    VERNEED         0005a098 05a098 000220 00   A  4   7  4
  [ 7] .rel.dyn          REL             0005a2b8 05a2b8 008700 08   A  3   0  4
  [ 8] .rel.plt          REL             000629b8 0629b8 003598 08   A  3  10  4
  [ 9] .init             PROGBITS        00065f50 065f50 00002e 00  AX  0   0  4
  [10] .plt              PROGBITS        00065f80 065f80 006b40 04  AX  0   0 16
  [11] .text             PROGBITS        0006cac0 06cac0 0d89d8 00  AX  0   0 16
  [12] .fini             PROGBITS        00145498 145498 00001a 00  AX  0   0  4
  [13] .rodata           PROGBITS        001454c0 1454c0 01c8e0 00   A  0   0 32
  [14] .eh_frame_hdr     PROGBITS        00161da0 161da0 00732c 00   A  0   0  4
  [15] .eh_frame         PROGBITS        001690cc 1690cc 024140 00   A  0   0  4
  [16] .gcc_except_table PROGBITS        0018d20c 18d20c 00bc6c 00   A  0   0  4
  [17] .init_array       INIT_ARRAY      001997e0 1997e0 000084 00  WA  0   0  4
  [18] .ctors            PROGBITS        00199864 199864 000008 00  WA  0   0  4
  [19] .dtors            PROGBITS        0019986c 19986c 000008 00  WA  0   0  4
  [20] .jcr              PROGBITS        00199874 199874 000004 00  WA  0   0  4
  [21] .data.rel.ro      PROGBITS        00199880 199880 005d14 00  WA  0   0 32
  [22] .dynamic          DYNAMIC         0019f594 19f594 000108 08  WA  4   0  4
  [23] .got              PROGBITS        0019f69c 19f69c 000950 04  WA  0   0  4
  [24] .got.plt          PROGBITS        0019fff4 19fff4 001ad8 04  WA  0   0  4
  [25] .data             PROGBITS        001a1acc 1a1acc 0000e4 00  WA  0   0  4
  [26] .bss              NOBITS          001a1bc0 1a1bb0 0007a8 00  WA  0   0 32
  [27] .comment          PROGBITS        00000000 1a1bb0 00002a 01  MS  0   0  1
  [28] .shstrtab         STRTAB          00000000 1a1bda 000101 00      0   0  1

1 个答案:

答案 0 :(得分:1)

尝试nm --demangle /usr/local/lib/libPocoFoundation.so并检查是否在那里定义了这些符号。

如果该符号在U输出的左栏中有nm,那么它是未定义的,您必须在其他地方找到它。