【问题标题】:Building a program (sscep) against OpenSSL: undefined reference to '[...]'针对 OpenSSL 构建程序 (sscep):未定义对“[...]”的引用
【发布时间】:2012-05-10 12:03:08
【问题描述】:

我正在尝试为 Windows 构建一个名为 sscep (http://www.klake.org/~jt/sscep/) 的工具。它不是本机运行的,我有一个“补丁”可以更改 sscep 以使其在 Windows 上编译。 应用补丁后,它编译完美,但链接器拧紧了。我在 minGW/msys 中使用 gcc 最初的消息是它找不到加密库,所以我用“-L../openssl-mingw/lib”添加了库,然后没有再产生任何错误。我的命令中还有命令行开关 -lcrypto:gcc -L../openssl-mingw/lib -lcrypto sscep.o init.o net.o sceputils.o pkcs7.o ias.o fileutils.o -o sscep。在这个目录中是一个 libcrypto.a。 OpenSSL 本身是用完全相同的编译器编译的,只是运行./config && make && make test && make install。此外,源代码是使用 minGW tar 而非 7-zip 提取的。

遵循所有文档后,这是我的(截断的)输出:

sscep.o:sscep.c:(.text+0x83): undefined reference to `WSAStartup@8'
sscep.o:sscep.c:(.text+0xa5): undefined reference to `WSACleanup@0'
sscep.o:sscep.c:(.text+0x3d5): undefined reference to `BIO_new_mem_buf'
sscep.o:sscep.c:(.text+0x3e0): undefined reference to `ASN1_INTEGER_new'
sscep.o:sscep.c:(.text+0x414): undefined reference to `a2i_ASN1_INTEGER'
sscep.o:sscep.c:(.text+0x432): undefined reference to `ASN1_INTEGER_to_BN'
sscep.o:sscep.c:(.text+0x448): undefined reference to `BN_bn2dec'
sscep.o:sscep.c:(.text+0xb7e): undefined reference to `EVP_des_cbc'
sscep.o:sscep.c:(.text+0xbaf): undefined reference to `EVP_bf_cbc'
sscep.o:sscep.c:(.text+0xbda): undefined reference to `EVP_des_cbc'
sscep.o:sscep.c:(.text+0xc02): undefined reference to `EVP_des_ede3_cbc'
sscep.o:sscep.c:(.text+0xc48): undefined reference to `EVP_md5'
sscep.o:sscep.c:(.text+0xc79): undefined reference to `EVP_md5'
sscep.o:sscep.c:(.text+0xca1): undefined reference to `EVP_sha1'

这适用于那里的每个文件,并且应该是每个调用的函数。 在此处和 google 搜索导致缺少库,但从上面省略了 -L 指令,我收到另一个关于找不到 libcrypto 的错误。所以我假设图书馆确实找到了,但地址有些错误或其他什么?

我的编译器/链接器知识到此结束。 如果补丁有可能对此负责(我不相信,因为这些都是 openssl 函数并且可以编译),那么我可以为您提供。

编辑:我应该提供任何信息以便有人可以帮助我吗?如果这有什么不同的话,openssl 的版本是 1.0.1。 关于这个主题:如果它确实有所作为,是否会因为版本错误而发生此错误。据我了解链接器理论,此错误不应源自错误的版本,除非 所有 以下函数被不同名称的函数替换(但编译器会抱怨,我猜?)。

另一个补充:由于我在 64 位 Windows 7 上,我尝试使用 -m32 标志编译它,但这没有帮助。我假设由于 mingw 已经只有 32 位,我什至无法构建 x64。另一个问题是,我在 AMD Opteron 上的虚拟化环境中运行,而 openssl 是使用命令“-march=i486”构建的,这是否是一个问题?

【问题讨论】:

    标签: windows gcc openssl mingw


    【解决方案1】:

    在一些帮助下,我终于可以解决这个问题了!这是顺序问题和缺少库的问题。这个组合害死我了。

    库必须是-lcrypto -lws2_32 -lgdi32 而不仅仅是-lcrypto。此外,我必须在目标文件之后追加库,所以:$(CC) $(CFLAGS) $(OBJS) -lcrypto -lws2_32 -lgdi32 -o $(PROG) 是正确的 make 行。

    最后,它编译得很好。我什至不需要任何架构标志等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-16
      • 2012-08-14
      • 2014-04-06
      • 1970-01-01
      • 2018-08-24
      • 2018-09-02
      • 2017-05-09
      相关资源
      最近更新 更多