Mex select wrong linker

조회 수: 3 (최근 30일)
Matteo Lodi
Matteo Lodi 2018년 3월 14일
댓글: Wilson González 2021년 5월 14일
I have a problem with mex linker.
I have two files a.cpp and b.cpp and I create both object files a.obj and b.obj through mex -c command. Now I want to create the executable mex file through mex a.obj b.obj but when I try I get the error "undefined reference to operator new". Then I try with -v and -n options and I see that matlab uses gcc to link files instead of g++!
How can I manually switch between c\c++ compiler?
  댓글 수: 2
Michal Misiaszek
Michal Misiaszek 2019년 7월 31일
I have same problem and mex -setup c++ does not solve it.
Michal Misiaszek
Michal Misiaszek 2019년 7월 31일
The solution is to give mex flag
mex -cxx

댓글을 달려면 로그인하십시오.

답변 (2개)

Michal Misiaszek
Michal Misiaszek 2019년 7월 31일
Try to use
mex -cxx

Sonam Gupta
Sonam Gupta 2018년 3월 26일
mex -setup command helps you to select the desired compiler. Following documentation provides more information about the same:
  댓글 수: 2
Michal Misiaszek
Michal Misiaszek 2019년 7월 31일
I use mex -setup command to set it to C++ but when I call mex to link object files it goes back to C instead of C++. How I can force mext to use g++ ? Please note I am just linking with MEX not compiling.
Wilson González
Wilson González 2021년 5월 14일
Having a similar situation to link .o files previously compiled with gfortran. Have you found a solution?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 External Language Interfaces에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by