zoukankan      html  css  js  c++  java
  • unity 调用 .dll 或 .so时遇到的问题

    1、32位的 .dll 无法在64位的unity编辑器下运行。

    System.DllNotFoundException: xxx  , 64位的程序运行32位的dll是会报这种错

    2、Failed to load 'Assets/Plugins/xxx.dll', expected x64 architecture, but was x86 architecture. You must recompile your plugin for x64 architecture.

    将CPU选择.dll对应的CPU

    3、System.EntryPointNotFoundException:Unable to find an entry point

    原因就是:c++源代码中的函数在编译成DLL后,函数的名称就发生了改变:会在函数的前后产生一些字符。所以找不到方法的入口点。

        [DllImport(dllName, EntryPoint = "?Free@@YAHXZ")]
        private static extern int Free();
    

      

    Free的名字编译为dll时,变成了  ?Free@@YAHXZ  ,猜想可能的原因是直接写的C++接口,而不是C接口

    即,可能是没有通过 extern "C" int _DLLExport Free(); 的形式封装。

    也可再强制一下编码格式 CharSet = CharSet.Unicode

    即,

    [DllImport(dllName, EntryPoint = "?Free@@YAHXZ",CharSet = CharSet.Unicode)]
        private static extern int Free();
    

      

    附:eXeScope是查看 dll、exe等编译后的名字的小工具,很好用,下载地址:https://download.csdn.net/download/jasonczy/10657046

    在导出里就可以看到对应的名字了。

  • 相关阅读:
    sqlalchemy
    tornado-模板继承extend,函数和类的导入
    vi规范
    Spark 分布式SQL引擎
    Spark SQL 编程
    Spark SQL 基本原理
    spark SQL概述
    spark 多语言编程
    hadoop YARN
    spark 存储管理机制
  • 原文地址:https://www.cnblogs.com/Jason-c/p/9619954.html
Copyright © 2011-2022 走看看