简体   繁体   English

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

[英]Running a 32-bit C code on a 64-bit system with Windows and a C compiler

I am trying to run ac code on my Windows laptop using the 64-bit MinGW compiler. 我试图使用64位MinGW编译器在Windows笔记本电脑上运行ac代码。 There are a few lines in the beginning of the code that direct to other files such as: 代码开头有几行指向其他文件,例如:

#include <openssl/e_os2.h>

When compiling the code the following error shows up: 编译代码时,出现以下错误:

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 made sure the files were in the correct locations, however the error still occurs. 我确保文件位于正确的位置,但是仍然发生错误。 I am thinking the error occurs because I am running a 32-bit binary on a 64-bit system. 我认为发生错误是因为我在64位系统上运行32位二进制文​​件。 Are there any ways to work around this issue given that I don't have a Linux system? 如果我没有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 believe you need a -I argument during compile. 我相信您在编译期间需要-I参数。 The headers are not located in the apps/ directory. 标头不在 apps/目录中。 Instead, they are located at ../include/ (relative to apps/ ). 相反,它们位于../include/ apps/ (相对于apps/ )。

So maybe a compile command like: 所以也许像这样的编译命令:

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

You will probably have additional problems because you need to link against libssl and libcrypto . 您可能会遇到其他问题,因为需要链接到libssllibcrypto Be aware you will still have work to do. 请注意,您仍有工作要做。


Here is what it looks like on Linux: 这是在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

Since the relative path is ../include/openssl/e_os2.h and the source file #include "openssl/e_os2.h" , you only need to include ../include using -I . 由于相对路径为../include/openssl/e_os2.h并且源文件#include "openssl/e_os2.h" ,因此您只需要使用-I包括../include


I am running a 32-bit binary on a 64-bit system... 我在64位系统上运行32位二进制文​​件...

You need to build OpenSSL as 32-bit. 您需要将OpenSSL构建为32位。 Run ./Configure LIST to get a list of MinGW targets. 运行./Configure LIST以获取MinGW目标的列表。 Then, configure with the appropriate triplet. 然后,配置适当的三元组。

You may need to add -m32 to the command line for your program. 您可能需要在程序的命令行中添加-m32

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 32位还是64位? 使用C代码 - 32-bit or 64-bit? Using C code 将 32 位应用程序转换为 C 中的 64 位应用程序 - Converting 32-bit Application Into 64-bit Application in C C 代码在 64 位 Ubuntu 14.04 中工作,但在 32 位 Ubuntu 14.04 中失败 - C code works in 64-bit Ubuntu 14.04 but fails in 32-bit Ubuntu 14.04 如何将 C 代码(或 32 位 dll 文件)编译成 64 位 dll 文件? - How to compile C code (or a 32-bit dll file) into 64-bit dll file? 如何在 32 位编译器中使用 64 位整数? - How to use 64-bit integers in 32-bit compiler? 64 位编译器结构填充与 32 位 arguments - 64-bit compiler struct padding with 32-bit arguments 将32位Windows驱动程序端口移植到64位Windows - Port 32-Bit Windows driver to 64-Bit Windows C:如果参数是从右往左推,为什么会出现下面的情况? (64位操作系统,32位程序) - C: If the parameters are pushed from right to left, why do the following happen? (64-bit operation system, 32-bit program) 32位代码在64位Linux计算机上运行 - 32-bit code runs on 64-bit linux machine C:在处理 32 位程序时,在 Windows 64 位计算机上将 int 转换为 int* 时出现警告 - C: Warning when casting int to int* on Windows 64-bit machine when working on 32-bit program
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM