title: AES-CMAC using mbedtls: undefined reference error
body: <p>I try to implement AES-CMAC using mbedTLS.
  I get some errors:</p>
  
  <blockquote>
    <p>undefined reference to <code>mbedtls_cipher_cmac_starts</code>, undefined reference to <code>mbedtls_cipher_cmac_update</code>, undefined reference to <code>mbedtls_cipher_cmac_finish</code>,</p>
  </blockquote>
  
  <p>Why could these functions not be resolved, even though <code>mbedtls_cipher_init</code> and <code>mbedtls_cipher_setup</code> could?</p>
  
  <p>BTW. I implemented AES under the same project using mbedTLS with no problem. I use Eclipse Nano.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include "stdio.h"
  #include "stdlib.h"
  #include "string.h"
  #include "openssl/evp.h"
  #include "openssl/cmac.h"
  #include "mbedtls/cmac.h"
  #include "mbedtls/cipher.h"
  using namespace std;
  unsigned char key[16]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  
  int main()
  {
      unsigned char m[100],m_len=32;
      unsigned char out[16],out1[16],out2[16];
      size_t d_len;
  
      int i,ret;
      mbedtls_cipher_context_t m_ctx;
      const mbedtls_cipher_info_t *cipher_info;
      cipher_info = mbedtls_cipher_info_from_type( MBEDTLS_CIPHER_AES_128_ECB );
      if(cipher_info==NULL)
          printf("\nmbedtls_cipher_info_from_type failed");
  
      mbedtls_cipher_init(&amp;m_ctx);
  
      ret=mbedtls_cipher_setup( &amp;m_ctx, cipher_info );
      printf("\n mbedtls_cipher_setup returned %d %d",ret,     m_ctx.cipher_info-&gt;type);
  
  
  
      ret=mbedtls_cipher_cmac_starts(&amp;m_ctx,key,128);
      printf("\n mbedtls_cipher_cmac_starts returned %d",ret);
  
      ret= mbedtls_cipher_cmac_update(&amp;m_ctx, m,m_len);
      printf("\n mbedtls_cipher_cmac_update returned %d",ret);
  
      ret=mbedtls_cipher_cmac_finish(&amp;m_ctx,out1);
      printf("\n mbedtls_cipher_cmac_starts returned %d",ret);
      d_len=16;
      printf("\nLength is %d\n",(int)d_len);
      for(i=0;i&lt;d_len;i++)
      {
          printf("%x ",out1[i]);
      }
  
  
      return 0;
  
  }
  </code></pre>