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;
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
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.