zhekrwlehdrh@ullarla:~/test$ g++ -o tls_tcp_client tls_tcp_client.cpp -I/usr/local/include/mbedtls -L/usr/local/lib
/tmp/ccUVHIGD.o: In function `main':
tls_tcp_client.cpp:(.text+0x8f): undefined reference to `mbedtls_net_init'
tls_tcp_client.cpp:(.text+0x9e): undefined reference to `mbedtls_ssl_init'
tls_tcp_client.cpp:(.text+0xad): undefined reference to `mbedtls_ssl_config_init'
tls_tcp_client.cpp:(.text+0xbc): undefined reference to `mbedtls_x509_crt_init'
tls_tcp_client.cpp:(.text+0xcb): undefined reference to `mbedtls_ctr_drbg_init'
tls_tcp_client.cpp:(.text+0xe4): undefined reference to `mbedtls_x509_crt_parse_file'
tls_tcp_client.cpp:(.text+0x134): undefined reference to `mbedtls_ssl_conf_ca_chain'
tls_tcp_client.cpp:(.text+0x143): undefined reference to `mbedtls_entropy_init'
tls_tcp_client.cpp:(.text+0x16b): undefined reference to `mbedtls_entropy_func'
tls_tcp_client.cpp:(.text+0x173): undefined reference to `mbedtls_ctr_drbg_seed'
tls_tcp_client.cpp:(.text+0x21f): undefined reference to `mbedtls_net_connect'
tls_tcp_client.cpp:(.text+0x277): undefined reference to `mbedtls_ssl_config_defaults'
tls_tcp_client.cpp:(.text+0x2ba): undefined reference to `mbedtls_ctr_drbg_random'
tls_tcp_client.cpp:(.text+0x2c2): undefined reference to `mbedtls_ssl_conf_rng'
tls_tcp_client.cpp:(.text+0x2dd): undefined reference to `mbedtls_ssl_conf_dbg'
tls_tcp_client.cpp:(.text+0x2f1): undefined reference to `mbedtls_ssl_set_hostname'
tls_tcp_client.cpp:(.text+0x33a): undefined reference to `mbedtls_net_recv'
tls_tcp_client.cpp:(.text+0x33f): undefined reference to `mbedtls_net_send'
tls_tcp_client.cpp:(.text+0x347): undefined reference to `mbedtls_ssl_set_bio'
tls_tcp_client.cpp:(.text+0x3e4): undefined reference to `mbedtls_ssl_write'
tls_tcp_client.cpp:(.text+0x489): undefined reference to `mbedtls_ssl_read'
tls_tcp_client.cpp:(.text+0x4be): undefined reference to `mbedtls_net_free'
tls_tcp_client.cpp:(.text+0x4cd): undefined reference to `mbedtls_ssl_free'
tls_tcp_client.cpp:(.text+0x4dc): undefined reference to `mbedtls_ssl_config_free'
tls_tcp_client.cpp:(.text+0x4eb): undefined reference to `mbedtls_ctr_drbg_free'
tls_tcp_client.cpp:(.text+0x4fa): undefined reference to `mbedtls_entropy_free'
tls_tcp_client.cpp:(.text+0x53a): undefined reference to `mbedtls_net_free'
tls_tcp_client.cpp:(.text+0x549): undefined reference to `mbedtls_ssl_free'
tls_tcp_client.cpp:(.text+0x558): undefined reference to `mbedtls_ssl_config_free'
tls_tcp_client.cpp:(.text+0x567): undefined reference to `mbedtls_ctr_drbg_free'
tls_tcp_client.cpp:(.text+0x576): undefined reference to `mbedtls_entropy_free'
collect2: error: ld returned 1 exit status
-> zhekrwlehdrh@ullarla:~/test$ g++ -o tls_tcp_client tls_tcp_client.cpp -lmbedtls -lmbedx509 -lmbedcrypto
README.md에 아래 내용이:
The Make and CMake build systems create three libraries: libmbedcrypto, libmbedx509, and libmbedtls. Note that libmbedtls depends on libmbedx509 and libmbedcrypto, and libmbedx509 depends on libmbedcrypto. As a result, some linkers will expect flags to be in a specific order, for example the GNU linker wants `-lmbedtls -lmbedx509 -lmbedcrypto`. Also, when loading shared libraries using dlopen(), you'll need to load libmbedcrypto first, then libmbedx509, before you can load libmbedtls.