디버그 모드에서는 링크 문제가 없는데 릴리즈 모드에서 링크 에러가 발생했다. 해당 라이브러리를 쓰는 다른 프로젝트는 문제가 없어서 lib 경로 문제인가 싶어서 이리저리 확인해 봤으나 원인을 찾을 수가 없었다. lib 에 정말 symbol 이 있는지 확인해 보고 싶어졌다. 

Visual Studio 에 포함된 dumpbin 을 이용하면 된다.

dumpbin /symbols [lib 파일명]

Visual Studio 에 포함된 libcmt.lib 를 까보면 이런 식으로 보인다.

dumpbin /symbols libcmt.lib


File Type: LIBRARY


COFF SYMBOL TABLE000 00C7A09E ABS    notype       Static       | @comp.id
001 00000011 ABS    notype       Static       | @feat.00
002 00000000 UNDEF  notype       External     | _strcat003 00000000 UNDEF  notype       WeakExternal | __mbscat

    Default index        2 Alias record

String Table Size = 0x0 bytes

COFF SYMBOL TABLE
000 00C7A09E ABS    notype       Static       | @comp.id
001 00000011 ABS    notype       Static       | @feat.00
002 00000000 UNDEF  notype       External     | _strcpy
003 00000000 UNDEF  notype       WeakExternal | __mbscpy

    Default index        2 Alias record

String Table Size = 0x0 bytes

COFF SYMBOL TABLE
000 00C7A09E ABS    notype       Static       | @comp.id
001 00000011 ABS    notype       Static       | @feat.00

...(생략)

0A4 00000000 SECT33 notype       External     | ??_C@_01EEMJAFIK@?6?$AA@ (`string')
0A5 00000000 SECT34 notype       Static       | .rdata    Section length    3, #relocs    0, #linenums    0, checksum BB71EC38, selection    2 (pick any)

0A7 00000000 SECT34 notype       External     | ??_C@_02LLMPMKNF@?$DO?5?$AA@ (`string')

0A8 00000000 SECT35 notype       Static       | .rdata

    Section length    9, #relocs    0, #linenums    0, checksum F5F13728, selection    2 (pick any)

0AA 00000000 SECT35 notype       External     | ??_C@_08OMAHNMHJ@?6Data?3?5?$DM?$AA@ (`string')

0AB 00000000 SECT36 notype       Static       | .rdata
    Section length   2A, #relocs    0, #linenums    0, checksum 21F15550, selection    2 (pick any)

0AD 00000000 SECT36 notype       External     | ??_C@_0CK@DKGBICFE@?6Allocation?5number?5within?5this?5f@ (`string')

0AE 00000000 SECT37 notype       Static       | .rdata

    Section length    8, #relocs    0, #linenums    0, checksum AFE40ACB, selection    2 (pick any)

0B0 00000000 SECT37 notype       External     | ??_C@_07DFDJCKFN@?6Size?3?5?$AA@ (`string')
0B1 00000000 SECT38 notype       Static       | .rdata

    Section length    D, #relocs    0, #linenums    0, checksum 37DE352B, selection    2 (pick any)
0B3 00000000 SECT38 notype       External     | ??_C@_0N@MHFFIMFG@?6Address?3?50x?$AA@ (`string')

0B4 00000000 SECT39 notype       Static       | .rdata
    Section length   48, #relocs    0, #linenums    0, checksum DB7219C5, selection    2 (pick any)

0B6 00000000 SECT39 notype       External     | ??_C@_0EI@CLEPFNGI@Stack?5area?5around?5_alloca?5memory@ (`string')
0B7 00000000 SECT3A notype       Static       | .rdata

    Section length   1A, #relocs    0, #linenums    0, checksum B3C0476C, selection    2 (pick any)
0B9 00000000 SECT3A notype       External     | ??_C@_0BK@ODNDAGKB@?$CFs?$CFs?$CFp?$CFs?$CFzd?$CFs?$CFd?$CFs?$CFs?$CFs?$CFs?$CFs?$AA@ (`string')

0BA 00000000 SECT3B notype       Static       | .rdata
    Section length   34, #relocs    0, #linenums    0, checksum D4450C50, selection    2 (pick any)
0BC 00000000 SECT3B notype       External     | ??_C@_0DE@OHJBPMBP@A?5variable?5is?5being?5used?5without@ (`string')

0BD 00000000 UNDEF  notype       External     | ___security_cookie
0BE 00000000 SECT3C notype       Static       | .sxdata


...(생략)


  Summary


           4 .00cfg
           4 .CRT$XCA
          10 .CRT$XCAA
           4 .CRT$XCZ
           4 .CRT$XDA
           4 .CRT$XDZ
           4 .CRT$XIA
          10 .CRT$XIAA
          10 .CRT$XIAC
           8 .CRT$XIC
           4 .CRT$XIZ
           4 .CRT$XLA
           4 .CRT$XLC
           4 .CRT$XLD
           4 .CRT$XLZ
           4 .CRT$XPA
           4 .CRT$XPZ
           4 .CRT$XTA
           4 .CRT$XTZ
         3A9 .bss
          38 .data
          77 .data$r
         1D0 .debug$F
       A7880 .debug$S
        3454 .debug$T
         5BF .drectve
          AC .gfids$y
        742E .rdata
          18 .rdata$T
         120 .rdata$r
           4 .rtc$IAA
           4 .rtc$IZZ
           4 .rtc$TAA
           4 .rtc$TZZ
          3C .sxdata
       1B0E8 .text$mn
           F .text$mn$00
          1B .text$x
           1 .tls
          8C .tls$
           1 .tls$ZZZ
         2E0 .xdata$x
       6C630 _RDATA


0BC 00000000 SECT3B notype       External     | ??_C@_0DE@OHJBPMBP@A?5variable?5is?5being?5used?5without@ (`string')

위와 같이 External 이 표기된 부분을 디버그와 릴리즈 모드를 비교해봤더니 릴리즈 모드에서 링크에러가 발생한 symbol을 찾을 수 없었다.

문제가 생긴 함수는 constructor 였는데 명시적으로 구현을 안해서 그런건지 릴리즈에서만 링크 에러가 발생한 것이었다. 다행히 명시적으로 cpp 파일에 구현해주니 링크 에러는 해결되었다.

참고 : https://stackoverflow.com/questions/305287/how-to-see-the-contents-of-windows-library-lib

728x90

+ Recent posts