简体   繁体   English

链接到Matlab编译器SDK生成的c ++共享库

[英]link to c++ shared library generated by Matlab Compiler SDK

Tried to deploy C++ code integrated with C++ shared library generated by Matlab compiler SDK . 试图部署与Matlab编译器SDK生成的C ++共享库集成的C ++代码 Matlab compiler SDK generated a folder including test.h, test.so, and readme.txt Matlab编译器SDK生成了一个包含test.h, test.so, and readme.txt的文件夹

  1. Install Matlab_runtime MCR 2. Edit the library link path according to the readme.txt Open home directory and gedit ~/.bashrc file, add the environment variable XAPPLRESDIR & LD_LIBRARY_PATH in the file according to readme.txt 3. Write the driver code main.cpp and Compile the main.cpp code use: 安装Matlab_runtime MCR2。根据readme.txt编辑库链接路径打开主目录并gedit〜/ .bashrc文件,根据readme.txt在文件中添加环境变量XAPPLRESDIR和LD_LIBRARY_PATH 3.编写驱动程序主代码。 cpp和编译main.cpp代码使用:

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

-L/home/yuan/Documents/Matlab2016b/Matlab_runtime/v91/bin/glnxa64 -L /家庭/元/文档/ Matlab2016b / Matlab_runtime / V91 /斌/ glnxa64

-I/home/yuan/Documents/Matlab2016b/Matlab_runtime/v91/extern/include -I /家庭/元/文档/ Matlab2016b / Matlab_runtime / V91 / EXTERN /包括

-L./test main.cpp -o main -L./测试main.cpp -o main

and I got errors: 我有错误:

/tmp/cc3Xemzh.o: In function main: main.cpp:(.text+0xa): undefined reference to mclmcrInitialize_proxy /tmp/cc3Xemzh.o:在函数main中:main.cpp :(。text + 0xa):对mclmcrInitialize_proxy的未定义引用

main.cpp:(.text+0x19): undefined reference to mclInitializeApplication_860_proxy main.cpp :(。text + 0x19):对mclInitializeApplication_860_proxy的未定义引用

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

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

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

main.cpp:(.text+0x9d): undefined reference to `mclTerminateApplication_proxy main.cpp :(。text + 0x9d):对`mclTerminateApplication_proxy的未定义引用

collect2: error: ld returned 1 exit status collect2:错误:ld返回1退出状态

This should be the linking library problem, but I don't know how to fix this , anyone can help? 这应该是链接库问题,但是我不知道该如何解决,任何人都可以帮忙吗?

仅编辑库链接路径是不够的。 您必须显式链接mclmcrrt.so

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM