cccgggsss_168 2018-04-08 13:05 采纳率: 0%
浏览 836
已结题

vs2010 matlab2012b 混编问题请教

各位大牛:
近期在做一个 VS2010调用 matlab2012B 产生的C++文件的事情,但一直搞不定,能否指点一下,不胜感激!

环境 VS2010 管理器设置 debugX64 调用 matlab2012B 64位,
1、用matlab 编 my_plot.m文件
function [x]=my_plot(A,B)
x=A+B;
plot(A,B,'-r');

2 mcc -W cpplib:my_plot -T link:lib my_plot.m
通过产生 my_plot.dll my_plot.h my_plot.lib

3、打开Vs2010 建立空窗体工程,管理器设置X64 编译运行通过

4、工程中加入相关matlab调用语句如下

#include "stdafx.h"
#include "Form1.h"
#include "my_plot.h"

#include "mclcppclass.h"
#include "mclmcrrt.h"

#pragma comment(lib,"mclmcrrt.lib")
#pragma comment(lib,"my_plot.lib")
using namespace chuang;
[STAThreadAttribute]
int main(array ^args)
{
mwArray mwX(1,11,mxDOUBLE_CLASS);
mwArray mwY(1,11,mxDOUBLE_CLASS);
mwArray mwZ(1,11,mxDOUBLE_CLASS);;
int i;
double x[1][11],y[1][11];

Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false); 

  if (!my_plotInitialize())
    return -1;

for(i=0; i<11; i++)
{
    x[1][i] = i;
    y[1][i] = sin(x[1][i]);
}


mwX.SetData(*x, 11);
mwY.SetData(*y, 11);

// mwZ.SetData(*y, 11);

my_plot(1,mwZ,mwX,mwY);    //调Ì¡Â用®?my_plot

my_plotTerminate();

Application::Run(gcnew Form1());

return 0;

}

环境变量

Path D:\Program Files\MATLAB\R2012b\bin\win64;D:\Program Files\MATLAB\R2012b\bin
包含目录
D:\Program Files\MATLAB\R2012b\extern\include;
D:\Program Files\MATLAB\R2012b\extern\include\win64;$(IncludePath)
库目录
D:\Program Files\MATLAB\R2012b\extern\lib\win64\microsoft;
$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSdkDir)lib\x64;

附加包含目录
D:\Program Files\MATLAB\R2012b\extern\include;
D:\Program Files\MATLAB\R2012b\extern\include\win64;%(AdditionalIncludeDirectories)

编译报错:
1> 所有输出均为最新。
1>chuang.obj : error LNK2031: 无法为 "extern "C" int __clrcall array_ref_set_numeric_mxDouble_proxy(class array_ref *,double const *,unsigned __int64)" (?array_ref_set_numeric_mxDouble_proxy@@$$J0YMHPEAVarray_ref@@PEBN_K@Z) 生成 p/invoke;元数据中缺少调用约定
1>chuang.obj : error LNK2031: 无法为 "extern "C" class array_ref * __clrcall array_ref_deep_copy_proxy(class array_ref *)" (?array_ref_deep_copy_proxy@@$$J0YMPEAVarray_ref@@PEAV1@@Z) 生成 p/invoke;元数据中缺少调用约定
1>chuang.obj : error LNK2031: 无法为 "extern "C" int __clrcall mclGetMatrix_proxy(void * *,unsigned __int64,unsigned __int64,enum mxClassID,enum mxComplexity)" (?mclGetMatrix_proxy@@$$J0YMHPEAPEAX_K1W4mxClassID@@W4mxComplexity@@@Z) 生成 p/invoke;元数据中缺少调用约定
1>chuang.obj : error LNK2031: 无法为 "extern "C" char const * __clrcall char_buffer_get_buffer_proxy(class char_buffer *)" (?char_buffer_get_buffer_proxy@@$$J0YMPEBDPEAVchar_buffer@@@Z) 生成 p/invoke;元数据中缺少调用约定
1>chuang.obj : error LNK2031: 无法为 "extern "C" int __clrcall char_buffer_set_buffer_proxy(class char_buffer *,char const *)" (?char_buffer_set_buffer_proxy@@$$J0YMHPEAVchar_buffer@@PEBD@Z) 生成 p/invoke;元数据中缺少调用约定
1>chuang.obj : error LNK2031: 无法为 "extern "C" int __clrcall mclCreateCharBuffer_proxy(void * *,char const *)" (?mclCreateCharBuffer_proxy@@$$J0YMHPEAPEAXPEBD@Z) 生成 p/invoke;元数据中缺少调用约定
1>chuang.obj : error LNK2031: 无法为 "extern "C" int __clrcall mclcppGetLastError_proxy(void * *)" (?mclcppGetLastError_proxy@@$$J0YMHPEAPEAX@Z) 生成 p/invoke;元数据中缺少调用约定
1>chuang.obj : error LNK2031: 无法为 "extern "C" char const * __clrcall error_info_get_message_proxy(class error_info *)" (?error_info_get_message_proxy@@$$J0YMPEBDPEAVerror_info@@@Z) 生成 p/invoke;元数据中缺少调用约定
@Z) 生成 p/invoke;元数据中缺少调用约定
1>chuang.obj : error LNK2031: 无法为 "extern "C" int __clrcall ref_count_obj_addref_proxy(class ref_count_obj *)" (?ref_count_obj_addref_proxy@@$$J0YMHPEAVref_count_obj@@@Z) 生成 p/invoke;元数据中缺少调用约定
1>chuang.obj : error LNK2031: 无法为 "extern "C" int __clrcall mclcppCreateError_proxy(void * *,char const *)" (?mclcppCreateError_proxy@@$$J0YMHPEAPEAXPEBD@Z) 生成 p/invoke;元数据中缺少调用约定
1>chuang.obj : error LNK2028: 无法解析的标记(0A00003F) "extern "C" int __clrcall array_ref_set_numeric_mxDouble_proxy(class array_ref *,double const *,unsigned __int64)" (?array_ref_set_numeric_mxDouble_proxy@@$$J0YMHPEAVarray_ref@@PEBN_K@Z),该标记在函数 "public: void __clrcall mwArray::SetData(double *,unsigned __int64)" (?SetData@mwArray@@$$FQEAMXPEAN_K@Z) 中被引用
1>chuang.obj : error LNK2028: 无法解析的标记(0A0000E9) "extern "C" class array_ref * __clrcall array_ref_deep_copy_proxy(class array_ref *)" (?array_ref_deep_copy_proxy@@$$J0YMPEAVarray_ref@@PEAV1@@Z),该标记在函数 "public: __clrcall mwArray::mwArray(class mwArray const &)" (??0mwArray@@$$FQEAM@AEBV0@@Z) 中被引用
1>chuang.obj : error LNK2028: 无法解析的标记(0A0000FA) "extern "C" int __clrcall mclGetMatrix_proxy(void * *,unsigned __int64,unsigned __int64,enum mxClassID,enum mxComplexity)" (?mclGetMatrix_proxy@@$$J0YMHPEAPEAX_K1W4mxClassID@@W4mxComplexity@@@Z),该标记在函数 "public: __clrcall mwArray::mwArray(unsigned __int64,unsigned __int64,enum mxClassID,enum mxComplexity)" (??0mwArray@@$$FQEAM@_K0W4mxClassID@@W4mxComplexity@@@Z) 中被引用
1>chuang.obj : error LNK2028: 无法解析的标记(0A00010E) "extern "C" char const * __clrcall char_buffer_get_buffer_proxy(class char_buffer *)" (?char_buffer_get_buffer_proxy@@$$J0YMPEBDPEAVchar_buffer@@@Z),该标记在函数 "public: __clrcall mwString::operator char const *(void)const " (??BmwString@@$$FQEBMPEBDXZ) 中被引用
1>chuang.obj : error LNK2028: 无法解析的标记(0A000110) "extern "C" int __clrcall char_buffer_set_buffer_proxy(class char_buffer *,char const *)" (?char_buffer_set_buffer_proxy@@$$J0YMHPEAVchar_buffer@@PEBD@Z),该标记在函数 "public: __clrcall mwString::mwString(class mwString const &)" (??0mwString@@$$FQEAM@AEBV0@@Z) 中被引用
1>chuang.obj : error LNK2028: 无法解析的标记(0A000111) "extern "C" int __clrcall mclCreateCharBuffer_proxy(void * *,char const *)" (?mclCreateCharBuffer_proxy@@$$J0YMHPEAPEAXPEBD@Z),该标记在函数 "public: __clrcall mwString::mwString(class mwString const &)" (??0mwString@@$$FQEAM@AEBV0@@Z) 中被引用
1>chuang.obj : error LNK2028: 无法解析的标记(0A000115) "extern "C" int __clrcall mclcppGetLastError_proxy(void * *)" (?mclcppGetLastError_proxy@@$$J0YMHPEAPEAX@Z),该标记在函数 "public: static void __clrcall mwException::raise_error(void)" (?raise_error@mwException@@$$FSMXXZ) 中被引用
1>chuang.obj : error LNK2028: 无法解析的标记(0A000116) "extern "C" char const * __clrcall error_info_get_message_proxy(class error_info *)" (?error_info_get_message_proxy@@$$J0YMPEBDPEAVerror_info@@@Z),该标记在函数 "public: virtual char const * __clrcall mwException::what(void)const " (?what@mwException@@$$FUEBMPEBDXZ) 中被引用
1>chuang.obj : error LNK2028: 无法解析的标记(0A000117) "extern "C" int __clrcall ref_count_obj_release_proxy(class ref_count_obj *)" (?ref_count_obj_release_proxy@@$$J0YMHPEAVref_count_obj@@@Z),该标记在函数 "public: virtual __clrcall mwArray::~mwArray(void)" (??1mwArray@@$$FUEAM@XZ) 中被引用
1>chuang.obj : error LNK2028: 无法解析的标记(0A000118) "extern "C" int __clrcall ref_count_obj_addref_proxy(class ref_count_obj *)" (?ref_count_obj_addref_proxy@@$$J0YMHPEAVref_count_obj@@@Z),该标记在函数 "public: __clrcall mwException::mwException(class mwException const &)" (??0mwException@@$$FQEAM@AEBV0@@Z) 中被引用
1>chuang.obj : error LNK2028: 无法解析的标记(0A000119) "extern "C" int __clrcall mclcppCreateError_proxy(void * *,char const *)" (?mclcppCreateError_proxy@@$$J0YMHPEAPEAXPEBD@Z),该标记在函数 "public: __clrcall mwException::mwException(void)" (??0mwException@@$$FQEAM@XZ) 中被引用
1>chuang.obj : error LNK2019: 无法解析的外部符号 "extern "C" char const * __clrcall error_info_get_message_proxy(class error_info *)" (?error_info_get_message_proxy@@$$J0YMPEBDPEAVerror_info@@@Z),该符号在函数 "public: virtual char const * __clrcall mwException::what(void)const " (?what@mwException@@$$FUEBMPEBDXZ) 中被引用
1>chuang.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __clrcall ref_count_obj_release_proxy(class ref_count_obj *)" (?ref_count_obj_release_proxy@@$$J0YMHPEAVref_count_obj@@@Z),该符号在函数 "public: virtual __clrcall mwArray::~mwArray(void)" (??1mwArray@@$$FUEAM@XZ) 中被引用
1>chuang.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __clrcall mclcppCreateError_proxy(void * *,char const *)" (?mclcppCreateError_proxy@@$$J0YMHPEAPEAXPEBD@Z),该符号在函数 "public: __clrcall mwException::mwException(void)" (??0mwException@@$$FQEAM@XZ) 中被引用
1>chuang.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __clrcall ref_count_obj_addref_proxy(class ref_count_obj *)" (?ref_count_obj_addref_proxy@@$$J0YMHPEAVref_count_obj@@@Z),该符号在函数 "public: __clrcall mwException::mwException(class mwException const &)" (??0mwException@@$$FQEAM@AEBV0@@Z) 中被引用
1>chuang.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __clrcall mclcppGetLastError_proxy(void * *)" (?mclcppGetLastError_proxy@@$$J0YMHPEAPEAX@Z),该符号在函数 "public: static void __clrcall mwException::raise_error(void)" (?raise_error@mwException@@$$FSMXXZ) 中被引用
1>chuang.obj : error LNK2019: 无法解析的外部符号 "extern "C" char const * __clrcall char_buffer_get_buffer_proxy(class char_buffer *)" (?char_buffer_get_buffer_proxy@@$$J0YMPEBDPEAVchar_buffer@@@Z),该符号在函数 "public: __clrcall mwString::operator char const *(void)const " (??BmwString@@$$FQEBMPEBDXZ) 中被引用
1>chuang.obj : error LNK2019: 无法解析的外部符号 "extern "C" class array_ref * __clrcall array_ref_deep_copy_proxy(class array_ref *)" (?array_ref_deep_copy_proxy@@$$J0YMPEAVarray_ref@@PEAV1@@Z),该符号在函数 "public: __clrcall mwArray::mwArray(class mwArray const &)" (??0mwArray@@$$FQEAM@AEBV0@@Z) 中被引用
1>chuang.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __clrcall array_ref_set_numeric_mxDouble_proxy(class array_ref *,double const *,unsigned __int64)" (?array_ref_set_numeric_mxDouble_proxy@@$$J0YMHPEAVarray_ref@@PEBN_K@Z),该符号在函数 "public: void __clrcall mwArray::SetData(double *,unsigned __int64)" (?SetData@mwArray@@$$FQEAMXPEAN_K@Z) 中被引用
1>chuang.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __clrcall char_buffer_set_buffer_proxy(class char_buffer *,char const *)" (?char_buffer_set_buffer_proxy@@$$J0YMHPEAVchar_buffer@@PEBD@Z),该符号在函数 "public: __clrcall mwString::mwString(class mwString const &)" (??0mwString@@$$FQEAM@AEBV0@@Z) 中被引用
ing@@$$FQEAM@AEBV0@@Z) 中被引用
@@$$FQEAM@_K0W4mxClassID@@W4mxComplexity@@@Z) 中被引用
1>E:\mat-vcc-test\chuang\x64\Debug\chuang.exe : fatal error LNK1120: 22 个无法解析的外部命令
1>

  • 写回答

1条回答

  • huairui008 2018-04-08 15:09
    关注

    装个matlab2017吧,可以直接生成工程。然后用vs打开工程编译就可以运行了

    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作