Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have this attached with a code. undefined reference to 'SCardEstablishContext@16' and 'SCardConnectA@24' keeps coming. what to do?
C++
SCARDCONTEXT    hSC;
                    LONG            lReturn;
                    // Establish the context.
                    lReturn = SCardEstablishContext(SCARD_SCOPE_USER,
                                                    NULL,
                                                    NULL,
                                                    &hSC);
                    if ( SCARD_S_SUCCESS != lReturn )
                        printf("Failed SCardEstablishContext\n");
                    else
                    {
                        SCARDHANDLE     hCardHandle;
                        LONG            lReturn1;
                        DWORD           dwAP;

                        lReturn1 = SCardConnect( hSC,
                                                (LPCTSTR)"Rainbow Technologies SCR3531 0",
                                                SCARD_SHARE_SHARED,
                                                SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
                                                &hCardHandle,
                                                &dwAP );
                        if ( SCARD_S_SUCCESS != lReturn1 )
                        {
                            printf("Failed SCardConnect\n");
                            exit(1);  // Or other appropriate action.
                        }

                        // Use the connection.
                        // Display the active protocol.
                        switch ( dwAP )
                        {
                            case SCARD_PROTOCOL_T0:
                                printf("Active protocol T0\n");
                                break;

                            case SCARD_PROTOCOL_T1:
                                printf("Active protocol T1\n");
                                break;

                            case SCARD_PROTOCOL_UNDEFINED:
                            default:
                                printf("Active protocol unnegotiated or unknown\n");
                                break;
                        }
                    }
Posted

1 solution

You must link your application to the Winscard library.

Add this line on top of one source file:
#pragma comment(lib, "winscard")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900