Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Solutions Academia Support User Community Company
spacer spacer spacer spacer spacer spacer

Technical Solutions

Why can't I create an M-MEX DLL with the MATLAB Add-in for Visual Studio?


Date Last Modified: Friday, June 26, 2009
Solution ID:   1-18J1I
Product:   MATLAB
Platform:   Windows
Operating System:   Windows Any
 

Subject:

Why can't I create an M-MEX DLL with the MATLAB Add-in for Visual Studio?

Problem Description:

I get the following (or similar) errors when I try to create a MEX function from an M-file in the Visual MATLAB add-in for Microsoft Visual Studio (MSVC) using the M-MEX DLL Application type.
Linking...
LINK : error LNK2001: unresolved external symbol mexFunction
test1.lib : fatal error LNK1120: 1 unresolved externals
LINK : fatal error LNK1141: failure during build of exports file
Error executing link.exe.

Solution:

This is a bug in the MATLAB Add-in for Visual Studio in MATLAB 6.0 (R12) that has been fixed in MATLAB 6.1 (R12.1).

If you are still using MATLAB 6.0 (R12), the following workaround can be used:

1. Open your project in MSVC
2. Right click on your project
3. Go to 'Settings'
4. Go to the 'Linking' tab
5. Go to 'Category:' choose 'Input'
6. Under 'Project Options:' change 'export:mexFunction' to 'export:mexLibrary'
7. Click OK

Now you should be able to compile and link your project, and successfully call the DLL from MATLAB.

Please provide feedback to help us improve this Solution
Contact support
E-mail this page
Print this page