Cannot use containers list, set

Hello there !

I’m currently trying to implement an algorithm who use list containers but I got some compilation errors. Several things are very strange :

This code works : (I mean, I can compile it)
std::vector<int> myVector ;
myVector.push_back(0) ;

This code works :
std::list<int> myList ;

This code doesn’t work when I use the make px4fmu-v3_default command but works when I use the make posix_sitl_default :

std::list<int> myList ;
myList.push_back(0) ;

I got this error :
[100%] Linking CXX executable firmware_nuttx
…/…/modules/commander/libmodules__commander.a(commander.cpp.obj): In function _M_insert<int>': /usr/include/newlib/c++/4.9.3/bits/stl_list.h:1689: undefined reference to std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)’
collect2: error: ld returned 1 exit status

Does someone fixed this problem yet ?

You’ll either have to look at libstdc++ options for Nuttx (px4fmu-v3_default), or stick to what’s available in PX4 (mathlib, matrix, etc). Do you actually need a std::list or could you get by with a simple array or linked list?

Thank you Dagar for your answer.

I added -lstdc++ in the Firmware/src/firmware/nuttx/CMakeLists.txt file.

target_link_libraries(firmware_nuttx -Wl,--warn-common -Wl,--gc-sections -Wl,--start-group -lstdc++ ${startup_libs} ${module_libraries} ${df_driver_libs} ${config_extra_libs} ${nuttx_bootloader_wrapers} ${link_libs} -Wl,--end-group)