Why do I receive C++ linking errors using the MATLAB Compiler on Redhat/Mandrake Linux?

Why do I receive C++ linking errors using the MATLAB Compiler on Redhat/Mandrake Linux?
When I do the following:
/usr/matlab/bin/mbuild -v ex1.cpp
I receive the following errors:
ERROR: ex1.o(.text+0x41): In function `main':: undefined reference to `mwArray::mwArray[in-charge](int, int, double*, double*, int)'ex1.o(.text+0x5a): In function `main':: undefined reference to `mwArray::mwArray[in-charge](int, int, double*, double*, int)'ex1.o(.text+0x68): In function `main':: undefined reference to `mwArray::Write(std::basic_ostream<char, std::char_traits<char> >&) const'ex1.o(.text+0x88): In function `main':: undefined reference to `mwArray::Write(std::basic_ostream<char, std::char_traits<char> >&) const'ex1.o(.text+0xcd): In function `main':: undefined reference to `mwArray::Read(std::basic_istream<char, std::char_traints<char> >&, int)'ex1.o(.text+0xdb): In function `main':: undefined reference to `mwArray::Write(std::basic_ostream<char, std::char_traits<char> >&) const'ex1.o(.text+0x25d): In function _static_initialization_and_destruction_0(int, int)':: undefined reference to `mwLibraryInitBuiltins::mwLibraryInitBuiltins[in-charge]()'ex1.o(.text+0x2bc): In function `__tcf_0':: undefined reference to `mwLibraryInitBuiltins::~mwLibraryInitBuiltins [in-charge]()'collect2: ld returned 1 exit status mbuild: link of 'ex1' failed.
Or, I might see:
ERROR: /usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init': elf-init.oS(.text+0xb): undefined reference to `__init_array_end'elf-init.oS(.text+0x10): undefined reference to `__init_array_start'elf-init.oS(.text+0x23): undefined reference to `__init_array_start'/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_fini':elf-init.oS(.text+0x36): undefined reference to `__fini_array_end'elf-init.oS(.text+0x3b): undefined reference to `__fini_array_start'

 採用された回答

MathWorks Support Team
MathWorks Support Team 2026 年 7 月 29 日
編集済み: MathWorks Support Team 2026 年 7 月 29 日

0 投票

This problem is caused by the iostream C++ library change between the 2.95 and 3.x versions of g++ (g++ 2.95 was used for our development of MATLAB 6.5 (R13)). You should change to gcc/g++ 2.95 in order to compile and link without errors.
Beware of using g++/gcc 2.96, which is included in several popular linux distributions. We have had users report problems when attempting to use gcc/g++ 2.96. For more information, see the GNU announcement about gcc/g++ 2.96:

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeC Shared Library Integration についてさらに検索

製品

リリース

R13SP1

Community Treasure Hunt

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

Start Hunting!

Translated by