2
votes

Tried to deploy C++ code integrated with C++ shared library generated by Matlab compiler SDK. Matlab compiler SDK generated a folder including 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:

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

and I got errors:

/tmp/cc3Xemzh.o: In function main: main.cpp:(.text+0xa): undefined reference to mclmcrInitialize_proxy

main.cpp:(.text+0x19): undefined reference to mclInitializeApplication_860_proxy

main.cpp:(.text+0x48): undefined reference to testInitialize

main.cpp:(.text+0x77): undefined reference to mlfTest

main.cpp:(.text+0x98): undefined reference to testTerminate

main.cpp:(.text+0x9d): undefined reference to `mclTerminateApplication_proxy

collect2: error: ld returned 1 exit status

This should be the linking library problem, but I don't know how to fix this , anyone can help?

1

1 Answers

0
votes

It is not enough to edit the library link path, You must explicitly link against mclmcrrt.so.