Giter Site home page Giter Site logo

build with mbedtls about libdatachannel HOT 4 CLOSED

azc5OQ avatar azc5OQ commented on September 25, 2024
build with mbedtls

from libdatachannel.

Comments (4)

paullouisageneau avatar paullouisageneau commented on September 25, 2024 1

@paullouisageneau regarding MBEDTLS_SSL_DTLS_SRTP, is this understanding correct?

@chobie Yes you are right, MbedTLS needs to be compiled with DTLS SRTP support. It's often the case for packaged builds, but if you compile by yourself, you have to make sure it's enabled.

I had to keep this manually added lines of code in libdatachannel's CMakeLists

	if (NOT DEFINED CMAKE_PREFIX_PATH)
		set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}\\deps\\mbedtls)
	else()
		set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${CMAKE_SOURCE_DIR}\\deps\\mbedtls")
	endif()

When building outside of an IDE, you can simply pass -DCMAKE_PREFIX_PATH=YOURPREFIX for libdatachannel. I guess there may be a similar option in CLion.

  • after build go to directory "cmake-build-release" and from there copy move "library" and "include" directories into \deps\mbedtls

  • rename "library" to "lib"

  • open libdatachannel in clion, now when cmake is configuring project instead of errors there should be this

Same you shouldn't need to do this manually, outside of an IDE you simply pass -DCMAKE_INSTALL_PREFIX=YOURPREFIX for MbedTLS, then you install it after the build, typically with make install, and CMake will copy everything under the prefix in the right directories.

from libdatachannel.

chobie avatar chobie commented on September 25, 2024

I have not performed it works, but these are the build instructions for Windows 11.
Please refer to them.

# on Developer Command Prompt For vs2022
# C:\Users\USERNAME\github. please replace USERNAME to your account.
# make sure you've already cloned libdatachannel repository

git clone https://github.com/Mbed-TLS/mbedtls.git
cd mbedtls
git checkout v3.5.1

# IMPORTANT: 
# You have to edit `include/mbedtls/mbedtls_config.h` to enable `#define MBEDTLS_SSL_DTLS_SRTP` constant (just uncomment that line).
# otherwise `mbedtls_dtls_srtp_info` cannnot find.

cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX="C:\\Users\\USERNAME\\github\\libdatachannel\\deps\\mbedtls" -DUSE_SHARED_MBEDTLS_LIBRARY=On -B build
cd build
nmake
nmake install
# then, result files will install `libdatachannel\deps\mbedtls` directories.


# after compile mbedtls, move to libdatachannel root directory
cd ..\..\

# use cmake command. the point is to specify mbedtls install path (specifically `DCMAKE_INSTALL_PREFIX`). not repository directory.
cmake -B build -G "NMake Makefiles" -DUSE_MBEDTLS=1 -DCMAKE_PREFIX_PATH="C:\\Users\\USERNAME\\github\\libdatachannel\\deps\\mbedtls" 

A key point is that building MbedTLS alone does not result in the directory structure expected by FindMbedTLS.
Therefore, I first configured the build of MbedTLS to install to the destination specified by DCMAKE_INSTALL_PREFIX. and install that. Then, by specifying DCMAKE_PREFIX_PATH in libdatachannel, I was able to resolve the references.

For the purpose of explanation, I specified the installation destination as the libdatachannel\deps directory, but you can choose any location you prefer. (I believe I have corrected the path in the explanation, but I apologize if there was any mistake during the process of trial and error.)

@paullouisageneau regarding MBEDTLS_SSL_DTLS_SRTP, is this understanding correct?

from libdatachannel.

chobie avatar chobie commented on September 25, 2024

I think that it's probably easier to use something like vcpkg rather than building mbedtls yourself.

from libdatachannel.

azc5OQ avatar azc5OQ commented on September 25, 2024

problem solved for me

I had to keep this manually added lines of code in libdatachannel's CMakeLists

	if (NOT DEFINED CMAKE_PREFIX_PATH)
		set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}\\deps\\mbedtls)
	else()
		set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${CMAKE_SOURCE_DIR}\\deps\\mbedtls")
	endif()

steps

  • open mbedtls with Clion
  • select mbedtls | Release configuration (there are many configurations)
  • build
[112/116] Building C object library/CMakeFiles/mbedtls.dir/net_sockets.c.obj
[113/116] Building C object library/CMakeFiles/mbedtls.dir/ssl_tls.c.obj
[114/116] Building C object library/CMakeFiles/mbedtls.dir/ssl_tls12_server.c.obj
[115/116] Building C object library/CMakeFiles/mbedtls.dir/ssl_tls12_client.c.obj
[116/116] Linking C static library library\libmbedtls.a
  • after build go to directory "cmake-build-release" and from there copy move "library" and "include" directories into \deps\mbedtls

  • rename "library" to "lib"

  • open libdatachannel in clion, now when cmake is configuring project instead of errors there should be this

-- Performing Test has_wno_address_of_packed_member - Success
-- Performing Test has_wno_deprecated_declarations
-- Performing Test has_wno_deprecated_declarations - Success
-- link library: ws2_32
-- Found MbedTLS: C:/Users/user/Desktop/libdatachannel/deps/mbedtls/lib/libmbedtls.a (found suitable version "3.5.1", minimum required is "3") 
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success

note both projects libdatachannel and mbedtls have to be build with same toolchain or linker wont be able to glue them together

suggestion: add mbedtls into libdatachannel by default (easiest to built)

from libdatachannel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.