Building cURL Applications Using Tizen Studio
building curl applications using tizen studio this topic describes how to build a sample application with tizen studio the sample application uses tizen sockets extension apis and is based on the url2file curl demo related info webassembly getting started using tizen studio for webassembly url2file curl demo prerequisites before you can build the sample application install the samsung emscripten sdk as described in webassembly overview install tizen studio as described in quick-start guide set up tizen studio and the samsung emscripten sdk toolchain as described in creating webassembly applications building the application to build a sample application based on url2file curl demo with tizen studio launch tizen studio create a project in tizen studio select "file > new > tizen project" select "template" and click "next" select "tv" and click "next" select "web application", check the "webassembly c/c++ " checkbox and click "next" select "empty project" and click "next" give a name to your project such as "hellocurl" and click "next" provide the required samsung emscripten sdk toolchain paths and click "finish" add the http //tizen org/privilege/internet privilege to your application for more information, see configuring web applications add a new webassembly module to your project right-click on your project in "project explorer" from the context menu, select "new > webassembly module" choose "empty module" and click "next" give a name to your module such as "hellocurl_module" add a "textarea" by selecting the "on" checkbox this “textarea” displays the logs the webassembly module writes to stdout click "finish" either replace the contents of src/empty cpp file in the created webassembly module with the contents of url2file_side_thread cpp or just copy the "url2file_side_thread cpp" file to the src/ directory and delete the src/empty cpp file download ca certificates extracted from mozilla and save them in the main directory of the webassembly module project add necessary compiler flag to your webassembly module right-click on your webassembly module project select "properties" from the context menu select "c/c++ build > settings" on the "tool settings" tab, select "emscripten c++ compiler > "miscellaneous" append the following flag to the "other flags" field -s use_curl=1 the-s use_curl=1 flag is required here and in the linker flags below as a compiler flag it is required to make curl include directories populated and provided to compilation stage using the -i switch also, putting this flag here allows the indexer to see curl-included directories and properly resolve curl includes add necessary linker flags to your webassembly module right-click on your webassembly module project select "properties" from the context menu select "c/c++ build > settings" on the "tool settings" tab, select "emscripten c++ linker > "miscellaneous" append the following flags to the "linker flags" field -s environment_may_be_tizen -s use_curl=1 --preload-file /cacert pem@/cacert pem -pthread -s use_pthreads=1 -s pthread_pool_size=2 flag description -s environment_may_be_tizen flag indicating that you want to use samsung tizen emscripten extensions available on samsung tizen tvs 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 toolchain note that during the first build, the full library is being built and cached, so compilation can take a while for more details, see emscripten ports --preload-file /cacert pem@/cacert pem flag allowing your application to read the "cacert pem" file using the standard c api fopen /cacert pem tizen studio launches the samsung emscripten toolchain in a currentbin directory, although youn have the cacert pem file in the main project's directory to avoid copying this file, use a relative path to refer to this file as /cacert pem in a c/c++ program, use the@/cacert pem mapping, as described in modifying file locations in the virtual file system -pthread -s use_pthreads=1 -s pthread_pool_size=2 flag allowing you to use threads in a webassembly module note that it is necessary to call posix sockets apis in threads other than the main thread of your application table 1 linker flags build your webassembly module project apply the following workarounds unlink the webassembly module from main application right-click on the main application, go to "others > project references", and unselect the referenced webassembly module project while in the project properties, add the "* data" file to the wgt package in "tizen studio > package", expand the tree to the 'currentbin' directory of the webassembly module project and check the file with the data extension click "apply and close" note this particular step must be performed after each build of the webassembly module project add the following snippet to wasm_modules/scripts/wasm_tools js after the body print method locatefile => { return path, prefix => { if prefix == '' { prefix = this path substring 0, this path lastindexof '/' | ''; prefix = prefix + '/'; } return prefix + path; }; } , build a signed package now you are done and can run your application on the device