Use of matlab generated dll in VisualStudio C++

We want to use matlab generated dll in VisualStudio.
First System: Windows7 64bit, MatlabR2012b 32bit with Matlab Compiler
Second System: WindowsXP 32 bit, Matlab Runtime R2012b 32bit (MCR 8.0), Microsoft VisualStudio 2008
First we try the matlab example in extern/examples/compiler and the Help description in Matlab Compiler-> Shared Libraries ->Integrate CShared Libraries
1. We get addmatrix.m, multiplymatrix.m, eigmatrix.m
2. On first system the matlab compiler generates a “C Shared Library” (NOT C++ shared lib) and we get libmatrix.h, libmatrix.lib and libmatrix.dll
3. On the second system we create a new project in VisualStudio. We have only one C-source from the example matrixdriver.c
The project properties we set: Additional include to find libmatrix.h
Linker additional dependancies: libmatrix.lib, mclmcrrt.lib
Additional library path: to find libmatrix.dll and C:\Programme\Matlab\Matlab Compiler Runtime\extern\lib\win32\microsoft
4. libmatrix.dll is set in the same path as matrixdriver.exe The path to the matalb-dlls was set automatically in the environment variable “path” with the installation of MCR.
The compilation and linking works fine but the execution results in a runtime error.

3 Comments

Please specify what the runtime error message says.
The error occurs before any statement of my own code.
In debugger stack: matrixdriver.exe!mainCRTStartup() line 398 matrixdriver.exe!__security_init_cookie() line 127 next step->unhandled exception ...
I will try to build the dll with the same C-compiler from VisualStudio. Maybe the mix of compilers ends with a mess.
Solution:
On the first system I install VisualStudio 2010 and choose this C-Compiler in Matlab with "build -setup". So there is no mix of Compilers and all works fine.

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 13 May 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!