Embed is a program that converts a binary file into a C/C++ array definition.

The primary purpose of the Embed tool is to provide a simple method of embedding files into an application. This may be useful if you want to include firmware images, bitmaps, etc. in your application without having to read them first from an external source.


embed variable_name input_file output_file

variable_name is the name of the C/C++ array to be initialised with the binary data.

input_file is the path to the binary input file.

output_file is the path to the C/C++ source file to generate.


To convert a binary file image.bin to a C/C++ file called image.h:

embed img image.bin image.h

This will generate the following output in image.h:

static const unsigned char img[] = {
  0x5B, 0x95, 0xA4, 0x56, 0x16, 0x5F, 0x2D, 0x47,
  0xC5, 0x04, 0xD4, 0x8D, 0x73, 0x40, 0x31, 0x66,
  0x3E, 0x81, 0x90, 0x39, 0xA3, 0x8E, 0x22, 0x37,
  0x3C, 0x63, 0xC8, 0x30, 0x90, 0x0C, 0x54, 0xA4,
  0xA2, 0x74, 0xC2, 0x8C, 0x1D, 0x56, 0x57, 0x05,
  0x45, 0xCE, 0x3B, 0x92, 0xAD, 0x0B, 0x2C, 0x39,
  0x92, 0x59, 0xB9, 0x9D, 0x01, 0x30, 0x59, 0x9F,
  0xC5, 0xEA, 0xCE, 0x35, 0xF6, 0x4B, 0x05, 0xBF