Mex select wrong linker

4 ビュー (過去 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 日
The solution is to give mex flag
mex -cxx

サインインしてコメントする。

回答 (2 件)

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 件のコメント
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?

サインインしてコメントする。


Michal Misiaszek
Michal Misiaszek 2019 年 7 月 31 日
Try to use
mex -cxx

カテゴリ

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by