2 Replies Latest reply on Oct 9, 2015 5:42 PM by CMata_Intel

    Is Intel Edison MCU SDK capable of compiling C++ for MCU?

    Majora

      Hello all,

       

      I am currently in the process of porting some C++ code for use on the Intel Edison MCU.  However, when I even began porting, I realized the SDK was giving me syntax errors all around any C++ specific code along with build errors when I attempted to compile (see console output and repro below.)  After doing a little research, it appears the errors I was getting where consistent with what you get when trying to compile C++ code with a C compiler.

       

      I admit that I don't know much about the Eclipse IDE and this might just be a simple as setting up the project differently, but so far I cannot find this documented.  Eclipse also has a project conversion tool for C -> C++ porting, but so far I have not gotten it work with the custom MCU project Template type.  I was also trying to isolate the build tools to perhaps compile the MCU code myself, but the only insight into the cross compiler is the IDE console output.  Using the console output I tracked down the supposed compiler in the toolchain directory, called i686-elf-gcc and attempted to recreate the console commands to compile but with the added "-x g++" flag, but then I got the error "i686-elf-gcc error:language c++ not recognized".  There is also a i686-elf-cpp program in the same directory as i686-elf-gcc, but I was unable to get that to compile using similar args for me either.

       

      I could really use a Makefile for the MCU along with the ability (or instructions) to upload said compiled code manually to the Edison.  Both these things are rather critical for an automatic build chain and an Intel Edison project that may go to production.

       

      To reproduce the issue:

      Start the MCU SDK, go to MCU -> New MCU Project  -> Templete Project (call its "cPlus") -> Finish

      Goto Project Explorer -> "cPlus" -> src -> (right click src) -> New -> Class -> (name class "test") and click ok (this will add an empty but stubbed out .cpp class file to your project with header)

      Inside mcu_main.c add '#include "test.h"'

      Goto MCU-> Build Project -> (select project "cPlus") -> OK

      Note the errors on console, particularly the line "error: unknown type name class" indicating that c++ syntax is invalid.

       

      or refer to the example code below.

       

      Build Console Output from SDK IDE

      14:34:00 **** Build of configuration Release for project cPlis ****

      make pre-build main-build

      Clean project before build

      make clean

      make[1]: Entering directory `/home/dev/Projects/EclipseWorkspace/cPlus/Release'

      rm -rf  ./src/mcu_main.o  ./src/mcu_main.d  libcPlus.a

       

      make[1]: Leaving directory `/home/dev/Projects/EclipseWorkspace/cPlus/Release'

       

      Building file: ../src/mcu_main.c

      Invoking: Cross GCC Compiler

      i686-elf-gcc -I"../include" -I"/home/dev/Downloads/edisonEclipse64/toolchain/linux-x86_64/i686-elf-gcc/i686-elf/include" -I"/home/dev/Downloads/edisonEclipse64/toolchain/linux-x86_64/i686-elf-gcc/i686-elf/usr/include" -I"/home/dev/Downloads/edisonEclipse64/toolchain/linux-x86_64/i686-elf-gcc/lib/gcc/i686-elf/4.6.1/include" -I"/home/dev/Downloads/edisonEclipse64/toolchain/linux-x86_64/i686-elf-gcc/lib/gcc/i686-elf/4.6.1/include-fixed" -O0 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/mcu_main.d" -MT"src/mcu_main.d" -o "src/mcu_main.o" "../src/mcu_main.c"

      In file included from ../src/mcu_main.c:3:0:

      ../src/test.h:11:1: error: unknown type name 'class'

      ../src/test.h:11:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token

      make: *** [src/mcu_main.o] Error 1

       

      14:34:00 Build Finished (took 188ms)

       

      It can be noted that on the MCU SDK website  that it mentions using the "Eclipse C/C++" SDK in a block diagram, which leads me to believe that C++ is supported.  But then on the same page in a foot note it also mentions that "The MCU SDK (Eclipse) is different and separate from the C/C++ Eclipse SDK for the Intel Atom processor" which might be there way of saying that C++ is not supported.  Other then those two references, I can find no other reference to the Intel Edsion IDE supporting C++ and have found no example code of the MCU running C++ code on the Intel sight or forums.


      For the lazy here is the example code:

      Test C++ code

      //mcu_main.c

      #include "test.h"

       

      void mcu_main()

      {

       

      }

      //test.h

       

      #ifndef TEST_H_

      #define TEST_H_

       

       

       

       

       

       

      class test {

        public:

           test();

           virtual ~test();

      };

       

      #endif

      //test.cpp

      #include "test.h"

       

      test::test() {

       

      }

       

      test::~test() {

       

      }

       

      Thanks for any help.

        • 1. Re: Is Intel Edison MCU SDK capable of compiling C++ for MCU?
          CMata_Intel

          Hi Majora,

           

          About the MCU SDK website (diagram), yes in the the components of the MCU SDK is included the "Eclipse C/C++" but this makes reference to the IDE itself not to the features of the MCU API.

          In other words you can create projects with C and C++ using the Eclipse IDE and also you can create projects for the MCU. But it not says that you can code scripts for the MCU using C and C++. I hope this clarifies a bit what the list of components of the MCU SDK includes.

           

          I reproduced the issue by following your instructions and got the same result. I was looking in the files and folders related to the MCU toolchain and I haven't found information about a G++ compiler. Also the libraries related to the MCU are .h and not .hpp.

          I will investigate about this, if there is a way to compile C++ code in the MCU SDK and let you know as soon as I get new results and/or updates.

           

          Kind regards,

          Charlie

          • 2. Re: Is Intel Edison MCU SDK capable of compiling C++ for MCU?
            CMata_Intel

            Hi Majora,

             

            The MCU does not have full support for C++, C/C++ compilers like g++ can not compile C++ for the MCU. The MCU IDE has a specific MCU compiler that has support only for the MCU APIs as documented in the MCU documents and basic C functions like "if" statement and "for" loops.