【问题标题】:how use dll files in C++?如何在 C++ 中使用 dll 文件?
【发布时间】:2011-03-16 08:53:32
【问题描述】:

我需要从 matlab 代码生成 Dll 文件并在 C++ 中使用它。我不能在 C++ 中耦合 dll 文件。请帮帮我。

【问题讨论】:

    标签: c++ visual-studio matlab dll c++builder


    【解决方案1】:

    这看起来很有希望:How do I create a C - shared library with MATLAB Compiler 3.0 which can be used in other projects?

    简而言之:

    1. 将您的 MATLAB 文件编译为 DLL(在 Windows 上):mcc -t -L C -W lib:mylib -T link:lib -h <MATLAB files> libmmfile.mlib

    2. mylib.lib 添加到您的 MSVC(或您自己的 IDE)项目中

    3. 确保从您的 调用任何已编译的 MATLAB 文件之前的代码。您需要拨打:mylibInitialize();
      之后,您应该调用终止例程:mylibTerminate();
      mylib.dll 中的所有符号也会出现在mylib.h 中。

    4. 您可以通过在 C 代码中调用 mlfFoo(...) 来调用从 MATLAB 代码编译的函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-23
      • 1970-01-01
      • 2022-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多