2017-02-06 12 views
1

나는 다음과 같은 온라인 라이브러리를 사용하는 .CPP 코드를 만들었습니다.컴파일 - - 포트란 코드로 연결 MEX 파일

내 코드에서 .mex 파일을 만들고 싶습니다. 내가 입력하고 때 :

이러한 오류가 발생 내 기능의
Error using mex 
/tmp/mex_7456790284416_24518/GUSTAVsolution.o: In function `MIEsolution::Spherical_Hankel_function(unsigned int, 
std::complex<double>, int)': 
GUSTAVsolution.cpp:(.text+0x18c): undefined reference to `zbesh_wrap' 
GUSTAVsolution.cpp:(.text+0x28e): undefined reference to `zbesh_wrap' 
/tmp/mex_7456790284416_24518/GUSTAVsolution.o: In function `MIEsolution::Spherical_Bessel_function_2k(unsigned int, 
std::complex<double>)': 
GUSTAVsolution.cpp:(.text+0x3dc): undefined reference to `zbesy_wrap' 
GUSTAVsolution.cpp:(.text+0x53d): undefined reference to `zbesj_wrap' 
/tmp/mex_7456790284416_24518/GUSTAVsolution.o: In function `MIEsolution::Spherical_Bessel_function_1k(unsigned int, 
std::complex<double>)': 
GUSTAVsolution.cpp:(.text+0x7a0): undefined reference to `zbesj_wrap' 
GUSTAVsolution.cpp:(.text+0x907): undefined reference to `zbesy_wrap' 
/tmp/mex_7456790284416_24518/GUSTAVsolution.o: In function 
`MIEsolution::Differentation_Spherical_Hankel_function(unsigned int, std::complex<double>, int)': 
GUSTAVsolution.cpp:(.text+0xb32): undefined reference to `zbesh_wrap' 
GUSTAVsolution.cpp:(.text+0xc4f): undefined reference to `zbesh_wrap' 
GUSTAVsolution.cpp:(.text+0xd30): undefined reference to `zbesh_wrap' 
GUSTAVsolution.cpp:(.text+0xe4d): undefined reference to `zbesh_wrap' 
/tmp/mex_7456790284416_24518/GUSTAVsolution.o: In function 
`MIEsolution::Differentation_Spherical_Bessel_function(unsigned int, std::complex<double>, int)': 
GUSTAVsolution.cpp:(.text+0xfb8): undefined reference to `zbesj_wrap' 
GUSTAVsolution.cpp:(.text+0x112b): undefined reference to `zbesy_wrap' 
GUSTAVsolution.cpp:(.text+0x1303): undefined reference to `zbesj_wrap' 
GUSTAVsolution.cpp:(.text+0x1476): undefined reference to `zbesy_wrap' 
GUSTAVsolution.cpp:(.text+0x161a): undefined reference to `zbesy_wrap' 
GUSTAVsolution.cpp:(.text+0x1787): undefined reference to `zbesj_wrap' 
GUSTAVsolution.cpp:(.text+0x1935): undefined reference to `zbesy_wrap' 
GUSTAVsolution.cpp:(.text+0x1aa2): undefined reference to `zbesj_wrap' 
collect2: error: ld returned 1 exit status 

하나는 :

complex<double> MIEsolution::Spherical_Bessel_function_2k(unsigned n,complex<double> z){ 

    complex<double> Sb2k; 

     Sb2k = sph_besselY(n, z); 

    return Sb2k; 

} 

요점은이 라이브러리는 일부 연결되어

mex GUSTAVsolution.cpp 

매트랩 다음과 같은 오류를 제공합니다 Fortran 코드와 C++. 예를 들어, sph_besselY 함수는 해당 포트란 코드 zbesy_wrap을 호출합니다.

저는 Fortran 함수를 어떻게 든 컴파일한다고 가정합니까? 웹 페이지와 동일한 방법으로 라이브러리를 설치했습니다. 또한, 나는 그렇게, 내 코드 라이브러리를 수입하고 여기 제안

#include <complex_bessel.h> 
+0

링커 명령 표시 ... 컴파일 된 C를 컴파일 된 Fortran과 링크합니다. 컴파일러 스위치 또는 BIND (C ...)와 함께 작동하는 밑줄과 같은 기호 문제가 있습니다. fortran에는 USE ISO_C_BINDING이 있습니다. 당신은 아마도 간단한 예를 원할 것입니다. 포트란에 BESSEL 함수가 내장되어 있습니다 ... – Holmz

답변

0

, 이것은 링커 플래그 -lcomplex_bessel을 추가 수정하려면 :

코드 :: 블록 IDE I에서 Compile simpleTest.cpp errors

Project->Build Options...->Linker Settings->Other linker options: 텍스트 상자에이 플래그를 설정하십시오.
mex에 대해서는이 하나가 작동하는지 모르겠다. 그러나 확실히이 링커 플래그를 어떻게 든 추가해야한다!

+0

OP가 Code :: Blocks를 어떻게 사용하는지 알 수 있습니까? –

+0

@VladimirF 나는 그것이 Matlab mex 컴파일러를 사용한다고 생각한다. 하지만 g ++과 C :: B를 사용하기 때문에 링커에'-lcomplex_bessel' 플래그가 설정되어 있지 않으면 같은 오류가 발생합니다. 그래서 컴파일러로서 Matlab mex 컴파일러는 어떻게 든 링커 플래그를주는 옵션을 가져야합니다! – Pekov