在Windows

时间:2018-01-26 00:38:58

标签: c++ curl gcc openssl

  • Windows 7 64位
  • Mingw64 with gcc 7.2.0
  • Msys2 64bit(使用pacman进行最新升级)用于编译开源库
  • 我的代码块 程序,使用mingw64及其gcc作为我的工具链

我一直试图将libcurl与ssl和ssh2静态链接,但发现了一堆未定义的引用。

我的Mingw64安装在C:/ mingw64上,Windows路径包含C:/ mingw64 / bin

我使用Msys2使用以下选项编译openssl: ./config no-idea no-mdc2 no-rc5 使依赖&&制造&& make install 然后我将libssl.a和libcrypto.a复制到C:/ mingw64 / opt / lib 以及适当的包含文件到C:/ mingw64 / opt / include

我使用这些选项类似地编译和安装ssh2 ./configure --disable-shared --enable-static --disable-examples-build 制造&& make install 然后将libssh2.a复制到C:/ mingw64 / opt / lib

我使用这些选项编译并安装curl ./configure --enable-crypto-auth --with-ssl --with-libssh2 --disable-shared --enable-static 制造&& make install 然后将libcurl.a复制到C:/ mingw64 / opt / lib

在我的程序中我定义了这些: CURL_STATICLIB _WIN32_WINNT = 0x0601 并按顺序链接这些库: libcurl.a libssh2.a libws2_32.a libssl.a libcrypto.a libwldap32.a ..我的程序需要的其他库

链接中的一些错误是:

  • C:\ MingW64 \ opt \ lib \ libcurl.a(libcurl_la-setopt.o):setopt.c undefined 引用`__imp ___ acrt_iob_func'
  • C:\ MingW64 \ opt \ lib \ libcurl.a(libcurl_la-url.o):url.c undefined 引用`__imp ___ acrt_iob_func'
  • C:\ MingW64 \选择\ lib中\ libcurl.a(libcurl_la-mprintf.o):mprintf.c 未定义的引用`__imp ___ acrt_iob_func'
  • C:\ MingW64 \选择\ lib中\ libcurl.a(libcurl_la-formdata.o):formdata.c 未定义的引用`__imp ___ acrt_iob_func'
  • C:\ MingW64 \ opt \ lib \ libssl.a(t1_enc.o):t1_enc.c more undefined 引用`__imp ___ acrt_iob_func'遵循
  • C:\ MingW64 \ opt \ lib \ libcrypto.a(bss_sock.o):bss_sock.c undefined 参考`__imp_shutdown'
  • C:\ MingW64 \ opt \ lib \ libcrypto.a(bss_conn.o):bss_conn.c undefined 参考`__imp_htonl'
  • C:\ MingW64 \ opt \ lib \ libcrypto.a(b_sock.o):b_sock.c undefined reference 到`__imp_gethostbyname'
  • C:\ MingW64 \ opt \ lib \ libcrypto.a(b_sock.o):b_sock.c undefined reference 到'__imp_htonl'
  • C:\ MingW64 \选择\ lib中\ libcrypto.a(pem_lib.o):pem_lib.c 未定义的引用`__imp ___ acrt_iob_func'
  • C:\ MingW64 \ opt \ lib \ libcrypto.a(ui_openssl.o):ui_openssl.c undefined 引用`__imp ___ acrt_iob_func'
  • C:\ MingW64 \ opt \ lib \ libcrypto.a(e_capi.o):e_capi.c undefined reference 到`__imp_CertFreeCertificateContext'

我猜它与openssl有关和/或我想要curl静态的事实,因为当我编译curl而没有ssl并且我的程序与curl静态链接时,它工作,如果我编译程序链接到libcurl.dll.a和curl有ssl它也可以工作(但在运行时需要curl dll)。我希望curl使用ssl,并让整个程序静态链接。我该如何解决我的问题?也许Mingw64和Msys2没有使用完全相同的工具链,如果情况如此,我如何验证并修复它?

0 个答案:

没有答案
相关问题