ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [MATLAB] MATLAB 2010a 와 Visual Studio 2010 연동하기
    Tech/Development 2011. 7. 6. 21:45

    지난 번 포스팅에서 64-bit Windows 7 에서 MATLAB2010a을 사용할 때, C/C++ 소스 파일과의 연동을 위해 64-bit compiler를 설치하는 법을 포함하였는데, 빠진 부분이 있다.


     64-bit 운영체제에서 MATLAB2010a가 64-bit compiler를 자동으로 포함하여 설치하지 않아, 이를 따로 설치해주는 것이지만, 이 때 Visual Studio 2010 버젼은 MATLAB 2010a와 호환되지 않는다. (MATLAB 2010a 기존의 mex는 Visual Studio 2008 SP1 까지 지원한다.)


     따라서 MATLAB 2010a에서 Visual Studio 2010과 연동하려면 mex file을 update해야 하는데, Mathworks 공식 홈페이지에 해결법이 자세히 올라와 있다.


    Mathworks 공식 홈페이지에서 확인하기


    해결 방법을 설명하면 아래와 같다.


    1. 다음 파일을 다운 받는다. 이 파일은 Visual Studio 2010과 MATLAB2010a를 연동시켜준다. (꼭 MATLAB2010a 에서만 사용할 것)
    2. 압축 파일을 MATLAB 설치 디렉토리에 풀면 되는데, MATLAB에서도 UNZIP 명령을 지원하므로 MATLAB에서 풀면 편하다. 이 때에 MATLAB 설치 디렉토리는 matlabroot 라는 이름의 변수로 선언되어 있으므로!
      • >> unzip( 'VS2010MEXSupport.zip', matlabroot);
    3. MEX 를 업데이트하자.
      • >> mex -setup
        Please choose your compiler for building external interface (MEX) files:
         
        Would you like mex to locate installed compilers [y]/n? y
         
        Select a compiler:
        [1] Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
         
        [0] None
         
        Compiler: 1
         
        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\jun\AppData\Roaming\MathWorks\MATLAB\R2010a\mexopts.bat
        From template:              C:\PROGRA~1\MATLAB\R2010a\bin\win64\mexopts\msvc100opts.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/support/solutions/en/data/1-5C27B9/?solution=1-5C27B9
                   Building with the -largeArrayDims option enables the new API.
        **************************************************************************
         
        >>

    Enjoy your MATLAB2010a with Visual Studio 2010!


    댓글

Copyright 2022 JY