zoukankan      html  css  js  c++  java
  • Unity4.5版本DLL库名字问题

    背景

    在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);
    细雨标记:

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

  • 相关阅读:
    2020年下半年学习进度04
    2020年下半年学习进度03
    2020年下半年学习进度02
    2020年下半年学习进度01
    数据爬取
    个人课程总结
    Syncnavigator V8.6.2在线说明书
    SyncNavigator V8.6.2企业版下载链接
    Syncnavigator V8.6.2帮助文档(说明书)下载
    SQL Server 自动同步到 MySQL
  • 原文地址:https://www.cnblogs.com/zsb517/p/4096640.html
Copyright © 2011-2022 走看看