ROS2 compile a standalone node: undefined references to `std::__throw_bad_array_new_length()'
18 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
federico ciresola
il 17 Mag 2024
Modificato: Walter Roberson
il 7 Feb 2025 alle 22:21
Hi all,
I am trying to create a standalone node for ROS2 with a publisher (see schema below) and I am using the following tutorial to set up the model to generate the code:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1697521/image.png)
but when I compile it, I obtain the following error
undefined reference to `std::__throw_bad_array_new_length()
and I don't find a way to fix (below the imag with the error). I also got the same error with the Simulink model used in the tutorial.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1697526/image.png)
System info:
- OS: Ubuntu 22.04 LTS
- ROS2 version: Humble
- gcc version: 11.4.0
0 Commenti
Risposta accettata
Josh Chen
il 17 Mag 2024
Hi Federico,
Thanks for providing the system information. This error seems to be a compiler incompatible issue.
In R2023b version of MATLAB/Simulink, some internal packages were built with gcc-10. Hence, when compiling the Simulink model with gcc-11, you may see undefined reference errors.
This issue was resolved in the upcoming R2024b version, which uses gcc-12 to build those packages.
As a workaround for R2023b, you could consider installing gcc-10 on your machine so that the entire project uses the same gcc version during build process.
Best,
Josh
2 Commenti
mehdi
il 30 Gen 2025 alle 9:31
Modificato: Walter Roberson
il 7 Feb 2025 alle 22:21
hi, thank you very much for your guide but i couldn't choose C++10(ISO) on the Language Standard bar
i can only see C++03 AND C++11
how to change it to C++10???!
[later]
Hi Josh, do you have any idea what should i do?!
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Custom Message Support in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!