Microsoft MakeCode

C++ Compilation

I want to develop makecode extensions based on C++. I have many c++ libraries for arduino and would simply like to port it over with minor changes. I used github and the web browser to develop a simple extension, imported the extension via github url so I can edit the extension in the makecode editor. When I edit the C++ or h hile, any time i make a change it compiles immediately. It takes up to 2 minutes to compile and I can’t stop it. How can prevent this? Using the local builder still compiles the C++ every time I change the code in the browser. Its impossible to develop like this.

The C++ compiler doesn’t provide error messages as well. It will just say there’s an error at ‘base’ and nothing else.

Any help would be appreciated

Which editor are you specifically trying to use? To speed up c++ you will have to install our CLI and build from it using

     pxt build —local

I’m using the web browser (https://maker.makecode.com/#editor). I have installed it locally but its not helpful. If I simply comment out a line of code it will begin to compile on its own immediately. Serving the editor locally results in the same situation. If there is an error in the c code, it doesn’t provide the source of the error (see below).

Modifying C++ in the web browser will generate a request to our cloud compilation service – which will take minute(s) to complete. Instead, you will need to use the PXT command line.

  • download the program to .uf2
  • extract it to disk
pxt extract myprogram.uf2
  • build locally
pxt build --local

Following https://github.com/microsoft/pxt-maker/blob/master/README.md, I I’m unable to complete step 8. I get the error ‘Could not remove /node_modules/pxt-core’

Oh right… you need to delete node_modules/pxt-core and node_modules/pxt-common-packages.

1 Like

Hi. I tried building using above instructions, and got this error while building. Any idea please:

Building of code, using typescript extensions builds fine. Am I missing any toolchain? Thanks

You’ll need to install docker to run the c++ tool chain.

Thanks. I installed and I am now getting the error “docker: Error response from daemon: invalid mode: /src.”. Looks like path is not correctly set?

Does docker have access to your drive? Otherwise use “—cloud” to use the cloud compiler (much smaller)

In Windows you need to give permissions to Docker to access the host machine. I think it’s the “shared drives” setting described on this page: https://docs.docker.com/docker-for-windows/

@peli Yes, the --cloud compiler compiles and is much smaller. But when I make any small changes in .cpp files, it causes error:

edited
It starts with this, yeah seems that build is failed:

The complete log is very long. Can’t paste here

This means that the build Failed. The log above should have more details.

If you are editing the C++ code yourself you should not be using the —cloud option. Try to set up docker - see Richard’s instructions above.