curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Problem building libcurl agaist mbedtls WITHOUT installing the mbedtls build on the build host.

From: Morten Winkler Jørgensen via curl-library <curl-library_at_lists.haxx.se>
Date: Fri, 05 Aug 2022 09:09:44 +0200

Dear all.

First of all, thank you very much for a wonderful and solid piece of software. It is highly appreciated!
Secondly, I have problems building libcurl agaist mbedtls WITHOUT installing the mbedtls build on the build host.
I hope someone will be able to help me out here.

Thanks, Morten

# Background

I need to build libcurl (TAG curl-7_84_0) using mbedtls (TAG v3.2.1) as two shared libraries _without_ installing mbedtls on the build machine, but I fail with the following error:

--------------------------------------------------------
MBEDTLS_INCLUDE_DIRS-NOTFOUND
--------------------------------------------------------
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find MbedTLS (missing: MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY
MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
curl/curl/CMake/FindMbedTLS.cmake:38 (find_package_handle_standard_args)
curl/curl/CMakeLists.txt:468 (find_package)


# Reproducing

Steps to reproduce on a linux host with docker, bash and git:

1. unpack the attached tarball as $FOO.
2. cd $FOO
3. ./getcode.sh
4. docker build . -t curl_mbed_workshop
5. docker run -ti -v `pwd`:/code curl_mbed_workshop

Run the commands from here in the docker container

6. cd
7. mkdir build
8. cd build
9. cmake -GNinja /code
10. See the error mentioned above

My setup is capable of building both libraries as proved in Appendix 1.

# What I have tried

I have tried to specify libraries and folders as

```
set(MBEDTLS_INCLUDE_DIRS "something I thought make sense" CACHE STRING "blah foo" FORCE)
set(MBEDTLS_LIBRARY "something I thought make sense" CACHE STRING "blah foo" FORCE)
set(MBEDX509_LIBRARY "something I thought make sense" CACHE STRING "blah foo" FORCE)
set(MBEDCRYPTO_LIBRARY "something I thought make sense" CACHE STRING "blah foo" FORCE)
```

in the CMakeFile.txt that includes curl as a sub_directory but in vain.


# Question
How do I build mbedtls and libcurl using mbedtls using cmake withtout installing mbedtls on the build host?


# Appendix 1: Proof that the buildenv is capable

These snippets build mbedtls as a shared library, installs it on the build host and then builds libcurl and the command line utility curl and thus proves that the environment is capable of building mbedtls and libcurl.

```
docker build . -t curl_mbed_workshop
docker run -ti -v `pwd`:/code curl_mbed_workshop

# The following commands are to be run in the docker container:

cd

mkdir buildmbed
cd buildmbed
cmake -GNinja -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=ON /code/mbedtls/mbedtls/
ninja
ninja install

cd

mkdir buildcurl
cd buildcurl
cmake -GNinja -DCURL_USE_MBEDTLS=ON /code/curl/curl/
ninja

./src/curl <https://google.com>
```



-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2022-08-05