{"id":11364,"date":"2026-02-06T12:19:27","date_gmt":"2026-02-06T03:19:27","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11364"},"modified":"2026-02-06T13:39:43","modified_gmt":"2026-02-06T04:39:43","slug":"rust%ec%99%80-webassembly%eb%a1%9c-%eb%a7%8c%eb%93%9c%eb%8a%94-hello-world-%ec%9b%b9%ec%95%b1","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11364","title":{"rendered":"Rust\uc640 WebAssembly\ub85c \ub9cc\ub4dc\ub294 &#8220;Hello World&#8221; \uc6f9\uc571"},"content":{"rendered":"<h1>Rust\uc640 WebAssembly\ub85c \ub9cc\ub4dc\ub294 &quot;Hello World&quot; \uc6f9\uc571<\/h1>\n<p>wasm-pack\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc544\uc8fc \uac04\ub2e8\ud558\uac8c &quot;Hello World&quot; \uc6f9 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ube4c\ub4dc\ud558\ub294 \uacfc\uc815\uc744 \uc18c\uac1c\ud569\ub2c8\ub2e4.<\/p>\n<h2>\uc0ac\uc804 \uc900\ube44 (Prerequisites)<\/h2>\n<ul>\n<li>\n<p>Rust \uc124\uce58<\/p>\n<p><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6512\">https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6512<\/a><\/p>\n<\/li>\n<li>\n<p>wasm-pack \uc124\uce58<\/p>\n<p>\uc77c\ubc18 CMD \ub300\uc2e0 <code>Developer PowerShell for VS 2022<\/code> \ub97c \uc2e4\ud589\ud558\uace0 \uc544\ub798 \uba85\ub839\uc744 \uc785\ub825\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">cargo install wasm-pack<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>kernel32.lib \uad00\ub828 \uc624\ub958\uac00 \ubc1c\uc0dd\ud558\uba74, Visual Studio Installer \ub97c \uc2e4\ud589\ud558\uace0, \uc218\uc815 \ubc84\ud2bc\uc744 \ub204\ub978 \ud6c4, \uac1c\ubcc4 \uad6c\uc131 \uc694\uc18c \ud0ed\uc73c\ub85c \uc774\ub3d9 \ud6c4, Windows SDK \uac80\uc0c9 \ud6c4, <code>Windows 11 SDK (10.0.22621.0)<\/code> \ub97c \uc124\uce58\ud574 \uc90d\ub2c8\ub2e4.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2026\/02\/image-1770350704137.png\" alt=\"file\" \/><\/p>\n<h2>\ud504\ub85c\uc81d\ud2b8 \uc0dd\uc131 \ubc0f \uc124\uc815<\/h2>\n<h3>\ud504\ub85c\uc81d\ud2b8 \uc0dd\uc131<\/h3>\n<pre><code class=\"language-bash\">cargo new --lib hello-wasm\ncd hello-wasm<\/code><\/pre>\n<h3>Cargo.toml \uc124\uc815<\/h3>\n<pre><code class=\"language-toml\">[lib]\ncrate-type = [&quot;cdylib&quot;]\n\n[dependencies]\nwasm-bindgen = &quot;0.2&quot;<\/code><\/pre>\n<h2>Rust \ucf54\ub4dc \uc791\uc131<\/h2>\n<p>src\/lib.rs \ud30c\uc77c\uc744 \uc5f4\uace0 \uae30\uc874 \ub0b4\uc6a9\uc744 \uc9c0\uc6b4 \ub4a4, \ube0c\ub77c\uc6b0\uc800\uc758 alert \ucc3d\uc744 \ub744\uc6b0\ub294 \ucf54\ub4dc\ub97c \uc791\uc131\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-rust\">use wasm_bindgen::prelude::*;\n\n\/\/ JavaScript\uc758 alert \ud568\uc218\ub97c \uc0ac\uc6a9\ud558\uae30 \uc704\ud55c \uc120\uc5b8\n#[wasm_bindgen]\nextern &quot;C&quot; {\n    fn alert(s: &amp;str);\n}\n\n\/\/ JavaScript\uc5d0\uc11c \ud638\ucd9c\ud560 \uc218 \uc788\ub3c4\ub85d \ub0b4\ubcf4\ub0b4\ub294 \ud568\uc218\n#[wasm_bindgen]\npub fn greet(name: &amp;str) {\n    alert(&amp;format!(&quot;Hello, {}! Welcome to WASM.&quot;, name));\n}<\/code><\/pre>\n<h2>WebAssembly \ube4c\ub4dc<\/h2>\n<p>\ube4c\ub4dc\uac00 \uc644\ub8cc\ub418\uba74 \ud504\ub85c\uc81d\ud2b8 \ud3f4\ub354 \ub0b4\uc5d0 pkg\/ \ub514\ub809\ud1a0\ub9ac\uac00 \uc0dd\uc131\ub429\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">wasm-pack build --target web<\/code><\/pre>\n<h2>\uc6f9\ud398\uc774\uc9c0\uc5d0\uc11c \uc2e4\ud589\ud558\uae30<\/h2>\n<p>\ud504\ub85c\uc81d\ud2b8 \ub8e8\ud2b8\uc5d0 index.html\uc744 \ub9cc\ub4dc\uc138\uc694.<\/p>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;ko&quot;&gt;\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;title&gt;Rust Wasm Hello World&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;script type=&quot;module&quot;&gt;\n        \/\/ \ube4c\ub4dc\ub41c pkg \ud3f4\ub354\uc5d0\uc11c init\uacfc greet \ud568\uc218\ub97c \uac00\uc838\uc635\ub2c8\ub2e4.\n        import init, { greet } from &#039;.\/pkg\/hello_wasm.js&#039;;\n\n        async function run() {\n            \/\/ Wasm \ubaa8\ub4c8 \ucd08\uae30\ud654\n            await init();\n            \/\/ Rust \ud568\uc218 \uc2e4\ud589\n            greet(&quot;Rust World&quot;);\n        }\n\n        run();\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<h2>\ub85c\uceec \uc11c\ubc84 \uc2e4\ud589<\/h2>\n<pre><code class=\"language-bash\"># Python\uc774 \uc788\ub2e4\uba74\npython3 -m http.server\n# \ub610\ub294 npx \uc0ac\uc6a9\nnpx serve .<\/code><\/pre>\n<p>\uc774\uc81c \ube0c\ub77c\uc6b0\uc800\uc5d0\uc11c localhost:8000 \ub610\ub294 localhost:3000 \uc5d0 \uc811\uc18d\ud558\uba74, Rust\ub85c \uc791\uc131\ub41c \ud568\uc218\uac00 \uc2e4\ud589\ub418\uc5b4 &quot;Hello, Rust World! Welcome to WASM.&quot; \uc774\ub77c\ub294 \uc54c\ub9bc\ucc3d\uc774 \ub728\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4!<\/p>\n<h2>html \uc218\uc815<\/h2>\n<h3>Cargo.toml \uc124\uc815 \ucd94\uac00<\/h3>\n<pre><code class=\"language-toml\">[lib]\ncrate-type = [&quot;cdylib&quot;]\n\n[dependencies]\nwasm-bindgen = &quot;0.2&quot;\n# HTML \uc870\uc791\uc744 \uc704\ud55c \ub77c\uc774\ube0c\ub7ec\ub9ac \ucd94\uac00\nweb-sys = { version = &quot;0.3&quot;, features = [&#039;Document&#039;, &#039;Element&#039;, &#039;HtmlElement&#039;, &#039;Node&#039;, &#039;Window&#039;] }<\/code><\/pre>\n<h3>src\/lib.rs \uc218\uc815<\/h3>\n<pre><code class=\"language-rs\">use wasm_bindgen::prelude::*;\n\n#[wasm_bindgen]\npub fn greet(name: &amp;str) {\n    let window = web_sys::window().expect(&quot;no global `window` exists&quot;);\n    let document = window.document().expect(&quot;should have a document on window&quot;);\n\n    \/\/ ID\uac00 &quot;output&quot;\uc778 \uc5d8\ub9ac\uba3c\ud2b8\ub97c \ucc3e\uc544\uc11c \ub0b4\uc6a9\uc744 \ubc14\uafc9\ub2c8\ub2e4.\n    if let Some(element) = document.get_element_by_id(&quot;output&quot;) {\n        element.set_inner_html(&amp;format!(&quot;Hello, {}! (from Rust)&quot;, name));\n    }\n}<\/code><\/pre>\n<h3>HTML \ud30c\uc77c \uc218\uc815<\/h3>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;ko&quot;&gt;\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;title&gt;Rust Wasm Hello World&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1 id=&quot;output&quot;&gt;\uae30\ub2e4\ub9ac\ub294 \uc911...&lt;\/h1&gt;\n    &lt;script type=&quot;module&quot;&gt;\n        \/\/ \ube4c\ub4dc\ub41c pkg \ud3f4\ub354\uc5d0\uc11c init\uacfc greet \ud568\uc218\ub97c \uac00\uc838\uc635\ub2c8\ub2e4.\n        import init, { greet } from &#039;.\/pkg\/hello_wasm.js&#039;;\n\n        async function run() {\n            \/\/ Wasm \ubaa8\ub4c8 \ucd08\uae30\ud654\n            await init();\n            \/\/ Rust \ud568\uc218 \uc2e4\ud589\n            greet(&quot;Rust World&quot;);\n        }\n\n        run();\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<h3>\ube4c\ub4dc \ubc0f \uc2e4\ud589<\/h3>\n<pre><code class=\"language-bash\">wasm-pack build --target web<\/code><\/pre>\n<pre><code class=\"language-bash\"># Python\uc774 \uc788\ub2e4\uba74\npython3 -m http.server\n# \ub610\ub294 npx \uc0ac\uc6a9\nnpx serve .<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Rust\uc640 WebAssembly\ub85c \ub9cc\ub4dc\ub294 &quot;Hello World&quot; \uc6f9\uc571 wasm-pack\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc544\uc8fc \uac04\ub2e8\ud558\uac8c &quot;Hello World&quot; \uc6f9 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ube4c\ub4dc\ud558\ub294 \uacfc\uc815\uc744 \uc18c\uac1c\ud569\ub2c8\ub2e4. \uc0ac\uc804 \uc900\ube44 (Prerequisites) Rust \uc124\uce58 https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6512 wasm-pack \uc124\uce58 \uc77c\ubc18 CMD \ub300\uc2e0 Developer PowerShell for VS 2022 \ub97c \uc2e4\ud589\ud558\uace0 \uc544\ub798 \uba85\ub839\uc744 \uc785\ub825\ud569\ub2c8\ub2e4. cargo install wasm-pack kernel32.lib \uad00\ub828 \uc624\ub958\uac00 \ubc1c\uc0dd\ud558\uba74, Visual Studio Installer \ub97c \uc2e4\ud589\ud558\uace0, \uc218\uc815 \ubc84\ud2bc\uc744 \ub204\ub978 \ud6c4, \uac1c\ubcc4\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11364\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-11364","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11364"}],"version-history":[{"count":6,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11364\/revisions"}],"predecessor-version":[{"id":11372,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11364\/revisions\/11372"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}