Sample code/Cpp/Hello World

bocdarorc4 This page presents a C++ variation of the classic C "Hello World" program

The source
The source code for the hello.cpp is presented here:
 * 1) include

int main( int argc, char **argv ) {   std::cout << "Hello World" << std::endl; return 0; }

There is also a simple Makefile which you can use as a starting point for creating your own Makefiles.

This Makefile assumes that you create a directory parallel to the gumstix-buildroot (i.e. on my system, gumstix-build root can be found at /home/dhylands/gumstix/gumstix-buildroot, so for the hello-world-cpp example, I'd create /home/dhylands/gumstix/hello-world-cpp).

Copy in the hello.cpp and Makefile into your hello-world-cpp directory and type make. You should see something like the following: rm -f .depend /home/dhylands/gumstix/hello-world-cpp/../gumstix-buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-uclibc-g++  -M hello.cpp >> .depend /home/dhylands/gumstix/hello-world-cpp/../gumstix-buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-uclibc-g++  -Os -march=armv5te -mtune=xscale -Wa,-mcpu=xscale -c -o hello.o hello.cpp /home/dhylands/gumstix/hello-world-cpp/../gumstix-buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-uclibc-g++ -Os -march=armv5te -mtune=xscale -Wa,-mcpu=xscale hello.o   -o hello

Enabling the C++ compiler (revision 1444 and later)
Starting with revision 1444 (when the verdex branch was merged into the main branch) the C++ compiler is enabled by default. So this means you shouldn't have to do anything. You can double check by doing: cd gumstix-buildroot grep LIBSTDCPP .config

and you should see: BR2_INSTALL_LIBSTDCPP=y

If for some reason, it's not enabled, you can follow the steps below to enable it.

Enabling the C++ compiler (revision 775 and later)
By default, the C++ compiler is not enabled as part of buildroot. You'll also want to use an XM variant of the gumstix (16 Mb flash) since the C++ runtime library is too big to use with the 4Mb flash version of the gumstix. There are ways to use it from an external card, see Robostix gumstix ISP since uisp is compiled using C++.

These steps assume that you've already installed buildroot. To enable and build the C++ compiler, perform the following steps: cd gumstix-buildroot make menuconfig Go under Toolchain Option Enable: Build/install c++ compiler and libstdc++? Exit, saving your changes rm toolchain_build_arm_nofpu/gcc-*-final/.configured make

You can double check that the C++ compiler is enabled by doing: grep LIBSTDCPP .config

If you see:
 * 1) BR2_INSTALL_LIBSTDCPP is not set

then building the C++ compiler is disabled. If you see: BR2_INSTALL_LIBSTDCPP=y

then everything is enabled properly.

If, for some reason, the above doesn't work, then try: rm -rf toolchain_build_arm_nofpu make