OLD | NEW |
1 .. _sdk-examples-2: | 1 .. _sdk-examples-2: |
2 | 2 |
3 .. TODO: After default toolchain is changed to pnacl, recreate the make examples
. | 3 .. TODO: After default toolchain is changed to pnacl, recreate the make examples
. |
4 | 4 |
5 Examples | 5 Examples |
6 ======== | 6 ======== |
7 | 7 |
8 Every Native Client SDK bundle comes with a folder of example applications. | 8 Every Native Client SDK bundle comes with a folder of example applications. |
9 Each example demonstrates one or two key Native Client programming concepts. | 9 Each example demonstrates one or two key Native Client programming concepts. |
10 After you've :doc:`downloaded the SDK <download>`, follow the instructions | 10 After you've :doc:`downloaded the SDK <download>`, follow the instructions |
11 on this page to build and run the examples. | 11 on this page to build and run the examples. |
12 | 12 |
13 Your version of Chrome must be equal to or greater than the version of your SDK | 13 Your version of Chrome must be equal to or greater than the version of your SDK |
14 bundle. For example, if you're developing with the ``pepper_35`` bundle, you | 14 bundle. For example, if you're developing with the ``pepper_35`` bundle, you |
15 must use Google Chrome version 35 or greater. To find out what version of Chrome | 15 must use Google Chrome version 35 or greater. To find out what version of Chrome |
16 you're using, type ``about:chrome`` or ``about:version`` in the Chrome address | 16 you're using, type ``about:chrome`` or ``about:version`` in the Chrome address |
17 bar. | 17 bar. |
18 | 18 |
19 .. _build-the-sdk-examples: | 19 .. _build-the-sdk-examples: |
20 | 20 |
21 Build the SDK examples | 21 Build the SDK examples |
22 ---------------------- | 22 ---------------------- |
23 | 23 |
24 The Makefile scripts for the SDK examples can build multiple versions of the | 24 The Makefile scripts for the SDK examples can build multiple versions of the |
25 examples using any of the three SDK toolchains (newlib, glibc, and PNaCl) and in | 25 examples using any of the three SDK toolchains (clang-newlib, glibc, and PNaCl) |
26 both release and debug configurations. Note that some examples, ``dlopen`` for | 26 and in both release and debug configurations. Note that some examples, |
27 example, build only with particular toolchains. | 27 ``dlopen`` for example, build only with particular toolchains. |
28 | 28 |
29 Find the toolchains for each example by looking at the ``VALID_TOOLCHAINS`` | 29 Find the toolchains for each example by looking at the ``VALID_TOOLCHAINS`` |
30 variable in the Makefile for a particular example. The first item listed is the | 30 variable in the Makefile for a particular example. The first item listed is the |
31 default. It's built when you run an example make file without parameters. for | 31 default. It's built when you run an example make file without parameters. for |
32 example running make in the ``core`` directory of pepper_35 builds the example | 32 example running make in the ``core`` directory of pepper_35 builds the example |
33 using the ``newlib`` toolchain. :: | 33 using the ``glibc`` toolchain. :: |
34 | 34 |
35 $ cd pepper_35/examples/api/core | 35 $ cd pepper_35/examples/api/core |
36 $ make | 36 $ make |
37 CXX newlib/Release/core_x86_32.o | 37 CXX glibc/Release/core_x86_32.o |
38 LINK newlib/Release/core_unstripped_x86_32.nexe | 38 LINK glibc/Release/core_unstripped_x86_32.nexe |
39 VALIDATE newlib/Release/core_unstripped_x86_32.nexe | 39 VALIDATE glibc/Release/core_unstripped_x86_32.nexe |
40 CXX newlib/Release/core_x86_64.o | 40 CXX glibc/Release/core_x86_64.o |
41 LINK newlib/Release/core_unstripped_x86_64.nexe | 41 LINK glibc/Release/core_unstripped_x86_64.nexe |
42 VALIDATE newlib/Release/core_unstripped_x86_64.nexe | 42 VALIDATE glibc/Release/core_unstripped_x86_64.nexe |
43 CXX newlib/Release/core_arm.o | 43 CXX glibc/Release/core_arm.o |
44 LINK newlib/Release/core_unstripped_arm.nexe | 44 LINK glibc/Release/core_unstripped_arm.nexe |
45 VALIDATE newlib/Release/core_unstripped_arm.nexe | 45 VALIDATE glibc/Release/core_unstripped_arm.nexe |
46 STRIP newlib/Release/core_x86_32.nexe | 46 STRIP glibc/Release/core_x86_32.nexe |
47 STRIP newlib/Release/core_x86_64.nexe | 47 STRIP glibc/Release/core_x86_64.nexe |
48 STRIP newlib/Release/core_arm.nexe | 48 STRIP glibc/Release/core_arm.nexe |
49 CREATE_NMF newlib/Release/core.nmf | 49 CREATE_NMF glibc/Release/core.nmf |
50 | 50 |
51 As you can see, this produces a number of architecture specific nexe files in | 51 As you can see, this produces a number of architecture specific nexe files in |
52 the ``pepper_35/examples/api/core/Release`` directory. Create debug versions by | 52 the ``pepper_35/examples/api/core/Release`` directory. Create debug versions by |
53 using the ``CONFIG`` parameter of the make command. :: | 53 using the ``CONFIG`` parameter of the make command. :: |
54 | 54 |
55 $make CONFIG=Debug | 55 $make CONFIG=Debug |
56 | 56 |
57 This creates similar output, but in ``pepper_35/examples/api/core/Debug``. | 57 This creates similar output, but in ``pepper_35/examples/api/core/Debug``. |
58 | 58 |
59 Select a different toolchain with the ``TOOLCHAIN`` parameter. For example:: | 59 Select a different toolchain with the ``TOOLCHAIN`` parameter. For example:: |
60 | 60 |
61 $ cd pepper_35/examples/api/core | 61 $ cd pepper_35/examples/api/core |
62 $ make TOOLCHAIN=pnacl CONFIG=Release | 62 $ make TOOLCHAIN=pnacl CONFIG=Release |
63 CXX pnacl/Release/core.o | 63 CXX pnacl/Release/core.o |
64 LINK pnacl/Release/core_unstripped.bc | 64 LINK pnacl/Release/core_unstripped.bc |
65 FINALIZE pnacl/Release/core_unstripped.pexe | 65 FINALIZE pnacl/Release/core_unstripped.pexe |
66 CREATE_NMF pnacl/Release/core.nmf | 66 CREATE_NMF pnacl/Release/core.nmf |
67 | 67 |
68 You can also set ``TOOLCHAIN`` to ``all`` to build all Release versions with | 68 You can also set ``TOOLCHAIN`` to ``all`` to build all Release versions with |
69 default toolchains. :: | 69 default toolchains. :: |
70 | 70 |
71 $ cd pepper_35/examples/api/core | 71 $ cd pepper_35/examples/api/core |
72 $ make TOOLCHAIN=all | 72 $ make TOOLCHAIN=all |
73 make TOOLCHAIN=newlib | 73 make TOOLCHAIN=clang-newlib |
74 make[1]: Entering directory 'pepper_35/examples/api/core' | 74 make[1]: Entering directory 'pepper_35/examples/api/core' |
75 CXX newlib/Release/core_x86_32.o | 75 CXX clang-newlib/Release/core_x86_32.o |
76 LINK newlib/Release/core_unstripped_x86_32.nexe | 76 LINK clang-newlib/Release/core_unstripped_x86_32.nexe |
77 VALIDATE newlib/Release/core_unstripped_x86_32.nexe | 77 VALIDATE clang-newlib/Release/core_unstripped_x86_32.nexe |
78 CXX newlib/Release/core_x86_64.o | 78 CXX clang-newlib/Release/core_x86_64.o |
79 LINK newlib/Release/core_unstripped_x86_64.nexe | 79 LINK clang-newlib/Release/core_unstripped_x86_64.nexe |
80 VALIDATE newlib/Release/core_unstripped_x86_64.nexe | 80 VALIDATE clang-newlib/Release/core_unstripped_x86_64.nexe |
81 CXX newlib/Release/core_arm.o | 81 CXX clang-newlib/Release/core_arm.o |
82 LINK newlib/Release/core_unstripped_arm.nexe | 82 LINK clang-newlib/Release/core_unstripped_arm.nexe |
83 VALIDATE newlib/Release/core_unstripped_arm.nexe | 83 VALIDATE clang-newlib/Release/core_unstripped_arm.nexe |
84 STRIP newlib/Release/core_x86_32.nexe | 84 STRIP clang-newlib/Release/core_x86_32.nexe |
85 STRIP newlib/Release/core_x86_64.nexe | 85 STRIP clang-newlib/Release/core_x86_64.nexe |
86 STRIP newlib/Release/core_arm.nexe | 86 STRIP clang-newlib/Release/core_arm.nexe |
87 CREATE_NMF newlib/Release/core.nmf | 87 CREATE_NMF clang-newlib/Release/core.nmf |
88 make[1]: Leaving directory 'pepper_35/examples/api/core' | 88 make[1]: Leaving directory 'pepper_35/examples/api/core' |
89 make TOOLCHAIN=glibc | 89 make TOOLCHAIN=glibc |
90 make[1]: Entering directory 'pepper_35/examples/api/core' | 90 make[1]: Entering directory 'pepper_35/examples/api/core' |
91 CXX glibc/Release/core_x86_32.o | 91 CXX glibc/Release/core_x86_32.o |
92 LINK glibc/Release/core_unstripped_x86_32.nexe | 92 LINK glibc/Release/core_unstripped_x86_32.nexe |
93 VALIDATE glibc/Release/core_unstripped_x86_32.nexe | 93 VALIDATE glibc/Release/core_unstripped_x86_32.nexe |
94 CXX glibc/Release/core_x86_64.o | 94 CXX glibc/Release/core_x86_64.o |
95 LINK glibc/Release/core_unstripped_x86_64.nexe | 95 LINK glibc/Release/core_unstripped_x86_64.nexe |
96 VALIDATE glibc/Release/core_unstripped_x86_64.nexe | 96 VALIDATE glibc/Release/core_unstripped_x86_64.nexe |
97 ... | 97 ... |
98 (content excerpted) | 98 (content excerpted) |
99 ... | 99 ... |
100 | 100 |
101 .. _build-results: | 101 .. _build-results: |
102 | 102 |
103 Build results | 103 Build results |
104 ^^^^^^^^^^^^^ | 104 ^^^^^^^^^^^^^ |
105 | 105 |
106 After running ``make``, example directories will contain one or more of the | 106 After running ``make``, example directories will contain one or more of the |
107 following subdirectories, depending on which Makefile you run: | 107 following subdirectories, depending on which Makefile you run: |
108 | 108 |
109 * ``newlib`` with subdirectories ``Debug`` and ``Release``; | 109 * ``clang-newlib`` with subdirectories ``Debug`` and ``Release``; |
110 * ``glibc`` with subdirectories ``Debug`` and ``Release``; | 110 * ``glibc`` with subdirectories ``Debug`` and ``Release``; |
111 * ``pnacl`` with subdirectories ``Debug`` and ``Release``; | 111 * ``pnacl`` with subdirectories ``Debug`` and ``Release``; |
112 | 112 |
113 For the newlib and glibc toolchains the Debug and Release subdirectories | 113 For the clang-newlib and glibc toolchains the Debug and Release subdirectories |
114 contain .nexe files for all target architectures. For the PNaCl toolchain | 114 contain .nexe files for all target architectures. For the PNaCl toolchain |
115 they contain a single .pexe file. PNaCl debug also produces pre-translated | 115 they contain a single .pexe file. PNaCl debug also produces pre-translated |
116 .nexe files, for ease of debugging. All Debug and Release directories contain | 116 .nexe files, for ease of debugging. All Debug and Release directories contain |
117 a manifest (.nmf) file that references the associated .nexe or .pexe files. | 117 a manifest (.nmf) file that references the associated .nexe or .pexe files. |
118 For information about Native Client manifest files, see the :doc:`Technical | 118 For information about Native Client manifest files, see the :doc:`Technical |
119 Overview <../overview>`. | 119 Overview <../overview>`. |
120 | 120 |
121 For details on how to use ``make``, see the `GNU 'make' Manual | 121 For details on how to use ``make``, see the `GNU 'make' Manual |
122 <http://www.gnu.org/software/make/manual/make.html>`_. For details on how to | 122 <http://www.gnu.org/software/make/manual/make.html>`_. For details on how to |
123 use the SDK toolchain itself, see :doc:`Building Native Client Modules | 123 use the SDK toolchain itself, see :doc:`Building Native Client Modules |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 249 |
250 At this point, you can use the standard GDB commands to debug your NaCl module. | 250 At this point, you can use the standard GDB commands to debug your NaCl module. |
251 The most common commands you will use to debug are ``continue``, ``step``, | 251 The most common commands you will use to debug are ``continue``, ``step``, |
252 ``next``, ``break`` and ``backtrace``. See | 252 ``next``, ``break`` and ``backtrace``. See |
253 :doc:`Debugging <../devguide/devcycle/debugging>` for more information about | 253 :doc:`Debugging <../devguide/devcycle/debugging>` for more information about |
254 debugging a Native Client application. | 254 debugging a Native Client application. |
255 | 255 |
256 | 256 |
257 .. |menu-icon| image:: /images/menu-icon.png | 257 .. |menu-icon| image:: /images/menu-icon.png |
258 .. |gear-icon| image:: /images/gear-icon.png | 258 .. |gear-icon| image:: /images/gear-icon.png |
OLD | NEW |