title: Linking error for a C application using PKCS#11 API
body: <p>I am trying to compile an example basic code that performs PKCS#11 initialization only but get following error;</p>
  
  <pre><code>gcc pkcs11_example1.c -o pk -L /usr/lib64/pkcs11/opensc-pkcs11.so 
  /tmp/cc8Dl0HE.o: In function `initialize':
  pkcs11_example1.c:(.text+0x10): undefined reference to `C_GetFunctionList'
  pkcs11_example1.c:(.text+0x2b): undefined reference to `assert'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>the rpm command shows following so paths</p>
  
  <pre><code>rpm -ql opensc
  /usr/lib64/libopensc.so.3
  /usr/lib64/libopensc.so.3.0.0
  /usr/lib64/libsmm-local.so.3
  /usr/lib64/libsmm-local.so.3.0.0
  /usr/lib64/opensc-pkcs11.so
  /usr/lib64/pkcs11
  /usr/lib64/pkcs11-spy.so
  /usr/lib64/pkcs11/opensc-pkcs11.so
  /usr/lib64/pkcs11/pkcs11-spy.so
  </code></pre>
  
  <p>my code is pasted below</p>
  
  <pre><code>CK_RV  
  initialize()
  {
      CK_FUNCTION_LIST_PTR pFunctionList;
      CK_C_Initialize pC_Initialize; 
      CK_RV rv;
  
    /* It’s OK to call C_GetFunctionList before calling
       * C_Initialize */
      rv = C_GetFunctionList(&amp;pFunctionList);
      assert(rv == CKR_OK);
      pC_Initialize = pFunctionList -&gt; C_Initialize; 
  
      /* Call the C_Initialize function in the library */
      rv = (*pC_Initialize)(NULL_PTR);
      return rv;
  
  }
  
  int    
  main(int argc, char **argv)
  {
      rv = initialize();
  }
  </code></pre>
  
  <p>but still getting the error</p>
  
  <pre><code>undefined reference to `C_GetFunctionList'
  </code></pre>
  
  <p>Kindly guide how to resolve this issue</p>