ACS ACR reader program NFS

I have to compile a short program - the same as posted by another guy on this forum but they don't allow any more posts in that thread. Here goes the program:
#include <stdio.h>
#include <ct_api.h>
int main(int argc, char *argv[])
{
char ret;
unsigned short ctn;
unsigned short pn;
unsigned char sad;
unsigned char dad;

// REQUEST ICC
unsigned char command[] = { 0x20, 0x12, 0x01, 0x00, 0x00 };
unsigned short lenc = sizeof(command);

unsigned char response[300];
unsigned short lenr = sizeof(response);
unsigned short i;

ctn = 1;
pn = 1;

// Initialize card terminal
ret = CT_init(ctn, pn);
if (ret != OK)
{
printf("Error: CT_init failed with error %d\n", ret);
return 1;
}

sad = 2; // Source = Host
dad = 1; // Destination = Card Terminal

// Send command
ret = CT_data(ctn, &dad, &sad, lenc, command, &lenr, response);
if (ret != OK)
printf("Error: CT_data failed with error %d\n", ret);
else
{
// Display response
printf("Response: ");
for (i = 0; i < lenr; i++)
printf("%02X ", response[i]);
printf("\n");
}

// Close card terminal
ret = CT_close(ctn);
if (ret != OK)
printf("Error: CT_close failed with error %d\n", ret);

return 0;
}

I can get a .o for main.cpp by using the following command:
g++ -c -pthread main.cpp

Using the above command creates the file main.o and there are no errors or
any warnings at all.

But I am having trouble getting it to link. I need to understand the following stuff in the file .pc in the pkgconfig directory. If I fully understood that or if I properly included relative path to .so1, I would be ok. So anything that helps I'd appreciate - should I rpath to so1? I want something simple for now.

How to interpret this? I can understand that it's all in /usr/include or /usr/lib by subbing for the exec path stuff. But the link part is cryptic to me with the private, etc.. Just not in my ballywick/ball of wax.
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/ctacs

Name: libctacs
Description: ACS CT-API library
Version: 1.0.1
Requires: libpcsclite >= 1.3.3
Libs: -L${libdir} -lctacs
Libs.private:
Cflags: -I${includedir} -pthread


HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Here's a list of the libraries in the /usr/lib directory. Usually, people just say what to link to for which function calls your making. I've only got 3 functions I call _init, .., _close, etc.. Simple stuff.

libctacs.a, libctacs.la, libctacs.so, libctacs.so.1, libctacs.so.1.0.1 I believe that's it. I'm weak on shell scripts that loop and grep but I'm a willing learner - do I need to cross-analyze these libraries.

libctacs.a - an archive
libctacs.la - a shared library (like Windows dll)
libctacs.so - symobolic link 17B
libctacs.so.1 - symbolic link 17B
libctacs.so.1.0.1 - shared library 49K (like Windows dll)

I can easily tell that the symbolic links are there simply as a level of indirection to insulate my lib references from changes in version.

I might just link to libctacs.la and libctacs.so.1.0.1 since these are shared
libraries and they have some beef in them. And maybe libctacs.a

I think I need to leave the lib off since it's assumed by g++.
Leaving lib off helps but now it can't find libpcsclite.so.1 Perhaps I need to find that or install it.

Ok, I've found a directory with a header file with pcsclite or something - I just need to find the binaries or perhaps build that library.

Wooh boy!
Last edited on
Ok, so now I've navigated in the terminal to the PCSC directory and run:

autoreconfig -i
./configure
make
make install

Now I'll try to rebuild the app I'm struggling to link
Wow, that was all it needed, I got an executable. Now I know the trick is to get it to find the dll(s) it needs. But at least I'm half way there.
I ran the command ./myexe and it cannot find the libpcsclite.so.1 so I need to research how to resolve this error.

At least it ran.
I have now found the directory where the file libpcsclite.so.1 is - /usr/local/lib so I guess I need to put this in the path or somethign.
I decided to append /usr/local/lib to my LD_LIBRARY_PATH to get it to find. I also decided to recompile in case it mattered.

Now the program runs.

Last edited on
Topic archived. No new replies allowed.