Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libmbedtls 初步 #17

Open
ghost opened this issue Jul 11, 2021 · 2 comments
Open

libmbedtls 初步 #17

ghost opened this issue Jul 11, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 11, 2021

https://archlinuxstudio.github.io/LinuxNetworkProgrammingAndEncryption/#/libmbedtls/basic

Linux 网络编程与加密

@WrenLiu
Copy link

WrenLiu commented Aug 28, 2021

Ubuntu 用户可按照以下方式操作,亲测有效,欢迎指正

1. 首先是安装

参考:https://www.cnblogs.com/sky-heaven/p/13884689.html

$ git clone https://github.com/ARMmbed/mbedtls.git

$ make SHARED=1
$ sudo make install

# 设置MBEDTLS_CONFIG_FILE宏,指向config-ccm-psk-tls1_2.h
$ CFLAGS="-I$PWD/configs -DMBEDTLS_CONFIG_FILE='<config-ccm-psk-tls1_2.h>'" 
# 重新编译
$ make

2. 安装总结,可以去对应文件下面找下文件,不知道为啥用cmake没装成功

  • 默认情况下 动态链接库安装至/usr/local/lib ,包括libmbedtls.solibmbedcrypto.solibmbedx509.so
  • 默认情况下 头文件安装至 /usr/local/include/mbedtls
  • 默认情况下 mbedtls的相关工具将安装/usr/local/bin目录下,例如gen_key等

3. 编译文件

此时如果编译base64.c文件会报 error while loading shared libraries: libmbedcrypto.so.10: cannot open shared object file: No such file or directory

解决方案:

$ sudo echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf
$ sudo /sbin/ldconfig

如果编译ciphersuite_list.c又会报 /usr/bin/ld: /usr/local/lib/libmbedx509.so: undefined reference to .....

解决方案

$ gcc ciphersuite_list.c -lmbedtls -lmbedx509 -lmbedcrypto -lmbedtls -lmbedx509 -lmbedcrypto

@ghost
Copy link
Author

ghost commented Aug 28, 2021

@JamesLiuwenliang 感谢回复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant