Menu

undefined reference to `_imp__g_rgSCardT...

Jan Bilek
2011-04-30
2013-06-06
  • Jan Bilek

    Jan Bilek - 2011-04-30

    Hi,

    I'm having a problem with compilation of code with winscard.h from mingw-w32-bin_i686-mingw_20110429 getting "undefined reference to `_imp__g_rgSCardT1Pci'".

    #include <winscard.h>
    int main(void)
    {
     DWORD dwActiveProtocol;
     SCARD_IO_REQUEST pioSendPci;
     switch(dwActiveProtocol)
     {
      case SCARD_PROTOCOL_T0:
       pioSendPci = *SCARD_PCI_T0;
       break;
      case SCARD_PROTOCOL_T1:
       pioSendPci = *SCARD_PCI_T1;
       break;
     }
     return 0;
    }
    

    Compiling with "c:\MinGW\i686-w64-mingw32\bin>gcc main_tiny.c -o main -L. -lwinscard"

    This is just code snippet original code I'm trying to compile is {here}.

    I can see definition in winscard.h as follows:

      WINSCARDDATA extern const SCARD_IO_REQUEST g_rgSCardT0Pci,g_rgSCardT1Pci,g_rgSCardRawPci;
    #define SCARD_PCI_T0 (&g_rgSCardT0Pci)
    #define SCARD_PCI_T1 (&g_rgSCardT1Pci)
    #define SCARD_PCI_RAW (&g_rgSCardRawPci)
    

    but linker still complains.

    Any help is much appreciated.

    Thanks.
    JB

     
  • Ozkan Sezer

    Ozkan Sezer - 2011-04-30

    Your toolchain indicates that it uses the trunk version of import libraries. lib32/winscard.def has:
    g_rgSCardRawPci@4
    g_rgSCardT0Pci@8
    g_rgSCardT1Pci@8
    … at the end of the file, but these are exported data, not exported functions. So we must remove the stdcall suffixes from them, and then maybe mark them as DATA as is the case with the trunk version of lib64/winscard.def (the release branch version of lib64/winscard.def doesn't mark them as DATA, btw…)   Revising the other stdcall/fastcall suffixes in lib32/winscard.def further, wouldn't hurt either…

     
  • Ozkan Sezer

    Ozkan Sezer - 2011-04-30

    A note, though:  gendef generates those exports without stdcall suffixes from the winxp version of the dll. With the vista version of the dll, however, it does add the suffixes. Ugh..

     
  • Jan Bilek

    Jan Bilek - 2011-04-30

    Hi sezero,

    thanks for a prompt response, is there anything I can help with?

     
  • Ozkan Sezer

    Ozkan Sezer - 2011-04-30

    Can't attach files here. Sent you a private message using sf.net mail interface. Please reply to it so I can send you an updated import library as a mail attachment.

     
  • Ozkan Sezer

    Ozkan Sezer - 2011-04-30

    OK, the following fix:

    Index: lib32/winscard.def
    ===================================================================
    --- lib32/winscard.def  (revision 4157)
    +++ lib32/winscard.def  (working copy)
    @@ -70,6 +70,6 @@
     SCardTransmit@28
     SCardWriteCacheA@24
     SCardWriteCacheW@24
    -g_rgSCardRawPci@4
    -g_rgSCardT0Pci@8
    -g_rgSCardT1Pci@8
    +g_rgSCardRawPci DATA
    +g_rgSCardT0Pci DATA
    +g_rgSCardT1Pci DATA
    

    … is confirmed to work in private mail.  I posted the fix to the developers list for review.

     
  • Jan Bilek

    Jan Bilek - 2011-04-30

    Hi Sezero,

    thank you very much for your help. It is very appreciated.

    JB

     
  • Ozkan Sezer

    Ozkan Sezer - 2011-04-30

    Fixed in the svn repo at rev. 4158.

     

Log in to post a comment.