0

I followed this stack overflow post to cross compile the openssl for arm. I was able to successfully do the steps, and I have an folder named as opensslArm in /home directory. However when I am trying to compile just a hello world program by using the following command

 arm-linux-gnueabi-gcc helloworld.c -o sslarm -static

It gets me this error.

/usr/include/openssl/e_os2.h:56:33: fatal error: openssl/opensslconf.h: No such file or directory

Following is the program that I had been using to compile (Nothing fancy, I just added a include statement to check whether cross compilation works before using real function)

#include <stdio.h>
#include <openssl/rsa.h> 

int main(){
    printf("Hello World\n");
    return 0; 
}

Could somebody please help me how to correctly compile to ARM with the linking of openssl libraries. I feel that I am not correctly linking the compiled openssl library. I tried searching in the internet and could not find an answer. Thank you in advance.

hEShaN
  • 551
  • 1
  • 9
  • 27
  • Try adding this to your `gcc` command: `--sysroot=` – kaylum Jan 25 '20 at 21:29
  • I tried with command `arm-linux-gnueabi-gcc helloworld.c -o sslarm -static --sysroot=/home/heshan` but still getting the same error – hEShaN Jan 25 '20 at 21:33
  • Are you sure the error is exactly the same? At a minimum the paths in the error should be different. It should not have `/usr/include`. The exact error matters so please double check. – kaylum Jan 25 '20 at 21:36
  • `helloworld.c:2:26: fatal error: openssl/rsa.h: No such file or directory` Exact error – hEShaN Jan 25 '20 at 21:40
  • How is that the same error? Please be more precise going forward so as not to waste time. Anyway, looks like you gave the wrong `sysroot` value or you haven't installed the `openssl` headers. Is there actually a `/home/heshan/openssl/rsa.h` file? If not, where did you install the openssl cross compiled build? – kaylum Jan 25 '20 at 21:49
  • sorry, I am just a beginner :( `/home/heshan/opensslArm/include/openssl` does contains the `rsa.h` file. I tried running `arm-linux-gnueabi-gcc helloworld.c -o sslarm -static --sysroot=/home/heshan/opensslArm/include/openssl` but gets the same `helloworld.c:2:26: fatal error: openssl/rsa.h: No such file or directory` error as before. – hEShaN Jan 25 '20 at 21:56
  • What `--prefix` value did you use when you built openssl and did you do `make install` when you built `openssl`? – kaylum Jan 25 '20 at 22:00
  • I used `--prefix=$HOME/opensslArm` – hEShaN Jan 25 '20 at 22:01
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/206641/discussion-between-kaylum-and-heshan). – kaylum Jan 25 '20 at 22:02

1 Answers1

0

Answer credits : @kaylum

arm-linux-gnueabi-gcc --sysroot=/home/heshan/opensslArm -I/home/heshan/opensslArm/include helloworld.c -o sslarm -static
hEShaN
  • 551
  • 1
  • 9
  • 27