构建小型smb客户端的未定义参考

问题描述 投票:0回答:1

我有以下问题。我正在尝试在“libdsm”项目的基础上构建小型smb客户端。我已经构建了必要的库(libdsm.a和libtasn1.a)。我的smb客户端看到这些静态库,但链接器通知我有未定义的引用。这条消息对我来说很清楚,我已经验证了链接静态库的存在等等。我不知道它为什么会发生。链接器告诉它有什么理由吗?我可以用哪些工具更深入地分析这个问题?下面我展示了构建库的readelf信息

File: libdsm.a(md4.o)
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          15128 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           64 (bytes)
  Number of section headers:         23
  Section header string table index: 20


   17: 0000000000000000    97 FUNC    GLOBAL DEFAULT    1 smb_session_new
    18: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND calloc
    19: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND smb_buffer_init
    20: 0000000000000070    93 FUNC    GLOBAL DEFAULT    1 smb_session_destroy
    21: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND smb_session_share_clear
    22: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND asn1_delete_structure
    23: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND smb_buffer_free
    24: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND free
    25: 00000000000000d0   141 FUNC    GLOBAL DEFAULT    1 smb_session_set_creds
    26: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __strndup
    27: 0000000000000160   463 FUNC    GLOBAL DEFAULT    1 smb_session_connect
    28: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND smb_transport_nbt

和我的小smb客户端的目标文件:

ELF Header:


Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          2744 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           64 (bytes)
  Number of section headers:         15
  Section header string table index: 12


Symbol table '.symtab' contains 26 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
    12: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z15smb_session_newv
    13: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND inet_aton
    14: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z19smb_session_connectP1
    15: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z21smb_session_set_creds
    16: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z17smb_session_loginP11s
    17: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND puts
    18: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z16smb_tree_connectP11sm
    19: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z9smb_fopenP11smb_sessio
    20: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z9smb_freadP11smb_sessio
    21: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z10smb_fcloseP11smb_sess
    22: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z19smb_tree_disconnectP1
    23: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z19smb_session_destroyP1

我希望这些额外的信息会有用。

c++ c ubuntu gcc undefined-reference
1个回答
0
投票

alk,谢谢你的建议。将main.cpp重命名为main.c后,一切正常。对我来说,将我的客户端编译为c或c ++程序无关紧要。

© www.soinside.com 2019 - 2024. All rights reserved.