MacOS/Linux (Intel/x86)

Set up VM

  • Install vitrualbox and vagrant. After installation, reboot your machine.

  • If you are using macOS Catalina or higher, you are recommended to (please do it) set the virtualbox permissions

  • Set up a directory for csc3150 (make sure the full path does not include space or Chinese, e.g. mkdir -p ~/dev/csc3150)

Terminal on Mac OS
  • Launch terminal and change current directory to the one you set up (e.g. cd ~/dev/csc3150), then execute vagrant init cyzhu/csc3150

  • Then execute vagrant up. It may take a while to download the system image. After that a virtualbox window may pop up. Leave it open but put it aside.

vagrant init cyzhu/csc3150 && vagrant up
  • The VM is set up. Now we can set up the ssh to connect to the VM. Still in terminal, execute mkdir -p ~/.ssh && vagrant ssh-config >> ~/.ssh/config and now you can connect to VM in terminal with ssh default

Set up VS Code (Optional)

To simplified the workflow, you are recommended to set up Remote SSH plugin in VS Code.

Install Remote SSH Plugin

After installing, go to the remote explorer tab, and find SSH Target called default. Click the icon to connect to the VM and launch a new window.

Go to the remote explorer tab and open a new window by connecting to "default"

The first time you connect to the VM via VS Code, it may take some time for it to load. Wait patiently. After it finshes loading, start a terminal.

Start a terminal (in remote machine)

In the terminal you just opened, install essential dependencies and libraries: sudo apt update && sudo apt install -y build-essential (it may take a while). After it finishes, create a directory for the course: mkdir -p ~/csc3150

After everything, you can open a folder in the VS Code window to locate to the directory you create:

Make a directory for the course

Finally, try a hello world program on the VM

Hellow World

As usual, open a (remote) terminal in VS Code and compile the hello world program (gcc hello.c -o hello) and try to run it.

You are good to go

Shutdown the VM

To shutdown the VM gracefully, go to terminal (on your host machine, not in VM/VS Code) and cd to your csc3150 diretory, and execute vagrant halt.

Symmetrically, next time you want to re-launch the VM, go to terminal (on your host machine, not in VM/VS Code) and cd to your csc3150 diretory, and execute vagrant up

Trouble Shootings

Troubles in "vagrant up"

vagrant up download the system image from the cloud and may involve network problems. In common case where you encounter a network problem, you may retry and succeed. However, if the problem persists, there is an alternative solution:

  • Remove the directory (rm -rf csc3150) and create it again

  • Download the image manually here

  • In terminal, cd to the directory and execute

    vagrant box add csc3150 /the/path/to/the/box/you/just/download
    vagrant init csc3150
    vagrant up

Last updated