请帮忙 - 我在论坛和stackoverflow上搜索了类似的内容,但没有找到。我能够成功构建x86(win32)模式,但是当我以x64为目标时,我遇到了链接错误。1> ------开始构建:项目:ZERO_CHECK,配置:Debug x64
...
2>;C:\Users\jcoffey\main\extlibs\curl-7.35.0\lib\smtp.c(2174):警告 C4267:“+ =”:从“size_t”转换为“long”,可能会丢失数据 2>pingpong.c 2>rtsp.c 2>curl_threads.c 2>warnless.c 2> hmac.c 2>curl_rtmp.c 2>openldap.c 2>curl_gethostname.c 2> gopher.c 2>生成代码... 2>编译... 2>idn_win32.c 2> http_negotiate_sspi.c 2>http_proxy.c 2>non-ascii.c 2>asyn-ares.c 2>asyn-thread.c 2>curl_gssapi.c 2>curl_ntlm.c 2>curl_ntlm_wb.c 2>curl_ntlm_core.c 2>curl_ntlm_msgs.c 2>curl_sasl.c 2> curl_multibyte.c 2>hostcheck.c 2>bundles.c 2>conncache.c 2> pipeline.c 2>dotdot.c 2>x509asn1.c 2>http2.c 2>生成 代码... 2>编译... 2>openssl.c 2>gtls.c 2>vtls.c 2>nss.c 2>qssl.c 2>polarssl.c 2>polarssl_threadlock.c 2>axtls.c 2> cyassl.c 2>curl_schannel.c 2>curl_darwinssl.c 2>gskit.c 2> 生成代码...
...
2>x64\Debug\file.obj : 致命错误 LNK1112: 模块 机器类型“x64”与目标机器类型“X86”冲突3>------ 开始构建:项目:curl,配置:Debug x64 ------3> 构建自定义规则 C:/Users/jcoffey/main/extlibs/curl-7.35.0/src/CMakeLists.txt
步骤1: 下载最新版本的CMake 2.8.12.2并更新Windows PATH环境变量(在我的情况下,我使用MINMGW32 bash shell提示符,但如果我使用本机Visual Studio 2013 x64 shell运行cmake也会出现完全相同的链接问题) $ export PATH=$PATH:/c/Program\ Files\ (x86)/CMake\ 2.8/bin
验证Windows上Cmake的路径和版本 $ cmake --version cmake version 2.8.12.2
步骤2: 将curl-7.35.0提取到文件夹c:\temp\curl-7.35.0中,并创建一个并行文件夹“c:\temp\curl-7.35.0 \build”。
步骤3: 更改到构建文件夹并运行Cmake,将Visual Studio 12作为所需的Visual Studio Solution / project组合进行定位 $ cmake -G "Visual Studio 12" ../curl-7.35.0
这会产生大量输出,但它确实创建了一个可工作的Visual Studio解决方案,其目标是X86机器类型。
$ cmake -G "Visual Studio 12" ../curl-7.35.0 -- The C compiler identification is MSVC 18.0.21005.1 -- Check for working C compiler using: Visual Studio 12 -- Check for working C compiler using: Visual Studio 12 -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done CMake Warning at CMakeLists.txt:47 (message): the curl cmake build system is poorly maintained. Be aware
-- curl version=[7.35.0] -- Looking for getch in ws2_32; -- Looking for getch in ws2_32; - found -- Looking for getch in winmm;ws2_32 -- Looking for getch in winmm;ws2_32 - found -- Looking for cldap_open in wldap32 -- Looking for cldap_open in wldap32 - found -- Looking for idna_to_ascii_lz in idn;winmm;ws2_32 -- Looking for idna_to_ascii_lz in idn;winmm;ws2_32 - not found -- Looking for ldap_init in ldap;winmm;ws2_32 -- Looking for ldap_init in ldap;winmm;ws2_32 - not found -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the sys tem variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR)
-- Looking for include file ws2tcpip.h -- Looking for include file ws2tcpip.h - found -- Looking for include files ws2tcpip.h, winsock2.h -- Looking for include files ws2tcpip.h, winsock2.h - found -- Looking for 3 include files ws2tcpip.h, ..., stdio.h -- Looking for 3 include files ws2tcpip.h, ..., stdio.h - found -- Looking for 4 include files ws2tcpip.h, ..., windows.h -- Looking for 4 include files ws2tcpip.h, ..., windows.h - found -- Looking for 5 include files ws2tcpip.h, ..., winsock.h -- Looking for 5 include files ws2tcpip.h, ..., winsock.h - found -- Looking for 6 include files ws2tcpip.h, ..., sys/filio.h -- Looking for 6 include files ws2tcpip.h, ..., sys/filio.h - not found -- Looking for 6 include files ws2tcpip.h, ..., sys/ioctl.h -- Looking for 6 include files ws2tcpip.h, ..., sys/ioctl.h - not found -- Looking for 6 include files ws2tcpip.h, ..., sys/resource.h -- Looking for 6 include files ws2tcpip.h, ..., sys/resource.h - not found -- Looking for 8 include files ws2tcpip.h, ..., sys/uio.h -- Looking for 8 include files ws2tcpip.h, ..., sys/uio.h - not found -- Looking for 8 include files ws2tcpip.h, ..., sys/un.h -- Looking for 8 include files ws2tcpip.h, ..., sys/un.h - not found -- Looking for 9 include files ws2tcpip.h, ..., arpa/tftp.h -- Looking for 9 include files ws2tcpip.h, ..., arpa/tftp.h - not found -- Looking for 9 include files ws2tcpip.h, ..., assert.h -- Looking for 9 include files ws2tcpip.h, ..., assert.h - found -- Looking for 10 include files ws2tcpip.h, ..., crypto.h -- Looking for 10 include files ws2tcpip.h, ..., crypto.h - not found -- Looking for 10 include files ws2tcpip.h, ..., des.h -- Looking for 10 include files ws2tcpip.h, ..., des.h - not found -- Looking for 10 include files ws2tcpip.h, ..., err.h -- Looking for 10 include files ws2tcpip.h, ..., err.h - not found -- Looking for 10 include files ws2tcpip.h, ..., errno.h -- Looking for 10 include files ws2tcpip.h, ..., errno.h - found -- Looking for 12 include files ws2tcpip.h, ..., gssapi/gssapi.h -- Looking for 12 include files ws2tcpip.h, ..., gssapi/gssapi.h - not found -- Looking for 12 include files ws2tcpip.h, ..., gssapi/gssapi_generic.h -- Looking for 12 include files ws2tcpip.h, ..., gssapi/gssapi_generic.h - not f ound -- Looking for 12 include files ws2tcpip.h, ..., gssapi/gssapi_krb5.h -- Looking for 12 include files ws2tcpip.h, ..., gssapi/gssapi_krb5.h - not foun d -- Looking for 12 include files ws2tcpip.h, ..., idn-free.h -- Looking for 12 include files ws2tcpip.h, ..., idn-free.h - not found -- Looking for 12 include files ws2tcpip.h, ..., ifaddrs.h -- Looking for 12 include files ws2tcpip.h, ..., ifaddrs.h - not found -- Looking for 13 include files ws2tcpip.h, ..., krb.h -- Looking for 13 include files ws2tcpip.h, ..., krb.h - not found -- Looking for 13 include files ws2tcpip.h, ..., libgen.h -- Looking for 13 include files ws2tcpip.h, ..., libgen.h - not found -- Looking for 13 include files ws2tcpip.h, ..., libssh2.h -- Looking for 13 include files ws2tcpip.h, ..., libssh2.h - not found -- Looking for 13 include files ws2tcpip.h, ..., limits.h -- Looking for 13 include files ws2tcpip.h, ..., limits.h - found -- Looking for 14 include files ws2tcpip.h, ..., locale.h -- Looking for 14 include files ws2tcpip.h, ..., locale.h - found -- Looking for 15 include files ws2tcpip.h, ..., netinet/tcp.h -- Looking for 15 include files ws2tcpip.h, ..., netinet/tcp.h - not found -- Looking for 15 include files ws2tcpip.h, ..., pem.h -- Looking for 15 include files ws2tcpip.h, ..., pem.h - not found -- Looking for 15 include files ws2tcpip.h, ..., poll.h -- Looking for 15 include files ws2tcpip.h, ..., poll.h - not found -- Looking for 15 include files ws2tcpip.h, ..., rsa.h -- Looking for 15 include files ws2tcpip.h, ..., rsa.h - not found -- Looking for 17 include files ws2tcpip.h, ..., ssl.h -- Looking for 17 include files ws2tcpip.h, ..., ssl.h - not found -- Looking for 17 include files ws2tcpip.h, ..., stdbool.h -- Looking for 17 include files ws2tcpip.h, ..., stdbool.h - found -- Looking for 21 include files ws2tcpip.h, ..., stropts.h -- Looking for 21 include files ws2tcpip.h, ..., stropts.h - not found -- Looking for 22 include files ws2tcpip.h, ..., tld.h -- Looking for 22 include files ws2tcpip.h, ..., tld.h - not found -- Looking for 23 include files ws2tcpip.h, ..., stddef.h -- Looking for 23 include files ws2tcpip.h, ..., stddef.h - found -- Looking for 26 include files ws2tcpip.h, ..., ldap.h -- Looking for 26 include files ws2tcpip.h, ..., ldap.h - not found -- Looking for 26 include files ws2tcpip.h, ..., sys/utsname.h -- Looking for 26 include files ws2tcpip.h, ..., sys/utsname.h - not found -- Looking for 26 include files ws2tcpip.h, ..., idna.h -- Looking for 26 include files ws2tcpip.h, ..., idna.h - not found -- LDAP_H not found CURL_DISABLE_LDAP set ON -- LDAP needs to be enabled to support LDAPS -- Check size of size_t -- Check size of size_t - done -- Check size of ssize_t -- Check size of ssize_t - failed -- Check size of long long -- Check size of long long - done -- Check size of long -- Check size of long - done -- Check size of short -- Check size of short - done -- Check size of int -- Check size of int - done -- Check size of __int64 -- Check size of __int64 - done -- Check size of time_t -- Check size of time_t - done -- Looking for basename -- Looking for basename - not found -- Looking for strncmpi -- Looking for strncmpi - not found -- Looking for alarm -- Looking for alarm - not found -- Looking for CRYPTO_cleanup_all_ex_data -- Looking for CRYPTO_cleanup_all_ex_data - not found -- Looking for gethostbyname -- Looking for gethostbyname - found -- Looking for strtoll -- Looking for strtoll - found -- Looking for _strtoi64 -- Looking for _strtoi64 - found -- Looking for strerror_r -- Looking for strerror_r - not found -- Looking for siginterrupt -- Looking for siginterrupt - not found -- Looking for fork -- Looking for fork - not found -- Looking for freeaddrinfo -- Looking for freeaddrinfo - found -- Looking for freeifaddrs -- Looking for freeifaddrs - not found -- Looking for pipe -- Looking for pipe - not found -- Looking for ftruncate -- Looking for ftruncate - not found -- Looking for getprotobyname -- Looking for getprotobyname - found -- Looking for getrlimit -- Looking for getrlimit - not found -- Looking for idn_free -- Looking for idn_free - not found -- Looking for idna_strerror -- Looking for idna_strerror - not found -- Looking for tld_strerror -- Looking for tld_strerror - not found -- Looking for setlocale -- Looking for setlocale - found -- Looking for setrlimit -- Looking for setrlimit - not found -- Looking for fcntl -- Looking for fcntl - not found -- Looking for ioctl -- Looking for ioctl - not found -- Looking for setsockopt -- Looking for setsockopt - found -- Looking for inet_pton -- Looking for inet_pton - not found -- Performing Curl Test HAVE_FCNTL_O_NONBLOCK -- Performing Curl Test HAVE_FCNTL_O_NONBLOCK - Failed -- Performing Curl Test HAVE_IOCTLSOCKET -- Performing Curl Test HAVE_IOCTLSOCKET - Success -- Performing Curl Test HAVE_IOCTLSOCKET_CAMEL -- Performing Curl Test HAVE_IOCTLSOCKET_CAMEL - Failed -- Performing Curl Test HAVE_IOCTLSOCKET_CAMEL_FIONBIO -- Performing Curl Test HAVE_IOCTLSOCKET_CAMEL_FIONBIO - Success -- Performing Curl Test HAVE_IOCTLSOCKET_FIONBIO -- Performing Curl Test HAVE_IOCTLSOCKET_FIONBIO - Success -- Performing Curl Test HAVE_IOCTL_FIONBIO -- Performing Curl Test HAVE_IOCTL_FIONBIO - Failed -- Performing Curl Test HAVE_IOCTL_SIOCGIFADDR -- Performing Curl Test HAVE_IOCTL_SIOCGIFADDR - Failed -- Performing Curl Test HAVE_SETSOCKOPT_SO_NONBLOCK -- Performing Curl Test HAVE_SETSOCKOPT_SO_NONBLOCK - Failed -- Performing Curl Test HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID -- Performing Curl Test HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID - Failed -- Performing Curl Test HAVE_SOCKLEN_T -- Performing Curl Test HAVE_SOCKLEN_T - Success -- Performing Curl Test HAVE_BOOL_T -- Performing Curl Test HAVE_BOOL_T - Success -- Performing Curl Test HAVE_FILE_OFFSET_BITS -- Performing Curl Test HAVE_FILE_OFFSET_BITS - Failed -- Performing Curl Test HAVE_GLIBC_STRERROR_R -- Performing Curl Test HAVE_GLIBC_STRERROR_R - Failed -- Performing Curl Test HAVE_POSIX_STRERROR_R -- Performing Curl Test HAVE_POSIX_STRERROR_R - Failed -- Check size of curl_off_t -- Check size of curl_off_t - failed -- Check size of socklen_t -- Check size of socklen_t - done -- Performing Test curl_cv_recv -- Performing Test curl_cv_recv - Success -- Performing Test int recv(int, void *, size_t, int) (curl_cv_func_recv_test) -- Performing Test int recv(int, void *, size_t, int) (curl_cv_func_recv_test) - Success -- Performing Test curl_cv_send -- Performing Test curl_cv_send - Success -- Performing Test int send(int, const void *, size_t, int) (curl_cv_func_send_t est) -- Performing Test int send(int, const void *, size_t, int) (curl_cv_func_send_t est) - Success -- Performing Test HAVE_MSG_NOSIGNAL -- Performing Test HAVE_MSG_NOSIGNAL - Failed -- Performing Test HAVE_STRUCT_TIMEVAL -- Performing Test HAVE_STRUCT_TIMEVAL - Success -- Performing Test HAVE_POLL_FINE -- Performing Test HAVE_POLL_FINE - Failed -- Check size of sig_atomic_t -- Check size of sig_atomic_t - done -- Performing Test HAVE_SIG_ATOMIC_T_NOT_VOLATILE -- Performing Test HAVE_SIG_ATOMIC_T_NOT_VOLATILE - Success -- Check size of struct sockaddr_storage -- Check size of struct sockaddr_storage - failed CMake Warning (dev) at tests/CMakeLists.txt:1 (add_subdirectory): The source directory
C:/Users/jcoffey/main/extlibs/curl-7.35.0/tests/libtest
does not contain a CMakeLists.txt file.
CMake does not support this case but it used to work accidentally and is being allowed for compatibility.
Policy CMP0014 is not set: Input directories must have CMakeLists.txt. Run "cmake --help-policy CMP0014" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at tests/CMakeLists.txt:2 (add_subdirectory):
The source directoryC:/Users/jcoffey/main/extlibs/curl-7.35.0/tests/server
does not contain a CMakeLists.txt file.
CMake does not support this case but it used to work accidentally and is being allowed for compatibility.
Policy CMP0014 is not set: Input directories must have CMakeLists.txt. Run "cmake --help-policy CMP0014" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done -- Generating done -- Build files have been written to: C:/Users/jcoffey/main/extlibs/curl-7.35.0-build
步骤4: 在Visual Studio中,使用配置管理器将目标类型更改为x64(我不得不选择一个新平台,我选择了X64并从Win32复制了设置)。这是一个非常简单明了的步骤,用于针对X64机器目标,为了避免混淆,我没有在这里包含详细的步骤。
步骤5: 从Visual Studio 2013中选择解决方案并重新构建所有内容,上面的输出将随之而来。
旁注:虽然我现在不需要SSL,但知道如何告诉CMake LIBSSL事物的位置会很好(我从http://www.confusedbycode.com/curl/下载了一个预构建库包(包括SSL和其他库的32位和64位版本),但这些是发布模式,我需要能够调试libCurl以查看我遇到的一些奇怪问题。我不擅长配置CMake,但它似乎是一个非常有前途的工具,适用于那些针对多个平台但更喜欢在Windows上开发的人。它肯定比gnu autotools容易。
Visual Studio 12
和Visual Studio 12 Win64
是不同的生成器。据我所知,您无法使用Visual Studio 12
生成项目并切换到x64
。请尝试使用cmake -G "Visual Studio 12 Win64" ../curl-7.35.0
。 - user2288008