Hello All i have a program written in C, and i want to call a sharedobject, which i can do fine!
The only problem i am having is passing parameters.. Here is my code
int main()
{
static int (*fp)(int);
int *handle;
int MatchFound;
struct SharedObject_{
char name[10];
char add[80];
}SharedObject;
strcpy(SharedObject.name, "STEPHEN" );
strcpy(SharedObject.add, "PLACE HOUSE FARM" );
printf("Sharedobject name = %s\n", SharedObject.name );
printf("Sharedobject add = %s\n", SharedObject.add );
/* Open shared object */
if ( (handle = dlopen("sharedobject.so", RTLD_LAZY)) == NULL)
return -1;
if ((fp = (int (*)())dlsym(handle, "my_add")) == NULL)
return -1;
if ( (MatchFound = (*fp)((int) &SharedObject)) == -1 )
return -1;
}
The my add is a procuedure in my shared object, which looks like below
#include<stdio.h>
int my_add(char *name, char *add)
{
printf("In Sharedobject\n" );
printf("name = %s\n", name );
printf("add = %s\n", add );
}
When i run this, i am getting the following output:-
Sharedobject name = STEPHEN
Sharedobject add = PLACE HOUSE FARM
In Sharedobject
name = STEPHEN
add = my_add
When i would expect to see :-
Sharedobject name = STEPHEN
Sharedobject add = PLACE HOUSE FARM
In Sharedobject
name = STEPHEN
add = PLACE HOUSE FARM
Any ideas?
Thanks