0

I'm having a weird problem with mbedtls security library. I've downloaded the newest version of it (link to download the .tar.gz) on my Ubuntu machine, then compiled it and copied the header files to /usr/include and the shared library files to the /usr/lib.

When I'm compiling my C++ program which calls the function mbedtls_cipher_cmac_starts from mbedtls/cmac.h, I get the undefined reference error Security.cpp:599: undefined reference to 'mbedtls_cipher_cmac_starts'. However, I have included and linked the libraries correctly (At least I think so, this is not an ordering problem, right?). The problem seems to be in the mbedtls library itself, as when I nm -D libmbedcrypto.so, I can't find the needed function. I also checked the libmbedtls.so but also no luck from there.

0000000000020206 T mbedtls_cipher_auth_decrypt
0000000000020128 T mbedtls_cipher_auth_encrypt
000000000001ff17 T mbedtls_cipher_check_tag
0000000000020022 T mbedtls_cipher_crypt
0000000000264960 D mbedtls_cipher_definitions
000000000001fb49 T mbedtls_cipher_finish

Although it seems to be in the library makefile when compiling the library. Also, it is weird that the header file (cmac.h) can be referenced from code, but it just won't compile because of the undefined references.

3
  • Also, it is weird that the header file (cmac.h) can be referenced from code, but it just won't compile because of the undefined references. It sounds like there's a mismatch between header version and your .a file. What is the question you want answered here? Commented Jul 25, 2017 at 11:48
  • 1
    Don't know the library in question, but: (a) Library ordering could be an issue: if the library providing that function occurs on the command-line before the library using that function, it likely won't work. Also, (b) are there any conditional compilation options for turning on/off parts of the library (such as "cmac")? Commented Jul 25, 2017 at 12:12
  • @pingul I'm using (and compiling) shared libraries, so they are .so files. Compile time it does not say that anything is wrong. There are also some test files for cmac testing in the library provided, and compiling the library doesn't get stuck at those files. @TripleHound , I tried to read through the whole library README, but there was just the specific command to output .so -library for the shared use. I will look further, and email the library developer if I can't sort this issue myself. I think the library ordering is not the issue, as other functions from the same library do work. Commented Jul 25, 2017 at 12:33

1 Answer 1

2

Which config.h did you use when building (have a look at configs/ folder)? Make sure MBEDTLS_CMAC_C is defined when building mbedtls, the default one does not define it (as of the date of this posting).

Sign up to request clarification or add additional context in comments.

1 Comment

This is embarassing... Stupid questioner deserves an obvious answer. Now it compiles with no problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.