这篇文章主要讲解了“JNA在Linux和MAC怎么编译C”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“JNA在Linux和MAC怎么编译C”吧!
编写C代码
test.c
#include
<stdio.h>
int
add
(
int
a
,
int
b
);
int
add
(
int
a
,
int
b
){
int
c
=
a
+
b
;
printf
(
"Hello,this method is userd to add two Integer."
)
;
return
c
;
}
gcc -fpic -c test.c
Linux系统编译:
gcc -shared -o libtest.so test.o
MAC系统编译:
gcc -dynamiclib -o libtest.dylib test.o
感谢各位的阅读,以上就是“JNA在Linux和MAC怎么编译C”的内容了,经过本文的学习后,相信大家对JNA在Linux和MAC怎么编译C这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是天达云,小编将为大家推送更多相关知识点的文章,欢迎关注!