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

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

  • 相关阅读:
    CF 234 C Weather(粗暴方法)
    给工作赋予的新意义——Leo鉴书78
    获取集合的方法
    VS 统计代码行数
    , ,
    指针的删除动作
    C++ 名称空间
    boost::token_compress_on
    指针与引用
    容器的end()方法
  • 原文地址:https://www.cnblogs.com/Jason-c/p/9619954.html
Copyright © 2011-2022 走看看