Building cURL Applications Using CLI Tools

This article shows how to build a sample application using command line tools. The sample application uses Tizen Sockets Extension APIs and is based on the url2file cURL demo.


Before you can build the sample application:

  1. Install the Samsung Emscripten SDK as described in the WebAssembly overview.

  2. Install either Tizen Studio or Tizen Studio with CLI (command line interface). See the Quick-start Guide for more information.

Building the Application

To build the sample application:

  1. Download url2file.c.


    You can also clone the whole repository from

  2. Download CA certificates extracted from Mozilla:

    curl -O
  3. Compile the url2file.c demo:

    emcc -o url2file.html -Os -s ENVIRONMENT_MAY_BE_TIZEN -s USE_CURL=1 --proxy-to-worker --preload-file cacert.pem url2file.c
    Table 1: Compilation flags
    Flag Description
    -Os Flag used to reduce size of the generated WebAssembly module. It reduces the memory consumption of the WebAssembly module compilation on a device.
    -o url2file.html Flag indicating the name of the output file. The provided value makes the Samsung Emscripten SDK generate "url2file.wasm", "url2file.js", and "url2file.html" files.
    -s ENVIRONMENT_MAY_BE_TIZEN Flag indicating that you want to use the Tizen extensions to the Samsung Emscripten SDK available on a device. This flag is necessary to use POSIX sockets APIs in your application.
    -s USE_CURL=1 Flag indicating that you want to build and use the cURL library provided with the Samsung Emscripten SDK. Note that the full library is being built and cached during the first build, so compilation can take a while. For more details, see Emscripten Ports.
    --proxy-to-worker Flag needed to run the main() method of your application in a Web Worker. This is needed because because the Tizen Sockets Extension can only be used in a Web Worker.
    --preload-file cacert.pem Flag allowing your application to read the cacert.pem file using standard C APIs fopen(./cacert.pem)
    Table 2: Implicitly enabled compilation flags
    Flag Description
    -s USE_SSL=1 Enables the SSL library (libssl) from OpenSSL libraries. This flag is implicitly turned on by -s USE_CURL=1
    -s USE_CRYPTO=1 Enables the crypto library (libcrypto) from OpenSSL libraries. This flag is implicitly turned on by -s USE_SSL=1
    -s USE_ZLIB=1 Enables the zlib compression library. This flag is implicitly turned on by -s USE_CURL=1

    Further information regarding the Samsung Emscripten SDK build options can be found in the Emscripten Compiler Frontend (emcc) documentation.

  4. Download config.xml to the same directory where the demo was compiled.


    • This application needs the privilege.
    • The content src attribute points to "url2file.html" instead of standard index.html, as this is what was generated by emcc.

    For more information regarding the config.xml file format, see Tizen Developers.

  5. Sign and pack the application using the Tizen CLI interface:

    tizen package -t wgt -s <YOUR_CERTIFICATE_PROFILE_NAME> -- .

    For instructions on creating a certificate profile, see Creating Certificates.

    For more information regarding the Tizen CLI interface, see Command Line Interface Commands.

  6. Set your device into developer mode as described in Target Device.

  7. Connect to the device using SDB:

    sdb connect <TV_IP>

    For the SDB command and its options, see Connecting Devices over Smart Development Bridge.

  8. List the connected devices to determine the device number:

    sdb devices

    Sample output (the device number is 0):

    List of devices attached      device          0
  9. Install the application on the device:

    tizen install -n url2file.wgt -t 0

    In the parameter-t 0, the value 0 is the device number from the sdb devices command output.

  10. Run the application on the device:

    tizen run -p url2file00.curl -t 0