alexcrichton / curl-rust

Rust bindings to libcurl
MIT License
1.02k stars 235 forks source link

Linking fails on Windows with Rust 1.12 MSVC 64-bit (unresolved external symbol __imp_sscanf) #132

Closed markusl closed 7 years ago

markusl commented 8 years ago

Just tried to compile a minimal test app on Windows Server 2012 R2 with Visual Studio 2015 and Rust 1.12 MSVC 64 bit installed and "cargo build" command fails with following log. Any ideas what to do?

error: linking with link.exe failed: exit code: 1120 | = note: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_a md64\link.exe" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\ \VC\lib\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0. 10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\w inv6.3\um\x64" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\Program Files\Rust stable MSVC 1.12\lib\rustlib\x86_64-pc-windows-msvc\lib" "C:\prod\version-notifie r\target\debug\version_notifier.0.o" "/OUT:C:\prod\version-notifier\target \debug\version_notifier.exe" "/OPT:REF,ICF" "/DEBUG" "/LIBPATH:C:\prod\versi on-notifier\target\debug\deps" "/LIBPATH:C:\prod\version-notifier\target\ debug\build\curl-sys-bed0e42e0a6d3a6b\out/lib" "/LIBPATH:C:\prod\version-no tifier\target\debug\build\libz-sys-abc54d15a9de5c22\out/lib" "/LIBPATH:C:\ Program Files\Rust stable MSVC 1.12\lib\rustlib\x86_64-pc-windows-msvc\lib" "C:\prod\version-notifier\target\debug\deps\librustc_serialize-3561541d79 c18212.rlib" "C:\prod\version-notifier\target\debug\deps\libslackhook-945 608af2b776cf3.rlib" "C:\prod\version-notifier\target\debug\deps\libchrono- 7342810e34d1c30d.rlib" "C:\prod\version-notifier\target\debug\deps\libnum- 1fa4854b44bb6a54.rlib" "C:\prod\version-notifier\target\debug\deps\libnum iter-50df698bc905252c.rlib" "C:\prod\version-notifier\target\debug\deps\li btime-750bfdd52feafcb7.rlib" "C:\prod\version-notifier\target\debug\deps\l ibkernel32-df86a08647459244.rlib" "C:\prod\version-notifier\target\debug\de ps\libhex-c4311871abf53460.rlib" "C:\prod\version-notifier\target\debug\de ps\libserde_json-b812e04ba18930d3.rlib" "C:\prod\version-notifier\target\de bug\deps\libdtoa-76ebb504ac31c05f.rlib" "C:\prod\version-notifier\target\d ebug\deps\libitoa-58ab3e11c7b36cd3.rlib" "C:\prod\version-notifier\target\ debug\deps\libcurl-6d2df8a9bcdb0495.rlib" "C:\prod\version-notifier\target\ \debug\deps\libquick_error-729eced693f2612d.rlib" "C:\prod\version-notifier\ \target\debug\deps\liblog-bf16bb9a4912b11d.rlib" "C:\prod\version-notifier\ \target\debug\deps\liburl-9a52f6193ca73c96.rlib" "C:\prod\version-notifier\ \target\debug\deps\libidna-82ebdb343d6c1855.rlib" "C:\prod\version-notifier \target\debug\deps\libunicode_bidi-04ad1da5552425fd.rlib" "C:\prod\version -notifier\target\debug\deps\libserde-a6e5b851ff800666.rlib" "C:\prod\versi on-notifier\target\debug\deps\libmatches-34170ac117690240.rlib" "C:\prod\v ersion-notifier\target\debug\deps\libcurl_sys-ef03a8e8ec4d17b2.rlib" "C:\pr od\version-notifier\target\debug\deps\libwinapi-0889532d327ff4e2.rlib" "C:\ \prod\version-notifier\target\debug\deps\libunicode_normalization-5de3a9c8f d8ddf4e.rlib" "C:\prod\version-notifier\target\debug\deps\liblibc-ad32fde1 bd850538.rlib" "C:\prod\version-notifier\target\debug\deps\libnuminteger- 52fdddf28cd8e924.rlib" "C:\prod\version-notifier\target\debug\deps\libnum traits-92bb90166cd1857c.rlib" "C:\Program Files\Rust stable MSVC 1.12\lib\ru stlib\x86_64-pc-windows-msvc\lib\libstd-40393716.rlib" "C:\Program Files\Ru st stable MSVC 1.12\lib\rustlib\x86_64-pc-windows-msvc\lib\libpanic_unwind- 40393716.rlib" "C:\Program Files\Rust stable MSVC 1.12\lib\rustlib\x86_64-p c-windows-msvc\lib\libunwind-40393716.rlib" "C:\Program Files\Rust stable MS VC 1.12\lib\rustlib\x86_64-pc-windows-msvc\lib\liblibc-40393716.rlib" "C:\ Program Files\Rust stable MSVC 1.12\lib\rustlib\x86_64-pc-windows-msvc\lib\ \librand-40393716.rlib" "C:\Program Files\Rust stable MSVC 1.12\lib\rustlib\ \x86_64-pc-windows-msvc\lib\libcollections-40393716.rlib" "C:\Program Files\ Rust stable MSVC 1.12\lib\rustlib\x86_64-pc-windows-msvc\lib\liballoc-40393 716.rlib" "C:\Program Files\Rust stable MSVC 1.12\lib\rustlib\x86_64-pc-win dows-msvc\lib\liballoc_system-40393716.rlib" "C:\Program Files\Rust stable M SVC 1.12\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_unicode-40393716.r lib" "C:\Program Files\Rust stable MSVC 1.12\lib\rustlib\x86_64-pc-windows- msvc\lib\libcore-40393716.rlib" "kernel32.lib" "ws2_32.lib" "wldap32.lib" "adv api32.lib" "normaliz.lib" "msvcrt.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "advapi32.lib" "msvcrt.lib" "compiler-rt.lib" = note: libcurl_sys-ef03a8e8ec4d17b2.rlib(formdata.obj) : error LNK2019: unres olved external symbol imp___iob_func referenced in function Curl_getformdata libcurl_sys-ef03a8e8ec4d17b2.rlib(mprintf.obj) : error LNK2001: unresolved exter nal symbol imp_iob_func libcurl_sys-ef03a8e8ec4d17b2.rlib(cookie.obj) : error LNK2001: unresolved extern al symbol _impiob_func libcurl_sys-ef03a8e8ec4d17b2.rlib(url.obj) : error LNK2001: unresolved external symbol imp_iob_func libcurl_sys-ef03a8e8ec4d17b2.rlib(mprintf.obj) : error LNK2019: unresolved exter nal symbol imp_sprintf referenced in function dprintf_formatf libcurl_sys-ef03a8e8ec4d17b2.rlib(ftp.obj) : error LNK2001: unresolved external symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(rtsp.obj) : error LNK2001: unresolved external symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(socks.obj) : error LNK2001: unresolved externa l symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(http_proxy.obj) : error LNK2001: unresolved ex ternal symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(http.obj) : error LNK2001: unresolved external symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(parsedate.obj) : error LNK2001: unresolved ext ernal symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(imap.obj) : error LNK2001: unresolved external symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(telnet.obj) : error LNK2001: unresolved extern al symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(cookie.obj) : error LNK2001: unresolved extern al symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(hostip.obj) : error LNK2001: unresolved extern al symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(url.obj) : error LNK2001: unresolved external symbol imp_sscanf libcurl_sys-ef03a8e8ec4d17b2.rlib(transfer.obj) : error LNK2001: unresolved exte rnal symbol __imp_sscanf C:\prod\version-notifier\target\debug\version_notifier.exe : fatal error LNK1120 : 3 unresolved externals

alexcrichton commented 8 years ago

Oh dear, this is quite suspicious! I can't say I've ever quite seen this before...

Just to confirm, you don't have any dirty build directories, right? If you start from a clean build you get these errors? If so, can you gist the full output build logs as well?

I wonder if perhaps VS tweaked its structure slightly in a way that we don't understand...

alexcrichton commented 7 years ago

IIRC I've seen this before when dealing with /MT vs /MD in C code, which I believe is all handled internally now, so I'm going to close this. Feel free to reopen though if problems crop up!