# Mender client cross compile for ARM - openssl dependency

**URL:** <https://hub.mender.io/t/mender-client-cross-compile-for-arm-openssl-dependency/3574>\
**Category:** General Discussions\
**Created:** [April 30, 2021, 12:28pm UTC](https://hub.mender.io/t/mender-client-cross-compile-for-arm-openssl-dependency/3574 "2021-04-30T12:28:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![prashanthjbabu](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/prashanthjbabu/32/1157_2.png) [@prashanthjbabu](https://hub.mender.io/u/prashanthjbabu)\
**Post date:** [April 30, 2021, 12:28pm UTC](https://hub.mender.io/t/mender-client-cross-compile-for-arm-openssl-dependency/3574/1 "2021-04-30T12:28:12Z")

</div>

Hello! I’m having trouble cross compiling mender client for ARM . When I try to compile mender for ARM from an AMD64 machine , I get the following error

```auto
mdb.c: In function ‘mdb_cursor_put’:
mdb.c:6535:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
      if (SIZELEFT(fp) < offset) {
         ^
mdb.c:6540:5: note: here
     case MDB_CURRENT:
     ^~~~
# github.com/mendersoftware/openssl
In file included from /usr/include/openssl/bio.h:13:0,
                 from ./shim.h:21,
                 from vendor/github.com/mendersoftware/openssl/bio.go:17:
/usr/include/openssl/e_os2.h:13:11: fatal error: openssl/opensslconf.h: No such file or directory
 # include <openssl/opensslconf.h>
           ^ ~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

```

The README in the mender client repository only talks about the `liblzma` dependency for cross compilation , is there any reference on how to do the same for `openssl` since `libssl-dev` is not multi arch compatible.

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [April 30, 2021, 4:54pm UTC](https://hub.mender.io/t/mender-client-cross-compile-for-arm-openssl-dependency/3574/2 "2021-04-30T16:54:23Z")

</div>

@oleorhagen any ideas here?

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [May 3, 2021, 6:38am UTC](https://hub.mender.io/t/mender-client-cross-compile-for-arm-openssl-dependency/3574/3 "2021-05-03T06:38:53Z")

</div>

Hi @prashanthjbabu 🙂

What do you mean `libssl-dev` is not multi-arch compatible?

> [@prashanthjbabu](#):
>
> The README in the mender client repository only talks about the `liblzma` dependency for cross compilation , is there any reference on how to do the same for `openssl` since `libssl-dev` is not multi arch compatible.

We don’t have it in the README, but in essence it should be pretty much the same as regular compilation, you just have to remember to set your C compiler env.

See [here](https://github.com/mendersoftware/mender#cross-compiler-setup)

If this does not work for you, can you share the exact steps you are following?

---

<div class="post-metadata">

**Author:** ![prashanthjbabu](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/prashanthjbabu/32/1157_2.png) [@prashanthjbabu](https://hub.mender.io/u/prashanthjbabu)\
**Post date:** [May 3, 2021, 6:49am UTC](https://hub.mender.io/t/mender-client-cross-compile-for-arm-openssl-dependency/3574/4 "2021-05-03T06:49:10Z")

</div>

Hi @oleorhagen ,

Here’s a reference for libssl-dev not being multi-arch compatible [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689093](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689093) .

I haven’t yet made an attempt to cross compile openssl . I will try that out and get back to you.

---

<div class="post-metadata">

**Author:** ![prashanthjbabu](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/prashanthjbabu/32/1157_2.png) [@prashanthjbabu](https://hub.mender.io/u/prashanthjbabu)\
**Post date:** [May 3, 2021, 8:16am UTC](https://hub.mender.io/t/mender-client-cross-compile-for-arm-openssl-dependency/3574/5 "2021-05-03T08:16:41Z")

</div>

Hi @oleorhagen ,

Here are the steps i’ve followed ( taken from the README of mender client repo ) to cross compile for raspberry pi ( as mentioned as an example in the README )

```auto
git clone https://github.com/mendersoftware/mender.git
cd mender/
git clone https://github.com/raspberrypi/tools.git
export PATH="$PATH:$(pwd)/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin"
export CC=arm-linux-gnueabihf-gcc
GOARCH=arm make TAGS="nodbus nolzma"

```

I get the following error :

```auto
go build -ldflags "-X github.com/mendersoftware/mender/conf.Version=fbed1ef" -tags 'nodbus nolzma'
# github.com/mendersoftware/openssl
In file included from /usr/include/openssl/bio.h:13:0,
                 from ./shim.h:21,
                 from vendor/github.com/mendersoftware/openssl/bio.go:17:
/usr/include/openssl/e_os2.h:13:11: fatal error: openssl/opensslconf.h: No such file or directory
 # include <openssl/opensslconf.h>
           ^ ~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:78: recipe for target 'build' failed
make: *** [build] Error 2

```

Are the steps wrong? I feel the README should be updated to include openssl cross compilation steps just like the liblzma steps , since you’ve recently introduced code changes under `https://github.com/mendersoftware/mender/tree/master/vendor/github.com/mendersoftware/openssl` which require this as a basic need for cross compilation to happen

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [May 4, 2021, 4:51am UTC](https://hub.mender.io/t/mender-client-cross-compile-for-arm-openssl-dependency/3574/6 "2021-05-04T04:51:23Z")

</div>

> [@prashanthjbabu](#):
>
> feel the README should be updated to include openssl cross compilation steps just like the liblzma steps , since you’ve recently introduced code changes under `https://github.com/mendersoftware/mender/tree/master/vendor/github.com/mendersoftware/openssl` which require this as a basic need for cross compilation to happen

You’ve probably got a point here, we can probably expand this. Once you get this working a PR would be hugely appreciated 🙂

> [@prashanthjbabu](#):
>
> Here’s a reference for libssl-dev not being multi-arch compatible [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689093](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689093) .

Ticket looks resolved to me.

This is the changelog:

```auto
   * Move <openssl/opensslconf.h> to /usr/include/$(DEB_HOST_MULTIARCH), and
     mark libssl-dev Multi-Arch: same.

```

And looking [here](https://packages.ubuntu.com/focal/libssl-dev), it looks like `armhf` is there. Also, the `armhf` [file-list](https://packages.ubuntu.com/focal/armhf/libssl-dev/filelist) looks like it is architecture.

How did the `openssl` cross-compilation go?

---

<div class="post-metadata">

**Author:** ![prashanthjbabu](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/prashanthjbabu/32/1157_2.png) [@prashanthjbabu](https://hub.mender.io/u/prashanthjbabu)\
**Post date:** [May 5, 2021, 5:01am UTC](https://hub.mender.io/t/mender-client-cross-compile-for-arm-openssl-dependency/3574/7 "2021-05-05T05:01:23Z")

</div>

hello @oleorhagen ,

I was able to successfully cross compile . Here’s a sample script which does everything

```auto
git clone https://github.com/mendersoftware/mender.git
cd mender/
git clone https://github.com/raspberrypi/tools.git
export PATH="$PATH:$(pwd)/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin"
export CC=arm-linux-gnueabihf-gcc
export CROSS=arm-linux-gnueabihf
wget -q https://www.openssl.org/source/openssl-1.1.1k.tar.gz
tar -xzf openssl-1.1.1k.tar.gz
cd openssl-1.1.1k
./Configure linux-armv4 --prefix=$(pwd)/install
make
make install
export LIBSSL_INSTALL_PATH=$(pwd)/install
cd ../
make CGO_CFLAGS="-I${LIBSSL_INSTALL_PATH}/include" CGO_LDFLAGS="-L${LIBSSL_INSTALL_PATH}/lib" CGO_ENABLED=1 GOOS=linux GOARCH=arm TAGS="nodbus nolzma"

```

I’ve also raised a PR to get this into README [Add libssl cross compilation steps to README by prashanthjbabu · Pull Request #752 · mendersoftware/mender · GitHub](https://github.com/mendersoftware/mender/pull/752)

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [May 5, 2021, 8:22am UTC](https://hub.mender.io/t/mender-client-cross-compile-for-arm-openssl-dependency/3574/8 "2021-05-05T08:22:40Z")

</div>

Awesome @prashanthjbabu !

And thanks for the PR, it looks good!
