In other words, you’d need not only a Linux OS environment (like you may have used during the week 3 exercises), but also a way to emulate x86-based hardware. In order to access these registers you’d need a way to “emulate” (pretend to be) an x86 architecture. If you’re on a machine that isn’t using an x86 architecture (this will most likely only be true if you’re on a new Mac with the ARM M1 chip), none of the above options will work for you for project 1.įirst, project 1 relies on registers that don’t exist on ARM. Or, you can even start a bash shell inside the container. You can also run other things within the container. You can edit code locally on your machine using whatever editor you like and Since this is rather long and complex, we included a mini script that does theĭocker run part for you. Incantation that runs cargo build in your Docker image: docker run -rm -it \ Once the image is built, you can run your code. Once you build this image, you won’t need to do it again! Running cargo (In our case, the dependencies are just a barebones version of Ubuntu, cargo, and make.) If you get a message that says “Cannot connect to the Docker daemon”, make sure you have Docker running in the background. This will build an deet image containing dependencies needed to run your program. Building the Docker imageĬd into the deet/ directory and then run docker build: docker build -t deet. Make sure you have the latest version of Docker installed. You can download and install docker for Mac here and for Windows here. It may take some more work to get running, but will probably be pretty smooth in terms of running your code. Use Dockerĭocker is a popular tool that creates consistent environments toĭevelop/test/deploy software in. That said, you’re also welcome to re-create and destroy the VM every time you go to work on the project all files are locally stored, so you won’t lose any work. Note: I recommend keeping the VM in existence while you’re working on this project, and ssh into it from the deet directory when you need to, just because booting and configuring the VM (with vagrant up) takes a few minutes. Once you’re done with the project, you can shut down and delete the VM by running this command from the deet directory (on your system): vagrant destroy (What I do is ssh into the VM, keep that terminal open, write my code in a different window in VSCode, and then go back to my VM terminal when I want to compile and run.) However, if you want to actually run the code in the VM, you need to do so from the VM terminal. The VM’s “file system” is hard linked to your computer’s file system, which means any changes you make on your computer will be automatically synchronized with the VM. You don’t have to write your code in the VM. Now, you can open whatever editor you normally use and start working on the assignment. This will give you a terminal in your VM! From here, you can run normal commands like make, cargo run or gdb, and they will run in your vagrant VM. Once it’s finished, you need to “ssh” into the VM. The VM might take a minute or so to boot. This will create and configure a Linux VM on your computer according to the specification of the Vagrant file. This directory has a file called VagrantFile that will configure the VM when you bring it up (take a look at the comments in the file if you’re interested in how this works).įrom the deet directory, run the following to set up the virtual machine: vagrant up Then, cd into the deet directory in your terminal. NOTE: if you’re on Mac and get an error when starting up the VM, likely saying “kernel driver not installed,” check out this article. On Mac with homebrew installed, you can do this easily by running brew install -cask virtualbox vagrant. This will allow you to easily run and test your code as if you’re running it on a Linux machine.įirst, you’ll want to install Vagrant. A virtual machine creates a “virtual” operating system that runs on top of your real operating system. Vagrant is a really helpful tool that will create and configure virtual machines on your computer. Mac with Intel chip, or Windows without WSL 2: Use Vagrant If you’re using VSCode, you may also want to install the “Remote - WSL”Įxtension. Sudo apt-get install -y build-essential make curl strace gdbĬurl -proto '=https' -tlsv1.2 -sSf | sh Run the following: # Install other dependencies: Then, from a terminal, run wsl to get into a WSL 2 command prompt, and then That the older WSL1 is unlikely to work with our assignments. Linux,” which runs Linux inside of a virtual machine that can be conveniently Newer versions of Windows include a feature called “Windows Subsystem for Getting a Local Linux Setup for Project 1 Windows: Use WSL2
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |