【问题标题】:link to c++ shared library generated by Matlab Compiler SDK链接到由 Matlab Compiler SDK 生成的 c++ 共享库
【发布时间】:2017-04-24 17:09:01
【问题描述】:

尝试部署与 Matlab 编译器 SDK 生成的 C++ 共享库集成的 C++ 代码。 Matlab编译SDK生成一个文件夹,包含test.h, test.so, and readme.txt

  1. 安装Matlab_runtime MCR 2.根据readme.txt编辑库链接路径 打开home目录,gedit~/.bashrc文件,根据readme.txt在文件中添加环境变量XAPPLRESDIR & LD_LIBRARY_PATH 3.编写驱动代码 main.cpp 并编译 main.cpp 代码使用:

g++ -L/home/yuan/Documents/Matlab2016b/Matlab_runtime/v91/extern/lib/glnxa64

-L/home/yuan/Documents/Matlab2016b/Matlab_runtime/v91/bin/glnxa64

-I/home/yuan/Documents/Matlab2016b/Matlab_runtime/v91/extern/include

-L./test main.cpp -o main

我得到了错误:

/tmp/cc3Xemzh.o: 在函数 main: main.cpp:(.text+0xa): undefined 引用 mclmcrInitialize_proxy

main.cpp:(.text+0x19): 未定义的引用 mclInitializeApplication_860_proxy

main.cpp:(.text+0x48): 未定义对 testInitialize 的引用

main.cpp:(.text+0x77): 未定义对 mlfTest 的引用

main.cpp:(.text+0x98): 对 testTerminate 的未定义引用

main.cpp:(.text+0x9d): 未定义的引用 `mclTerminateApplication_proxy

collect2: 错误:ld 返回 1 个退出状态

这应该是链接库的问题,但我不知道如何解决这个问题,有人可以帮忙吗?

【问题讨论】:

    标签: c++ shared-libraries matlab-compiler


    【解决方案1】:

    编辑库链接路径是不够的,You must explicitly link against mclmcrrt.so

    【讨论】:

      猜你喜欢
      • 2011-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多