Posted by: Morten Nobel-Jørgensen | March 12, 2011

Setting up Native Client in NetBeans 7.0

Google’s Native Client (NaCl) is a browser technology that allows you to run compiled C/C++ directly in the browser in a secure way. NaCl is cross platform and runs on multiple architectures. I’ll here give a short introduction to how to setup to use the NaCl-toolchain in NetBeans. I use OS/X, but I believe that the method described also works on Linux and Windows.

Setup NaCL project

This tutorial is created based on the ‘Gettings started‘-tutorial on the Native Client SDK webpage.

The first step, is to setup the NaCl on your computer (copied from the tutorial):

  • Download the Native Client SDK and complete the following steps:
  • Be sure you have a version of the Google Chrome browser that supports Native Client (version 10 or later). Install a new version of Google Chrome if necessary.
  • In addition, enable Native Client in Chrome by typing about:flags into the browser’s address bar and then click “Enable” under Native Client. Restart the browser (scroll down to the bottom of the page and click the Restart button).
  • On Mac or Linux systems, make sure you have Python installed.
  • Start the simple Python web server that is included in the SDK (in the examples/ directory) with the command python 5103. This runs the sample server at the following URL: http://localhost:5103.

Now you need to create a project. We’ll create the project in the example directory, since this allows you easily test your application (NaCl requires that the executable is recieved from a webserver).

Navigate to the directory project_templates/ and run the command following command to create the project hello_nb_cc:

python -d ../examples -n hello_nb_cc

Setup NetBeans

Install NetBeans IDE C/C++  7.0 (currently in beta).

Setup toolchain

To setup the toolchain open the preferences and select C/C++ -> Build tools click ‘Add…’. In the ‘Add New Tool Collection’ dialog set the Base Directory to ‘(installdir)/toolchain/mac_x86/bin’, set tool collection family to GNU and name it GNU_Native_Client:

Now set the following directories:

  • Base Directory: (installdir)/toolchain/mac_x86/bin
  • C Compiler: (installdir)/toolchain/mac_x86/bin/nacl-gcc
  • C++ Compiler: (installdir)/toolchain/mac_x86/bin/nacl-c++
  • Assembler: (installdir)/toolchain/mac_x86/bin/nacl-as

Click OK to finish setting up the toolchain.

Setup project

Choose C/C++ -> C/C++ Project with Existing Sources. In the next dialog select the directory examples/hello_nb_cc, set the Tool Collection to GLU_Native_Client and choose automatic or custom configuration.

You don’t need to change anything else in the project creation, so click Next until NetBeans allows you to click Finish.

You have now installed the project. Click Build in NetBeans to compile the project and verify that it works by open http://localhost:5103/hello_nb_cc/hello_nb_cc.html in Chrome. If the project is compiled succesfully you should see the following in the Chrome browser:

You can now do step 4-7 from the ‘Gettings started‘-tutorial to make the hello_nb_cc a little bit more meaningful.



  1. In the nightly build NaCl is now using sconf instead of make. To make Netbeans trigger the sconf, simple create a Makefile that invoke sconf.

  2. Or you can change the project settings (Build -> Make) to use
    ./scons -c
    for building and cleaning. It works fine for me.

  3. HI ! Really cool tutorial. But under windows I didn’t manage this way (no GNU installed)
    I had to install MingW (maybe Cygwin can be used), and selected Mingw instead of GNU.
    i also used Automatic instead of custom.
    Building from NetBeans worked like a charm with arm , x86_32n & x86_64 exe files generated from the hello world tutorial example project.
    Thank you!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: