gpt4 book ai didi

c - 使用 Windows 和 C 编译器在 64 位系统上运行 32 位 C 代码

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:13:48 25 4
gpt4 key购买 nike

我正在尝试使用 64 位 MinGW 编译器在我的 Windows 笔记本电脑上运行 C 代码。代码开头有几行指向其他文件,例如:

#include <openssl/e_os2.h>

编译代码时出现以下错误:

C:\MinGW\bin\openssl\apps>gcc s_server.c
s_server.c:21:27: fatal error: openssl/e_os2.h: No such file or directory
#include <openssl/e_os2.h>
^
compilation terminated.

我确保文件位于正确的位置,但错误仍然存​​在。我认为发生错误是因为我在 64 位系统上运行 32 位二进制文​​件。鉴于我没有 Linux 系统,是否有任何方法可以解决此问题?

最佳答案

C:\MinGW\bin\openssl\apps>gcc s_server.c
s_server.c:21:27: fatal error: openssl/e_os2.h: No such file or directory
#include <openssl/e_os2.h>
^
compilation terminated.

我相信您在编译期间需要一个 -I 参数。 header 位于apps/ 目录中。相反,它们位于 ../include/(相对于 apps/)。

所以编译命令可能是这样的:

# from apps/ directory
gcc -I ../include/ s_server.c

您可能会遇到其他问题,因为您需要针对 libssllibcrypto 进行链接。请注意,您仍有工作要做。


这是它在 Linux 上的样子:

openssl$ find . -name e_os2.h
./include/openssl/e_os2.h

openssl$ cd apps

apps$ ls ../include/openssl/e_os2.h
../include/openssl/e_os2.h

由于相对路径是../include/openssl/e_os2.h和源文件#include "openssl/e_os2.h",你只需要使用 -I 包含 ../include


I am running a 32-bit binary on a 64-bit system...

您需要将 OpenSSL 构建为 32 位。运行 ./Configure LIST 以获取 MinGW 目标列表。然后,配置适当的三元组。

您可能需要将 -m32 添加到程序的命令行。

关于c - 使用 Windows 和 C 编译器在 64 位系统上运行 32 位 C 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56693869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com