Install Rust in WSL2 Ubuntu environment and build WASM build environment

When I worked on the MDN article "Compile from Rust to WebAssembly", there were some things that didn't work, so I'll write it as a reminder.

Work environment
Windows 10 Pro 20H2
Ubuntu 20.04 LTS (WSL2)
Rust 1.48.0

1. sh.rustup.rs terminates with permission denied.

The cause was that I was using Remote-WSL with VScode on the Windows side to open a working folder on Ubuntu. I don't think people who do this are so, but I will write it for the time being. The message was subtle, so it took me more time than I expected.

2. I get a linker cc not found error with cargo install wasm-pack.

python


cargo install wasm-pack 

When I run the command, wasm-pack downloads and builds a large number of dependent packages, but it seems that it can be done if the linker is not installed.

python


error: linker `cc` not found

Let's install gcc.

python


sudo apt install gcc

3. cargo install wasm-pack fails to run custom build command for openssl-sys v0.9.60 error occurs.

When I installed gcc and tried again, I got the following error this time:

python


error: failed to run custom build command for `openssl-sys v0.9.60`

There was a revelation to install pkg-config in a large number of debug messages.

 It looks like you're compiling on Linux and also targeting Linux. Currently this
 requires the `pkg-config` utility to find OpenSSL but unfortunately `pkg-config`
 could not be found. If you have OpenSSL installed you can likely fix this by
 installing `pkg-config`.

Perform the installation.

python


sudo apt install pkg-config

Finally, the wasm-pack installation is complete.

Installed package `wasm-pack v0.9.1` (executable `wasm-pack`)

Recommended Posts

Install Rust in WSL2 Ubuntu environment and build WASM build environment
WSL2 + Ubuntu 20.04 Install Vivado in LTS environment
How to install the language used in Ubuntu and how to build the environment
Install Ubuntu 20.04 in virtual box on windows10 and build a development environment using docker
Install ruby serial port in WSL environment
Build and install Wireshark Development Release (3.3.1) on Ubuntu
Command memo to install xeyes in ubuntu docker environment
AWS CLI install in Ubuntu 20.04
Install Java on WSL Ubuntu 18.04
Build docker environment with WSL
Install / run a standalone robot simulator in wsl2 / docker environment!
Install docker and docker-compose on ubuntu in the shortest process
What happened in "Java 8 to Java 11" and how to build an environment
[Windows] WSL2 + Ubuntu + Node.js environment construction
Install gem in Serverless Framework and AWS Lambda with Ruby environment
Install JDK and JRE on Ubuntu 16.10
Until you build the docker environment and start / stop the Ubuntu container
Install laravel/Dusk in docker environment (laravel6)
Build a XAMPP environment on Ubuntu
Install Rails in the development environment and create a new application
Install Ubuntu20.04 on RaspberryPi 4 and build Kubernetes to run the container
Challenge to install WSL2 and docker
Install Ubuntu Server 20.04 in VirtualBox on Mac and connect with SSH
Install PHP7.4 to build CentOS7 Laravel environment
Build and manage RStudio environment with Docker-compose
Use docker in proxy environment on ubuntu 20.04.1
Use selenium (Firefox) in Ruby in WSL environment
Use selenium (Chrome) in Ruby in WSL environment
Build Cakephp environment from docker installation Ubuntu
Try putting Docker in ubuntu on WSL
Install Docker and create Java runtime environment
Try running ScalarDB on WSL Ubuntu (Environment Construction)
Just install Laravel8 on docker in PHP8 environment
Publish MySQL externally and log in on Ubuntu
(Basic authentication) environment variables in rails and Docker
[Java] Build Java development environment on Ubuntu & check execution
Build Java environment and output hello world [Beginner]
How to install Titan2D (v4.2.0) in virtual environment
Build a DHCP and NAT router on Ubuntu 16.04
Docker on Ubuntu18.04 on WSL2 and VSCode installation instructions
Build mecab (NEologd dictionary) environment with Docker (ubuntu)
How to build a Pytorch environment on Ubuntu
[Beginner] Install java development tool in cloud9 development environment.
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
Install Veeam PN on Ubuntu in IBM Cloud VPC and connect with SSL VPN