背景

在unity4.2版本中可以在Android中使用的so链接库,在Unity4.5中使不了~~

[DllImport("libclient.so", EntryPoint = "readFifo")]
private static extern int readFifo(int clientFd);

原因

最初一直以为是So的编译问题,结果测试几个之后还是一样,代码什么都不动,转换到4.5发布之后就不行。昨天发现这段话:

If you have control over the library name, keep the above naming conventions in mind and don’t use a platform-specific library name in the DllImport statement. Instead, just use the library name itself, without any prefixes or suffixes, and rely on the runtime to find the appropriate library at runtime. For example:

 [DllImport ("MyLibrary")]
private static extern void Frobnicate ();
Then, you just need to provide MyLibrary.dll for Windows platforms, libMyLibrary.so for Unix platforms, and libMyLibrary.dylib for Mac OS X platforms.

翻译过来就是不用对每个平台使用DLLIMPORT的时候使用不同的DLL名字,只需要使用DLL库本身的名字,不加任何的前缀或者后缀,系统会自动根据DLL名字和平台去搜索。比如:"MyLibrary" 在windows平台需要MyLibrary.dll , 在Android中需要libMyLibrary.so,在IOS中需要libMyLibrary.dylib . 

我的工程中实际名字是:libclient.so,所以可以这样写:

[DllImport("client", EntryPoint = "readFifo")]
private static extern int readFifo(int clientFd);
细雨标记: unity dll

参考地址:http://www.mono-project.com/docs/advanced/pinvoke/

最新文章

  1. SHELL脚本攻略(学习笔记)--2.4 find
  2. The web application [/codeMarket] registered the JBDC driver[.........] but failed to unregister it when the web application was stopped. To prevent
  3. (2)jni编程学习笔记
  4. P2342 叠积木
  5. Android使用surface直接显示yuv数据(三)
  6. python基础===随机打印txt文件中的某一行
  7. nodejs之express4x
  8. 浅谈unity中gamma空间和线性空间
  9. r.js合并实践
  10. PS绘制扁平化风格相机镜头UI图标
  11. IO流--与properties集合配合使用
  12. context configure and clock schedule
  13. Visual Studio Code 的 launch.json 解析
  14. 为什么MySQL不推荐使用子查询和join
  15. POJ 2601
  16. raft 论文
  17. Vue 动态组件渲染问题分析
  18. 合格PHP工程师的知识结构
  19. ORM练习项目-图书管理系统(BMS)实现细节
  20. 13.8.8 div块 居中

热门文章

  1. nginx 匹配.zip .apk 结尾的文件 直接下载
  2. adbWireless 简单教程
  3. hdu 4005 双联通 2011大连赛区网络赛E *****
  4. RTP/RTCP/RTSP/SIP/SDP 关系(直接看总结)
  5. 对android中ActionBar中setDisplayHomeAsUpEnabled和setHomeButtonEnabled和setDisplayShowHomeEnabled方法的理解(转)
  6. Android权限设置android.permission
  7. 怎样删除github中的项目
  8. Hark的数据结构与算法练习之归并排序
  9. c/c++ 笔试面试题
  10. 洛谷 P1009 阶乘之和 Label:高精度