小细节很多,所以容易出错.

平台:linux gcc matlab2010a

1 在matlab中写好函数例如branch,调用命令

mcc -W cpplib:libbranch -T link:lib branch.m -C

注意末尾的-C,很关键用于生成ctf文件,里面有执行需要的一些配置文件

2 将libbranch.so  libbranch.ctf放在同一个目录中,写c++程序main.cpp,需要branch.h branch.cpp

需要加入so:

mx mat mwmclmcrrt mwmclmcr branch (貌似顺序不能乱)

添加路径,很重要记得把依赖的libxm.so.3等路径加入/etc/ld.so.conf中

但是ld.so.conf中路径太多的话很容易互相影响,所以还是推荐链接时加上选项 -Wl,-rpath:/libxm.so.3.path

main.cpp中需要要#include "libbranch.h"

然后初始化需要
    if( !libbranchInitialize())
{
std::cout << "Could not initialize libbranch!" << std::endl;
return -1;
}

基本到此结束

相关文章:

  • 2022-01-07
  • 2021-12-15
  • 2021-06-04
  • 2022-12-23
  • 2022-02-26
  • 2021-06-07
  • 2021-07-22
猜你喜欢
  • 2021-11-30
  • 2021-11-30
  • 2021-10-22
  • 2021-06-16
  • 2021-05-04
  • 2021-12-06
  • 2021-11-29
相关资源
相似解决方案