본문 바로가기
개발/Matlab

Matlab Coder Unknown compiler 오류 메시지 해결 방법

by belitino 2013. 10. 22.

출처: http://www.mathworks.com/matlabcentral/answers/69173

 

프로젝트 납기일 때문에 어쩔 수 없이 Matlab 코딩을 C/C++로 바꿔서 사용해야할 경우가 생겼습니다. Matlab으로 간단한 기능만 짜봤지 C/C++로 변환하는 것은 처음이었는데 Matlab Coder를 처음 돌리자마자 Unknown Compiler라는 오류 메시지가 발생하면서 코드 생성이 안됐습니다.

 

구글링 해보니 Matlab에서 설치된 C/C++ 컴파일러의 위치를 몰라서 그렇다는군요. Matlab 설치할 때 알아서 C/C++ 컴파일러 설치 디렉토리를 검색해서 설치할 것이지 은근히 귀찮게 하는군요.

 

해결 방법은 간단합니다. 다음과 같이 command 창에서 mex -setup을 돌리면 됩니다.

저의 경우는 Visual Studio 2010/2012가 깔려 있어서 둘 중 하나를 선택했습니다.

 

Matlab Compiler의 경우도 이와 유사하게 command 창에서 mbuild -setup을 돌려줘야 하네요

 

C:\>mex -setup

Welcome to mex -setup.  This utility will help you set up
a default compiler.  For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/win64.html

Please choose your compiler for building MEX-files:

Would you like mex to locate installed compilers [y]/n?

Select a compiler:
[1] Microsoft Visual C++ 2012 in C:\Program Files (x86)\Microsoft Visual Studio
11.0
[2] Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio
10.0

[0] None

Compiler: 2

Please verify your choices:

Compiler: Microsoft Visual C++ 2010
Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0

Are these correct [y]/n? y

***************************************************************************
  Warning: MEX-files generated using Microsoft Visual C++ 2010 require
           that Microsoft Visual Studio 2010 run-time libraries be
           available on the computer they are run on.
           If you plan to redistribute your MEX-files to other MATLAB
           users, be sure that they have the run-time libraries.
***************************************************************************


Trying to update options file: C:\Users\AppData\Roaming\MathWorks\MATLA
B\R2013a\mexopts.bat
From template:              C:\PROGRA~1\MATLAB\R2013a\bin\win64\mexopts\msvc100o
pts.bat

Done . . .

**************************************************************************
  Warning: The MATLAB C and Fortran API has changed to support MATLAB
           variables with more than 2^32-1 elements.  In the near future
           you will be required to update your code to utilize the new
           API. You can find more information about this at:
           http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-fi
les-to-use-64-bit-api.html
           Building with the -largeArrayDims option enables the new API.
**************************************************************************

C:\>