解决java.lang.UnsatisfiedLinkError:dlopen failed:cannot locate symbol "tcgetattr" referenced by..

来源:互联网 发布:caffe 可视化 编辑:程序博客网 时间:2024/05/16 00:33

问题 :

09-15 12:21:41.297: D/AndroidRuntime(19825): Shutting down VM

09-15 12:21:41.297: W/dalvikvm(19825): threadid=1: thread exiting with uncaught exception (group=0x415ef898)
09-15 12:21:41.297: E/AndroidRuntime(19825): FATAL EXCEPTION: main
09-15 12:21:41.297: E/AndroidRuntime(19825): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locatesymbol "tcgetattr" referenced by "xxxlib.so"...
09-15 12:21:41.297: E/AndroidRuntime(19825):at java.lang.Runtime.loadLibrary(Runtime.java:361)

09-15 12:21:41.297: E/AndroidRuntime(19825):at java.lang.System.loadLibrary(System.java:525)

分析 :

对于tcgetattr ,在termios.h中是这样定义的 :int tcgetattr(int, struct termios*);

其中结构体termios 的定义是:

struct termios {
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 tcflag_t c_iflag;
 tcflag_t c_oflag;
 tcflag_t c_cflag;
 tcflag_t c_lflag;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  cc_t c_line;
  cc_t c_cc[NCCS];
};

查百度百科:

      头文件   #include<termios.h>

   函数原型:int tcgetattr(int fd, struct termios *termios_p);

   返回值 :成功返回零;失败返回非零,发生失败接口将设置errno错误标识。

tcgetattr函数用于获取与终端相关的参数,而tcsetattr函数用于设置终端参数。参数fd为终端的文件描述符,返回的结果保存在termios 结构体中。
分析结论:所以还是库xxxlib.so编译问题造成的。
解决办法:
网上查了很多,答案参差不齐,综合别人的意见,找出了解决我的问题的办法是 :
在Android.mk中加入:
APP_PLATFORM := android-19
      APP_STL         := gnustl_shared
参考网址:
https://groups.google.com/forum/#!topic/android-ndk/usuNcsLbp14
http://forum.openframeworks.cc/t/android-master-branch/20106/2
http://qnalist.com/questions/6204640/two-similar-apps-one-works-the-other-no-ndk-not-linking-properly-why





1 1
原创粉丝点击