|
안녕하세요,
Borland C++ 6.0 Builder에서 Matlab 함수를 호출하는 법에 대해 알고 싶습니다.
주로 나와 있는 예제들은 MS Visual C++ 에서 Matlab을 불러오는 것이라...
볼랜드 C++의 Project - Option - Directories/Conditional - Directories 부분에서 Matlab의 include file과 library file은 링크시켰는데, 그 후 프로그램을 작성하면 compile 및 실행 시 에러가 발생합니다. 제가 쓴 예제와 에러는 다음과 같습니다.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <stdio.h>
#include <stdlib.h>
#include "engine.h" // This file is needed to call the subroutines needed to call the MATLAB 6.0
Engine *ep;
mxArray *mp, *ans;
double *ar, *detreal;
int i, j;
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
mp = mxCreateDoubleMatrix(3, 3, 0);
mxSetName(mp, "A");
ar = mxGetPr(mp);
for(i=1;i<4;i++)
{
for(j=1;j<4;j++)
{
ar[i-1+3*(j-1)] = j*j*i*i;
}
}
}
//---------------------------------------------------------------------------
1. Compile 시 발생하는 에러입니다.
[C++ Warning] Unit1.cpp(31): W8006 Initializing mxComplexity with int
[C++ Error] Unit1.cpp(32): E2219 Wrong number of arguments in call of macro 'mxSetName'
[C++ Error] Unit1.cpp(32): E2379 Statement missing ;
2. Compile 시 발생하는 부분인 " mxSetName(mp, "A"); " 부분을 주석처리 해서 실행시키면 다음과 같은 실행 에러가 나타납니다.
[Linker Error] Unresolved external '_mxCreateDoubleMatrix' referenced from C:\DOCUMENTS AND SETTINGS\민배현\바탕 화면\8.22 C++에서 MATLAB 호출\UNIT1.OBJ
[Linker Error] Unresolved external '_mxGetPr' referenced from C:\DOCUMENTS AND SETTINGS\민배현\바탕 화면\8.22 C++에서 MATLAB 호출\UNIT1.OBJ
해결책을 모르겠습니다...어떻게 해야 볼랜드에서 매트랩을 호출할 수 있는 걸까요?
|