Openssl and zlib libraries missing in TorizonCore Debian Based Container Images (Error during build)

I am trying to build and deploy a CPP application (written for a linux envirionment) on Toradex Apalis iMX8QM board with Torizoncore. I use visual studio 2019 as my development environment. My application uses openssl and zlib libraries. I get the following errors while building:

**error : openssl/ssl.h: No such file or directory 
error : zlib.h: No such file or directory**

The container that starts running in the build environment is: arm64v8-debian-base_buster_2a0fe2f5-cc3f-4788-a3c9-58900e05f974_debug_sdk based on the image: arm64v8-debian-base_buster_2a0fe2f5-cc3f-4788-a3c9-58900e05f974_debug_sdk_image. (Listed from the commands docker ps and docker images respectively). I can step into the running container using the command docker exec -it CONTAINER ID /bin/bash and see that the build folder is created at location /home.

I could customize the container by installing all the development packages that I need (openssl and zlib). However, note that it did not simply work with apt-get install openssl and apt-get install zlib1g-dev. I had to download the source files and do make install (it takes a lot of time!!). Then my problem is solved temporarily and I can execute my application. But I don’t want to do this every time I want to test my application since a new container is started every time and installing these libraries each time will take a lot of time.

So I built a new image from the running container (using docker commit) with the libraries that I need (basically the arm64v8-debian-base_buster_debug_######_sdk container with the openssl and zlib libraries that I installed), and pushed this image into docker hub. Next thing, I changed the name of the image in C:\lokal\rudhi\torizonCPP\MyProject\appconfig_0\work\Dockerfile.debug to the name of the new image that I just pushed. Changing the Dockerfile does not seem to be the right solution as far as I understand, because it is still building a new debian-base_buster container in the build environment instead of a container from my newly built image.

I do not understand what Dockerfile_SDK.debug file is and if I need to change something in there. I am a newbie to docker. What would be a permanent solution to my problem? I need my application to run in a container with all the libraries and packages that I need and I don’t want to configure the containers every single time. Also, how do I install the runtime libraries for these on the container running on Toradex’s Computer on Modules (and will I have to do this every time I turn on the module)?

Greetings @rudhi31,

Let me try and tackle the root of the issue here. Your application you’re trying to develop here needs development libraries/files from both zlib and libssl. It seems you got the right development package for zlib, zlib1g-dev, but for openssl the right package is libssl-dev. If you install these two files I really do expect that it should work unless a new error pops up.

Even with these two packages installed is your application still failing to work/build? When it fails after adding these packages is it the same error of missing development files? Or is it a new error?

Also just to clarify while it is true that the extension builds a new container image each time, it does some level of caching. Meaning while the first build make take a while it should cache the results during a 2nd build unless you change something fundamental in which case it would need to do a complete rebuild.

Finally if installing the dev-packages from Debian truly doesn’t work and you need to compile in the files yourself, then I would suggest taking a look at this article: C/C++ Development and Debugging on Torizon Using Visual Studio | Toradex Developer Center

In the above article we walk through how to take an external codebase and integrate it into your solution. In the example we use influxdb-cxx but the concepts should be applicable to the libssl and zlib source code. Also the entire article should help clear up any other general misunderstandings. And as I said above the first build may take a while but subsequent builds should be cached resulting in faster build times.

Best Regards,
Jeremias

Hi @jeremias.tx,

Thanks a lot for your input.

So, I could find the right solution from the article: C/C++ Development and Debugging on Torizon Using Visual Studio | Toradex Developer Center that you just mentioned. It pushed me in the right direction.

I only needed to add the devpackages in Torizon C/C++ Application Properties.
The devpackages are libssl-dev:arm64 and zlib1g-dev:arm64.
The build will be successful but while deploying the application on the module, it gives error that it cannot find some shared object libraries.

error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

Well, I fixed that by installing that library on the build container and then deployed it again:

    apt-get install lib32stdc++6
	cp /usr/aarch64-linux-gnu/lib/libstdc++.so.6 /usr/lib/
	cd /usr/lib/
	ln -s libstdc++.so.6 libstdc++.so
	ldconfig

Great! Now my application is deployed successfully on the module and it starts running!!

I couldn’t find the option for extrapackages in visual studio though. Is this removed from the configuration properties now because it’s not needed anymore? My problem was solved even without adding the extra packages to be included in the application container that runs on the target.

PS: Installing the lbssl-dev and zlib1g-dev libraries manually in the running container on the build environment doesn’t seem to be the right solution. I get new build errors for missing files after I do apt-get install libssl-dev and apt-get install zlib1g-dev.

build errors:

1>Build FAILED.    
    1>
    1>/usr/include/openssl/e_os2.h(13,11): error : openssl/opensslconf.h: No such file or directory
    1>/usr/include/openssl/e_os2.h(13,11): error :  # include <openssl/opensslconf.h>
    1>/usr/include/openssl/e_os2.h(13,11): error :            ^~~~~~~~~~~~~~~~~~~~~~~
    1>/usr/include/openssl/e_os2.h(13,11): error : compilation terminated.
    1>/usr/include/openssl/e_os2.h(13,11): error : openssl/opensslconf.h: No such file or directory  
    1>/usr/include/openssl/e_os2.h(13,11): error :  # include <openssl/opensslconf.h>   
    1>/usr/include/openssl/e_os2.h(13,11): error :            ^~~~~~~~~~~~~~~~~~~~~~~  
    1>/usr/include/openssl/e_os2.h(13,11): error : compilation terminated.

    1>/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld : error : cannot find -lz
    1>collect2 : error : ld returned 1 exit status

I could fix this after a long and tedious process of downloading the libraries and compiling them.
But adding the devpackages in the project properties seems to be the easiest way to solve this.

Regards,

Rudhi

Glad you were able to resolve this.