Compiler properties for building MEX-files
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm working with MATLAB R2010b and need to compile a C++ source file to a .mex64 MEX-file.
I'm using the Microsoft VS2008 SP1 as a third party compiler.
mex.getCompilerConfigurations gives the following
mex.CompilerConfiguration
Package: mex
Properties:
Name: 'Microsoft Visual C++ 2008'
Manufacturer: 'Microsoft'
Language: 'C++'
Version: '9.0'
Location: 'C:\Program Files (x86)\Microsoft Visual Studio 9.0'
Details: [1x1 mex.CompilerConfigurationDetails]
So I think that the compiler is installed correctly. I tried to compile a simple hello.cpp file and it worked perfectly. However, my C++ source file requires the usage of MFC in a shared DLL. When I try to compile it in matlab using >>mex filenme.cpp I get the following error:
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ATLMFC\INCLUDE\afx.h(24) : fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Compile of 'filename.cpp' failed.
??? Error using ==> mex at 208
Unable to complete successfully.
How can I adjust the compiler used by MATLAB to use MFC in a Shared DLL? (as I guess that this is the problem, or?)
Thank you
0 Commenti
Risposte (1)
Kaustubha Govind
il 22 Lug 2011
Perhaps you should build your code in the Visual Studio IDE directly. See Custom Building MEX-Files for some tips. I would recommend get a simple MEX example to compile on the IDE (without using the MATLAB mex command), before you try your code.
Once you can compile your MEX-function on the IDE, you might want to follow generic Visual Studio steps to use the MFC. For example, this page suggests setting:
Project + Properties, General. Ensure Use of MFC is set to "Use MFC in a Shared Library".
This will ensure that all Visual Studio settings are configured for use of the MFC.
2 Commenti
Kaustubha Govind
il 27 Lug 2011
My best bet is that your Visual Studio project is not configured for an x64 target (by default, it is setup for a 32-bit target, and since libmat.lib, etc. are 64-bit libraries, they don't work with 32-bit projects).
Vedere anche
Categorie
Scopri di più su Beamforming and Direction of Arrival Estimation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!