[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-786519-105":59,"doc-detail-786519-en":130,"doc-similar-786519":162},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","logrocket-guide-cross-compilation-in-rust","LogRocket Guide - Cross-Compilation in Rust","","Rust cross-compilation enables developers to build programs for platforms other than the machine performing the compilation, supporting multi-platform releases, cloud-based builds, and targets where Rust tools cannot run natively. The guide introduces a sample project using the current_platform crate, explains Rust target triples and how to identify them, then demonstrates compiling from Linux to Windows with Cross, Cargo, and a suitable container engine. It also addresses platform-specific code and provides commands and examples that help readers configure and verify cross-platform builds.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/logrocket-guide-cross-compilation-in-rust/786519/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/logrocket-guide-cross-compilation-in-rust/786519.png","ImageObject",300,407,{"name":92,"@type":93},"Himbo","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-12-05","2026-12-04",true,{"@type":102,"interactionType":103,"userInteractionCount":8},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What is cross-compiling?","Question",{"text":112,"@type":113},"It means compiling a program on one platform to run on a different platform.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"Why might developers use cross-compilation?",{"text":117,"@type":113},"It can simplify building for multiple platforms from one machine, support cloud-based builds, and target platforms where the Rust compiler or host tools cannot run.",{"name":119,"@type":110,"acceptedAnswer":120},"How does Rust identify a platform target?",{"text":121,"@type":113},"Rust uses a target triple. Developers can find the host triple with rustc -vV or look it up in the Rust Platform Support list.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},786519,1796427847,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":8,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":139,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":129,"read_time":144,"preview_page_count":19,"preview_urls":145},687197100911,"https://ap-avatar.wpscdn.com/avatar/a000239b6f1da00475?x-image-process=image/resize,m_fixed,w_180,h_180&k=1785132997149421697","Advisory boards aren’t only for executives. Join the LogRocket Content Advisory Board today →  \n􀀂  \nMay 25, 2023 ⋅ 6 min read    \n A guide  to cro  ss-compilation in  \nRust                       \nGreg Stoll  \nGreg is a software engineer with over 20 years of experience in the  industry. He enjoys working on projects in his spare time and enjoys  writing about them!                  \nTable of contents 􀀁  \nCross-compiling is a very handy capability to have in multiple scenarios. Let’s take a look at why you might want to do it and how to get set up in Rust for crosscompilation.  \nWhat we’ll cover:  \n◦ Understanding cross-compiling and its Rust bene􀀁ts  \n◦ Setting up an example Rust cross-compilation project  \n◦ How Rust represents platforms  \n◦ Cross-compiling our demo Rust project from Linux to Windows  \n◦ How to write platform-speci􀀁c code  \nTo follow along, see the GitHub repo for this project.  \nUnderstanding cross-compiling and its Rust beneﬁts  \nCross-compiling means compiling a program on a platform for a di􀀂erent platform. For example, if you are on a Windows machine, you can compile a program that can run on Linux.  \nThere are a few reasons cross-compiling can be helpful. One is that if you have a product that you want to ship on multiple platforms, it can be convenient to be able to build all versions from a single machine instead of having one Windows machine, one Mac machine, etc.  \nCross-compilation can be helpful in cloud-based build scenarios as well. Rust even supports running tests across multiple target platforms on the same host platform.  \nAnother reason you may want to cross-compile is that it might be necessary, as the Rust compiler and host tools are not supported on every platform they can build for. For example, the Rust compiler supports building an app for iOS, but the Rust compiler itself doesn’t run on iOS.  \nSetting up an example Rust crosscompilation project  \nThere is some built-in support in rustc for cross-compiling, but getting the build to actually work can be tricky due to the need for an appropriate linker. Instead, we’re going to use the Cross crate, which used to be maintained by the Rust Embedded Working Group Tools group.  \nFirst, let’s set up a simple project that will show which platform it’s running on. Todo this, we’re going to use the current_platform crate, which is an easy way to see what platform your code is running on, as well as what platform it was compiled on.  \nLet’s make a new crate with cargo new and add the crate with cargo add [current_platform](current_platform . Then we can add the following to the src/main.rs)[ . Then we can add the following to the](current_platform . Then we can add the following to the src/main.rs)[ src/main.rs](current_platform . Then we can add the following to the src/main.rs) 􀀁le:  \nuse current_platform::{COMPILED_ON , CURRENT_PLATFORM};  \nfn main() {  \nprintln!(\"Hello, world from {}! I was compiled on {} . \" , CURREN}  \nOn my Linux machine, running this with cargo run leads to this output:  \nHello , world from x86 _ 64-unknown-linux-gnu! I was compiled on x86  \nThis agrees with what rustc thinks the platform is; running rustc -vV gives this output:  \nrustc 1.68 .2 (9eb3afe9e 2023-03-27)  \nbinary : rustc  \ncommit-hash : 9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0  \ncommit-date : 2023-03-27  \nhost : x86 _ 64-unknown-linux-gnu  \nrelease : 1.68 .2  \nLLVM version : 15.0 .6  \nHow Rust represents platforms  \nTo cross-compile, you need to know the “target triple” for the platform you’rebuilding for. Rust uses the same format that LLVM does. The format is \u003Carch>\u003Csub> - \u003Cvendor> - \u003Csys> - \u003Cenv> , although 􀀁guring out these values for a given platform is not obvious.  \nAs we saw above, x86 _ 64-unknown-linux-gnu represents a 64-bit Linux machine. Running rustc --print target-list will print all targets that Rust supports, but the list is long, and it’s hard to 􀀁nd the one you want.  \nThe two best ways to 􀀁nd the target triple for a platform you care about ","cbCaieZAEbo0gbk9","https://ap.wps.com/l/cbCaieZAEbo0gbk9","pdf",1462438,11,"English","# Understanding cross-compiling and its Rust benefits\n# Setting up an example Rust cross-compilation project\n# How Rust represents platforms\n# Cross-compiling a Rust project from Linux to Windows\n# Writing platform-specific code","[{\"question\":\"What is cross-compiling?\",\"answer\":\"It means compiling a program on one platform to run on a different platform.\"},{\"question\":\"Why might developers use cross-compilation?\",\"answer\":\"It can simplify building for multiple platforms from one machine, support cloud-based builds, and target platforms where the Rust compiler or host tools cannot run.\"},{\"question\":\"How does Rust identify a platform target?\",\"answer\":\"Rust uses a target triple. Developers can find the host triple with rustc -vV or look it up in the Rust Platform Support list.\"}]","LogRocket Guide - Cross-Compilation in Rust | PDF",28,[146,150,154,158],{"page_no":8,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-04/4b0bd5fab457534a06cff2d8e6a620ad.webp",983,1388,{"page_no":14,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-04/650b8d89f676942d0c612666f0c90d2b.webp",982,1387,{"page_no":81,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-04/1fc2ecafb475f5d02a171659d75c022f.webp",981,1385,{"page_no":19,"url":159,"width":160,"height":161},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-04/3d312fb68644b5cd8e19a389bb93ccf4.webp",980,1384,{"list":163,"token":66},[164,171,178,184,191,197,203,209,215,222],{"doc_id":165,"doc_title":166,"file_type":137,"home_preview_img_url":167,"slug":168,"view_count":169,"category_name":30,"create_tm":170},422295,"The Leading Information Technology News Summary - Now In Its 41st Year - Vol.41 No.43","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229922595716/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796585279&Signature=2lp7aGbQjESzJ1OhwhXTb78CzFI%3D","the-leading-information-technology-news-summary-now-in-its-41st-year-vol41-no43",12,1790626793,{"doc_id":172,"doc_title":173,"file_type":137,"home_preview_img_url":174,"slug":175,"view_count":176,"category_name":30,"create_tm":177},681823,"Qualcomm TensorFlow Lite SDK Tools Quick Start Guide - Revision AB","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229998394971/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796585279&Signature=bINlBIdX%2B7w7yFFuAEqkGDUyBVA%3D","qualcomm-tensorflow-lite-sdk-tools-quick-start-guide-revision-ab",13,1793954880,{"doc_id":179,"doc_title":180,"file_type":137,"home_preview_img_url":181,"slug":182,"view_count":24,"category_name":30,"create_tm":183},693145,"AWS Amplify - Overview","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230005090824/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796585279&Signature=dqoQMw1VD7K7BwC35TYAR5cwy%2BE%3D","aws-amplify-overview",1794250470,{"doc_id":185,"doc_title":186,"file_type":137,"home_preview_img_url":187,"slug":188,"view_count":189,"category_name":30,"create_tm":190},203920,"Cloud Native Application Platform Solution Brief - CNAP service offering, features, and approach","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229882955746/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796585279&Signature=YRiqBTH%2FECru3iHY54iK5YvK7aM%3D","cloud-native-application-platform-solution-brief-cnap-service-offering-features-and-approach",15,1788565068,{"doc_id":192,"doc_title":193,"file_type":137,"home_preview_img_url":194,"slug":195,"view_count":24,"category_name":30,"create_tm":196},689109,"Notes on Data Structures and Programming Techniques - CPSC 223 Spring 2018","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230001510733/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796585279&Signature=GOXSTZY50B1pSbzWqAOKiMfs%2BzU%3D","notes-on-data-structures-and-programming-techniques-cpsc-223-spring-2018",1794096425,{"doc_id":198,"doc_title":199,"file_type":137,"home_preview_img_url":200,"slug":201,"view_count":81,"category_name":30,"create_tm":202},689158,"Studio Developer Manual - Release 2401 - CoreMedia Content Cloud","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000682098/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796585279&Signature=mkYOwEh2ypX2%2FHQVfG4R3lliCuY%3D","studio-developer-manual-release-2401-coremedia-content-cloud",1794097895,{"doc_id":204,"doc_title":205,"file_type":137,"home_preview_img_url":206,"slug":207,"view_count":39,"category_name":30,"create_tm":208},689156,"Thermo-Calc Documentation Set - Version 2020b - Installation Guide and Licensing Setup","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230001524699/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796585279&Signature=xU2oZJ3bslFSsIPNJoUtymz803s%3D","thermo-calc-documentation-set-version-2020b-installation-guide-and-licensing-setup",1794097891,{"doc_id":210,"doc_title":211,"file_type":137,"home_preview_img_url":212,"slug":213,"view_count":29,"category_name":30,"create_tm":214},686589,"Useful Commands for Linux, Yocto & Git - Shortcuts and tricks","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000539861/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796585279&Signature=MWapCJgitr1nb%2FUj79%2BhcM0iUsI%3D","useful-commands-for-linux-yocto-git-shortcuts-and-tricks",1794057231,{"doc_id":216,"doc_title":217,"file_type":137,"home_preview_img_url":218,"slug":219,"view_count":220,"category_name":30,"create_tm":221},180611,"Neoverse Reference Design Docs-Arm-Com-En-Main","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229877541346/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796585279&Signature=Hk4kS0U%2F4MLyaK2NcAUvoc7TPTk%3D","neoverse-reference-design-docs-arm-com-en-main",17,1788341478,{"doc_id":223,"doc_title":224,"file_type":137,"home_preview_img_url":225,"slug":226,"view_count":34,"category_name":30,"create_tm":227},646215,"MySQL Reference Manual - read online free","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229971488362/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796585279&Signature=t2HF0YSXoGQxL6o6DtXEy9a9tGc%3D","mysql-reference-manual-read-online-free",1792753724]