1

I am trying to run a c code on my Windows laptop using the 64-bit MinGW compiler. 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. Are there any ways to work around this issue given that I don't have a Linux system?

Shahnila
  • 13
  • 2
  • [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/install-win10). Visual Studio Community. Exactly what do you want to link openssl with? – Elliott Frisch Jun 20 '19 at 21:27
  • Also see [How to modify code for s_client?](https://stackoverflow.com/q/28313713/608639) It takes you through compiling a new version of `s_client.c` as a stand-alone program. You might also be interested in [How to run different 'modes' of a program based on command line parameters?](https://stackoverflow.com/q/27660746/608639) – jww Jun 20 '19 at 23:23

1 Answers1

0
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. The headers are not located in the apps/ directory. Instead, they are located at ../include/ (relative to 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. Be aware you will still have work to do.


Here is what it looks like on 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.


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

You need to build OpenSSL as 32-bit. Run ./Configure LIST to get a list of MinGW targets. Then, configure with the appropriate triplet.

You may need to add -m32 to the command line for your program.

jww
  • 97,681
  • 90
  • 411
  • 885
  • The e_os2.h file is located in an `include` folder outside of `apps/` but there is a folder inside `apps/` that is also called `include`. Will it work to copy and paste the e_os2.h file from one `include` folder to the other within `apps/`? – Shahnila Jun 21 '19 at 13:54