if((rcvbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
(void) fprintf(stderr,"Error allocating receive buffer\n");
tpfree(sendbuf);
tpterm();
exit(1);
}
(void) strcpy(sendbuf, "0123456789abcdef0123456789abcdef");
/* Request the service TOUPPER, waiting for a reply */
ret = tpcall("TOUPPER", (char *)sendbuf, 0, (char **)&rcvbuf, &rcvlen, (long)0);
if(ret == -1) {
(void) fprintf(stderr, "Can't send request to service TOUPPER\n");
(void) fprintf(stderr, "Tperrno = %d\n", tperrno);
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
exit(1);
}
(void) fprintf(stdout, "Returned string is: %s\n", rcvbuf);
/* Free Buffers & Detach from System/T */
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
return;
}
#ifdef __cplusplus
}
#endif
#endif
5.编译.c为.o .so
gcc -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -I$TUXDIR/include -c -L${TUXDIR}/lib Hello.c
gcc -shared -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -I$TUXDIR/include -L$TUXDIR/lib -ltux -lbuft -lfml -lfml32 -lengine -ldl -lpthread /usr/lib/libcrypt.a -Wl,-soname,libhello.so.1 -o libhello.so.1.0 Hello.o
cp libhello.so.1.0 libhello.so
6.ldd libhello.so
如果看到一下的输出,恭喜!基本OK啦!
责任编辑:cyth