[cmake-developers] Strange behaviour with check_library_exists on Windows
Sergei Nikulov
sergey.nikulov at gmail.com
Thu Jul 28 09:58:43 EDT 2016
2016-07-28 15:03 GMT+03:00 Ben Boeckel <ben.boeckel at kitware.com>:
> On Thu, Jul 28, 2016 at 13:33:35 +0300, Sergei Nikulov wrote:
>> -- Looking for CertFreeCertificateContext in crypt32;
>> -- Looking for CertFreeCertificateContext in crypt32; - found
>> crypt32 found
>
> These are tested using try_compile. Is there anything interesting under
> CMakeFiles/CMakeTmp/* when you configure with --debug-trycompile? It
> should contain the example files used and output from the compiler.
>
Ben,
Could you please provide me with information what should be
interesting for me exactly?
Here is my investigate
32-bit build
CL.command.1.tlog
-------------------------------------------------------------
^C:\PROGRAM FILES\CMAKE\SHARE\CMAKE-3.6\MODULES\CHECKFUNCTIONEXISTS.C
/c /Zi /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D
CHECK_FUNCTION_EXISTS=CertFreeCertificateContext /D _DEBUG /D
"CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise
/Zc:wchar_t /Zc:forScope /Zc:inline /Fo"CMTC_67614.DIR\DEBUG\\"
/Fd"CMTC_67614.DIR\DEBUG\VC140.PDB" /Gd /TC /analyze- C:\PROGRAM
FILES\CMAKE\SHARE\CMAKE-3.6\MODULES\CHECKFUNCTIONEXISTS.C
-------------------------------------------------------------
link.command.1.tlog is empty
Dumpbin output
-------------------------------------------------------------
E:\WORK\github\cmake_issue_checklibraryexist\build.32\CMakeFiles\CMakeTmp\cmTC_6
7614.dir\Debug>dumpbin /SYMBOLS CheckFunctionExists.obj
Microsoft (R) COFF/PE Dumper Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file CheckFunctionExists.obj
File Type: COFF OBJECT
COFF SYMBOL TABLE
000 01045E92 ABS notype Static | @comp.id
001 80000191 ABS notype Static | @feat.00
002 00000000 SECT1 notype Static | .drectve
Section length 30, #relocs 0, #linenums 0, checksum 0
004 00000000 SECT2 notype Static | .debug$S
Section length 270, #relocs 5, #linenums 0, checksum 0
006 00000000 SECT3 notype Static | .debug$T
Section length 88, #relocs 0, #linenums 0, checksum 0
008 00000000 SECT4 notype Static | .text$mn
Section length 2F, #relocs 2, #linenums 0, checksum ED2BC9DE
00A 00000000 UNDEF notype () External | _CertFreeCertificateContext
00B 00000000 SECT4 notype () External | _main
00C 00000000 UNDEF notype () External | __RTC_CheckEsp
00D 00000000 UNDEF notype () External | __RTC_InitBase
00E 00000000 UNDEF notype () External | __RTC_Shutdown
00F 00000000 SECT5 notype Static | .rtc$IMZ
Section length 4, #relocs 1, #linenums 0, checksum 0, select
ion 2 (pick any)
011 00000000 SECT5 notype Static | __RTC_InitBase.rtc$IMZ
012 00000000 SECT6 notype Static | .rtc$TMZ
Section length 4, #relocs 1, #linenums 0, checksum 0, select
ion 2 (pick any)
014 00000000 SECT6 notype Static | __RTC_Shutdown.rtc$TMZ
String Table Size = 0x7B bytes
Summary
270 .debug$S
88 .debug$T
30 .drectve
4 .rtc$IMZ
4 .rtc$TMZ
2F .text$mn
E:\WORK\github\cmake_issue_checklibraryexist\build.32\CMakeFiles\CMakeTmp\cmTC_6
7614.dir\Debug>
64-bit build
CL.command.1.tlog
-------------------------------------------------------------
^C:\PROGRAM FILES\CMAKE\SHARE\CMAKE-3.6\MODULES\CHECKFUNCTIONEXISTS.C
/c /Zi /W3 /WX- /Od /Ob0 /D WIN32 /D _WINDOWS /D
CHECK_FUNCTION_EXISTS=CertFreeCertificateContext /D _DEBUG /D
"CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise
/Zc:wchar_t /Zc:forScope /Zc:inline /Fo"CMTC_7909E.DIR\DEBUG\\"
/Fd"CMTC_7909E.DIR\DEBUG\VC140.PDB" /Gd /TC C:\PROGRAM
FILES\CMAKE\SHARE\CMAKE-3.6\MODULES\CHECKFUNCTIONEXISTS.C
-------------------------------------------------------------
link.command.1.tlog
-------------------------------------------------------------
^E:\WORK\GITHUB\CMAKE_ISSUE_CHECKLIBRARYEXIST\BUILD.64\CMAKEFILES\CMAKETMP\CMTC_7909E.DIR\DEBUG\CHECKFUNCTIONEXISTS.OBJ
/OUT:"E:\WORK\GITHUB\CMAKE_ISSUE_CHECKLIBRARYEXIST\BUILD.64\CMAKEFILES\CMAKETMP\DEBUG\CMTC_7909E.EXE"
/INCREMENTAL /NOLOGO KERNEL32.LIB USER32.LIB GDI32.LIB WINSPOOL.LIB
SHELL32.LIB OLE32.LIB OLEAUT32.LIB UUID.LIB COMDLG32.LIB ADVAPI32.LIB
CRYPT32.LIB /MANIFEST /MANIFESTUAC:"level='asInvoker'
uiAccess='false'" /manifest:embed /DEBUG
/PDB:"E:/WORK/GITHUB/CMAKE_ISSUE_CHECKLIBRARYEXIST/BUILD.64/CMAKEFILES/CMAKETMP/DEBUG/CMTC_7909E.PDB"
/SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT
/IMPLIB:"E:/WORK/GITHUB/CMAKE_ISSUE_CHECKLIBRARYEXIST/BUILD.64/CMAKEFILES/CMAKETMP/DEBUG/CMTC_7909E.LIB"
/MACHINE:X64 /machine:x64
CMTC_7909E.DIR\DEBUG\CHECKFUNCTIONEXISTS.OBJ
-------------------------------------------------------------
Dumpbin output
-------------------------------------------------------------
E:\WORK\github\cmake_issue_checklibraryexist\build.64\CMakeFiles\CMakeTmp\cmTC_7
909e.dir\Debug>dumpbin /SYMBOLS CheckFunctionExists.obj
Microsoft (R) COFF/PE Dumper Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file CheckFunctionExists.obj
File Type: COFF OBJECT
COFF SYMBOL TABLE
000 01045E92 ABS notype Static | @comp.id
001 80000190 ABS notype Static | @feat.00
002 00000000 SECT1 notype Static | .drectve
Section length 30, #relocs 0, #linenums 0, checksum 0
004 00000000 SECT2 notype Static | .debug$S
Section length 210, #relocs 4, #linenums 0, checksum 0
006 00000000 SECT3 notype Static | .debug$T
Section length 88, #relocs 0, #linenums 0, checksum 0
008 00000000 SECT4 notype Static | .text$mn
Section length 4F, #relocs 1, #linenums 0, checksum DF4B9C22
00A 00000000 UNDEF notype () External | CertFreeCertificateContext
00B 00000000 SECT4 notype () External | main
00C 00000000 UNDEF notype () External | _RTC_InitBase
00D 00000000 UNDEF notype () External | _RTC_Shutdown
00E 00000000 SECT4 notype Label | $LN4
00F 00000000 SECT5 notype Static | .xdata
Section length 8, #relocs 0, #linenums 0, checksum 85724CC6
011 00000000 SECT5 notype Static | $unwind$main
012 00000000 SECT6 notype Static | .pdata
Section length C, #relocs 3, #linenums 0, checksum F0BDD041
014 00000000 SECT6 notype Static | $pdata$main
015 00000000 SECT7 notype Static | .rtc$IMZ
Section length 8, #relocs 1, #linenums 0, checksum 0, select
ion 2 (pick any)
017 00000000 SECT7 notype Static | _RTC_InitBase.rtc$IMZ
018 00000000 SECT8 notype Static | .rtc$TMZ
Section length 8, #relocs 1, #linenums 0, checksum 0, select
ion 2 (pick any)
01A 00000000 SECT8 notype Static | _RTC_Shutdown.rtc$TMZ
String Table Size = 0x80 bytes
Summary
210 .debug$S
88 .debug$T
30 .drectve
C .pdata
8 .rtc$IMZ
8 .rtc$TMZ
4F .text$mn
8 .xdata
E:\WORK\github\cmake_issue_checklibraryexist\build.64\CMakeFiles\CMakeTmp\cmTC_7
909e.dir\Debug>
As I can see the difference is
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c
/Zi /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D
CHECK_FUNCTION_EXISTS=CertFreeCertificateContext /D _DEBUG /D
"CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise
/Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_67614.dir\Debug\\"
/Fd"cmTC_67614.dir\Debug\vc140.pdb" /Gd /TC /analyze-
/errorReport:queue "C:\Program
Files\CMake\share\cmake-3.6\Modules\CheckFunctionExists.c"
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl /c /Zi /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D
CHECK_FUNCTION_EXISTS=CertFreeCertificateContext /D _DEBUG /D
"CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise
/Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_67614.dir\Debug\\"
/Fd"cmTC_67614.dir\Debug\vc140.pdb" /Gd /TC /analyze-
/errorReport:queue "C:\Program
Files\CMake\share\cmake-3.6\Modules\CheckFunctionExists.c"
CheckFunctionExists.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe
/ERRORREPORT:QUEUE
/OUT:"E:\WORK\github\cmake_issue_checklibraryexist\build.32\CMakeFiles\CMakeTmp\Debug\cmTC_67614.exe"
/INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
crypt32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker'
uiAccess='false'" /manifest:embed /DEBUG
/PDB:"E:/WORK/github/cmake_issue_checklibraryexist/build.32/CMakeFiles/CMakeTmp/Debug/cmTC_67614.pdb"
/SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT
/IMPLIB:"E:/WORK/github/cmake_issue_checklibraryexist/build.32/CMakeFiles/CMakeTmp/Debug/cmTC_67614.lib"
/MACHINE:X86 /SAFESEH /machine:X86
cmTC_67614.dir\Debug\CheckFunctionExists.obj
CheckFunctionExists.obj : error LNK2019: unresolved external symbol
_CertFreeCertificateContext referenced in function _main
[E:\WORK\github\cmake_issue_checklibraryexist\build.32\CMakeFiles\CMakeTmp\cmTC_67614.vcxproj]
E:\WORK\github\cmake_issue_checklibraryexist\build.32\CMakeFiles\CMakeTmp\Debug\cmTC_67614.exe
: fatal error LNK1120: 1 unresolved externals
[E:\WORK\github\cmake_issue_checklibraryexist\build.32\CMakeFiles\CMakeTmp\cmTC_67614.vcxproj]
00A 00000000 UNDEF notype () External | _CertFreeCertificateContext
for 32-bit
vs
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\bin\x86_amd64\CL.exe /c /Zi /W3 /WX- /Od /Ob0 /D WIN32 /D
_WINDOWS /D CHECK_FUNCTION_EXISTS=CertFreeCertificateContext /D _DEBUG
/D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise
/Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_7909e.dir\Debug\\"
/Fd"cmTC_7909e.dir\Debug\vc140.pdb" /Gd /TC /errorReport:queue
"C:\Program Files\CMake\share\cmake-3.6\Modules\CheckFunctionExists.c"
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
cl /c /Zi /W3 /WX- /Od /Ob0 /D WIN32 /D _WINDOWS /D
CHECK_FUNCTION_EXISTS=CertFreeCertificateContext /D _DEBUG /D
"CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise
/Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_7909e.dir\Debug\\"
/Fd"cmTC_7909e.dir\Debug\vc140.pdb" /Gd /TC /errorReport:queue
"C:\Program Files\CMake\share\cmake-3.6\Modules\CheckFunctionExists.c"
CheckFunctionExists.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE
/OUT:"E:\WORK\github\cmake_issue_checklibraryexist\build.64\CMakeFiles\CMakeTmp\Debug\cmTC_7909e.exe"
/INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
crypt32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker'
uiAccess='false'" /manifest:embed /DEBUG
/PDB:"E:/WORK/github/cmake_issue_checklibraryexist/build.64/CMakeFiles/CMakeTmp/Debug/cmTC_7909e.pdb"
/SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT
/IMPLIB:"E:/WORK/github/cmake_issue_checklibraryexist/build.64/CMakeFiles/CMakeTmp/Debug/cmTC_7909e.lib"
/MACHINE:X64 /machine:x64
cmTC_7909e.dir\Debug\CheckFunctionExists.obj
cmTC_7909e.vcxproj ->
E:\WORK\github\cmake_issue_checklibraryexist\build.64\CMakeFiles\CMakeTmp\Debug\cmTC_7909e.exe
00A 00000000 UNDEF notype () External | CertFreeCertificateContext
for 64-bit
> Thanks,
>
> --Ben
So looks like name mangling differs for different targets.
--
Best Regards,
Sergei Nikulov
More information about the cmake-developers
mailing list