[英]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
. 您可能会遇到其他问题,因为需要链接到
libssl
和libcrypto
。 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.