【问题标题】:Compile Openssl with MinGW on Windows - fatal error: openssl/md4.h: No such file or directory在 Windows 上使用 MinGW 编译 Openssl - 致命错误:openssl/md4.h:没有这样的文件或目录
【发布时间】:2013-07-12 16:36:02
【问题描述】:

我做到了:

  1. 已安装 MinGW+MSYS
  2. 已安装 ActivePerl
  3. 将我需要的所有内容添加到 PATH
  4. 下载最新的 Openssl 并解压到 C:\openssl
  5. 在我的cmd.exe 中做了:perl 配置mingw shared --prefix=/c/openssl
  6. make depand
  7. make
  8. make install
  9. cd 到 C:\cpp 我有我的 test.cpp :

test.cpp:

#include <stdio.h>
#include <string.h>
#include <openssl/md4.h>

int main()
{
    unsigned char digest[MD4_DIGEST_LENGTH];
    char string[] = "hello world";

    MD4((unsigned char*)&string, strlen(string), (unsigned char*)&digest);    

    char mdString[33];

    for(int i = 0; i < MD4_DIGEST_LENGTH; i++)
         sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]);

    printf("md4 digest: %s\n", mdString);

    return 0;
}

试图编译它并得到了这个:

C:\cpp>g++ test.cpp -lcrypto
test.cpp:3:25: fatal error: openssl/md4.h: No such file or directory
compilation terminated.

我现在该怎么办?

【问题讨论】:

    标签: c windows openssl mingw


    【解决方案1】:

    找到包含文件openssl/md4.h 的安装目录,并将该目录包含在命令中。

    例如,如果openssl/md4.h的完整路径是c:\openssl\include\openssl\md4.h,你的命令会变成:

    g++ -Ic:\openssl\include tst.cpp -lcrypto
    

    【讨论】:

    • 它给了我这个:C:\cpp&gt;g++ -Ic:\openssl-1.0.1e\include\ test.cpp -lcrypto c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lcrypto collect2: ld returned 1 exit status
    • @mazix 找到 libcrypto 二进制文件的路径,并使用 -L 选项将路径添加到 g++,方法与 -I 相同。
    猜你喜欢
    • 2017-09-19
    • 2012-10-13
    • 2018-10-02
    • 1970-01-01
    • 1970-01-01
    • 2020-04-13
    • 1970-01-01
    • 2022-07-21
    • 1970-01-01
    相关资源
    最近更新 更多