In simulink we can call C++ shared library functions using S-functions. Let main s-function file be main.cpp and shared library file be sharedObject.so. Compile the files and create a mex executable by calling the command
mex main.cpp -Ipath_to_.so_file)/sharedObject.so
Call the generated mex file in s-function block in simulink.
Hope this workaround using simulink works for you. For more information on s-functions type sfundemos in MATLAB command promt and see existing examples.
I am attaching a document containing a sample program.