Cross Compiling C++ code for Colibri iMX6ULL

Compiling C++ hello world program giving below Error.

${CC} -Wall hw.cpp -o hw

/tmp/ccL3wINt.o:hw.cpp:function main: error: undefined reference to ‘std::cout’
/tmp/ccL3wINt.o:hw.cpp:function main: error: undefined reference to ‘std::cout’
/tmp/ccL3wINt.o:hw.cpp:function main: error: undefined reference to ‘std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)’
/tmp/ccL3wINt.o:hw.cpp:function __static_initialization_and_destruction_0(int, int): error: undefined reference to ‘std::ios_base::Init::Init()’
/tmp/ccL3wINt.o:hw.cpp:function __static_initialization_and_destruction_0(int, int): error: undefined reference to ‘std::ios_base::Init::~Init()’
/tmp/ccL3wINt.o:hw.cpp:function __static_initialization_and_destruction_0(int, int): error: undefined reference to ‘std::ios_base::Init::~Init()’
collect2: error: ld returned 1 exit status

Hi @Arun229 and Welcome to the Toradex Community!

Could you provide the version of the Hardware and Software of your module?

Regarding your issue, have you looked at this?

Best regards,
Jaski

Maybe you are just missing the “-lstdc++” flag (or using ${CXX} instead)?

Hello @jaski.tx,

Thank you for your suggestion. Yes, I have gone through that example and followed the same steps.
Its working good for C hello World program but when I tried to compile the C++ program I got the error mentioned above.

Hardware version: Colibri iMX6 ULL Iris Rev 1.1

Hi @qojote,

Do I need to include the C++ library externally by mentioning the “-lstdc++” flag?

Thanks

Hi @jaski.tx
Thank you for your suggestion. Yes, I have gone through that example and followed the same steps. Its working good for C hello World program but when I tried to compile the C++ program I got the error mentioned above.

Did you try the suggestion of qojote?

Hi @qojote

Do I need to include C++ library externally by mentioning the “-lstdc++” flag?

Usually ${CC} expands to “arm-angstrom-linux-gnueabi-gcc” where one would need to specify additional C++ libraries. You could try ${CXX} instead.

Hi @jaski.tx,

I tried the suggestions of qojote and its working fine now. Thankyou !!!

Thankyou @qojote …It’s compiling both ways. thanks a lot !!!

Hi qojote, Thanks for your Input.

Perfect that it works. Thanks for the feedback.