Setting up your Development Environment

Setting up your development environment is not a quick task, but if done right it can save you hundreds of hours.

My preferred development environment for C++ is CLion running on Mac. I have also included details of my Windows development environment since lots of people use Windows. Visual Studio, Eclipse and other IDEs have similar features to CLion, so modify the instructions as needed to get the same functionality.

Msys2 (Windows)

CLion relies on external programs for compilation which means you need to have g++ and gcc already installed. There are multiple options (MinGw, Cygwin, etc) but my preferred one is Msys2 which provides a unix like environment under Windows. It also helps install additional programs easily.

  1. Right Click on Start > System > Search for View Advanced System Settings > Environment Variables, Add new user variable HOME with %USERPROFILE% - this will make Msys2 start in the windows directory (if you do this after installing Msys2, move files from C:\msys64\home\pisan to  C:\Users\pisan manually https://github.com/valtron/llvm-stuff/wiki/Set-up-Windows-dev-environment-with-MSYS2 
  2. Install Git for Windows https://git-scm.com/downloads
  3. Install MSys2 https://www.msys2.org/ on default directory C:\msys64 Follow the instructions on the web page, especially about 'pacman -Syu' to update package database and core system
  4. pacman -S --needed mingw-w64-x86_64-emacs mingw64/mingw-w64-x86_64-gcc python3 mingw64/mingw-w64-x86_64-putty mingw64/mingw-w64-x86_64-cmake mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-cppcheck msys/unzip python3-pip mingw32/mingw-w64-i686-make msys/git
  5. pip install --upgrade pip
  6. pip install cpplint
  7. Run c:\msys64\mingw64.exe to get started and pin it to the taskbar for future
  8. Make sure the compilers are installed, try 'which g++' to find the location of g++
  9. You can configure Putty under Windows as well as ssh under Msys2 to use public/private keys to allow login without using password. Run C:\Program Files\PuTTY\puttygen.exe to generate a private key. Save it to your windows machine. Copy the "public key" (starts with ssh-rsa ....). On the linux server, such as uw1-320-01.uwb.edu, edit the file ~/.ssh/authorized_keys and paste the "public key" to this file. Configure Putty on windows to use your netid as the auto-login username (under Connection > Data) and Connection > SSH > Auth should have the private key file for authentication. You can now login to uw1-320-01 without entering a password. Repeat editing the authorized_keys file for each of the CSS Linux machines as needed.

Mac

Mac relies on Xcode for compilers or you can install g++ and gcc via brew

  1. Install Xcode -- we need it for the command line tools
  2. Start XCode and agree to Terms and Conditions
  3. Open terminal use: "xcode-select --install" This will install comman-line interface (CLI)
  4. Install homebrew
  5. Open terminal use: brew install valgrind cppcheck gcc make cmake emacs gdb wget python3
  6. pip3 install cpplint

CLion

Install CLion, assuming Msys2 has already been set as above for Windows or necessary programs installed for Mac

  1. Settings > Editor > Live Templates > CMake -- create a new shortcut named "wall" as follows
    # CSS Linux Lab only has cmake 3.5
    cmake_minimum_required(VERSION 3.5)
    
    # Minimum c++14
    set(CMAKE_CXX_STANDARD 14)
    
    # have compiler give warnings, but not for signed/unsigned
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Wno-sign-compare")
            
  2. Clion add plugins cpplint and cppcheck
  3. Configure cppcheck
  4. Configure cpplint
  5. Add Ctrl-R as a Clion shortcut for Run
  6. Ctrl-I as Auto-Indent Lines (instead or inaddition to Ctrl-Alt-I)
  7. Check that you can use different toolchaings
    1. g++ for regular Windows development
    2. wsl for compiling thinghs under ubuntu and using valgrind
    3. Visual Studio's compiler -- if necessary
  8. If you are using CATCH framework: Download Catch2 testing framework and integrate it with CLion following instructions at https://www.jetbrains.com/help/clion/catch-tests-support.html xx
  9. If you are using GitHub



Windows - New Computer

Getting a new Windows computer ready.

For some reason a new Windows computrer comes with all types of unnecessary stuff. These are all the steps I had to take to get my computer into a usable state. Some of them may be applicable to you.

  1. Preparation
    1. IMPORTANT. By default Windows Explorer hides file extensions. While this might be OK for a regular user, it is a nightmare for a developer where you enddp with multiple files with the same name: Readme.txt (a text file that can be opened and edited in Notepad or any text editor), Readme.pdf (PDF file that can be opened in Acrobat), Readme.exe (an executable file, can be run by double clicking, an unusual name for a program), README.cfg (probably a configuration file), Readme.md (a markdown file, can be edited by any text editor), ....
      Show file extensions - Search for “file explorer options” under Windows Setting from Start button. Full path in title bar, Uncheck hide extensions
    2. Download install Huskey OnNet. You need this to connect to CSS Linux Labs when you are not on the UW network. https://itconnect.uw.edu/connect/uw-networks/about-husky-onnet/
    3. Install basic version of FileZilla. Need this to transfer files to CSS Linux Labs. https://filezilla-project.org/download.php?type=client
    4. Uninstall Dell Mobile Connect,  Candy Crush, Microsoft News, Minecraft, Netflix, weather, Xbox, Xbox Game Speech Windows, Xbox Live, Dropbox Promotion, Fitbit Coach, LinkedIn, Solitaire Collection, Mobile Plans
    5. Create a second admin account - eventually make this account a regular account and use the admin account when installing new software is required
    6. Windows Update - if you need it
    7. Add c:\Users\pisan to Quick Access in File Explorer
    8. Right Click on Start > System > Search for View Advanced System Settings > Advanced > Visual Effects -- modify as needed
    9. Right Click on Start > System > Search for View Advanced System Settings > Computer Name - somename -- need to reboot after this
    10. Create a restore point, Search “restore point”, allocate 1-2% for System, and create the first restore point
    11. Turn off Right Click on Start > System > Search for View Advanced System Settings > Remote Assistance
    12. (Search) Notifications and Actions, Disable most notifications
    13. Kill apps on shutdown - maybe, https://www.tomshardware.com/picturestory/853-windows-10-settings-you-should-change.html#s4
    14. Themes - set theme, back to colors to set the default color to blue rather than switching with theme/background
    15. Taskbar - remove people
    16. Sign-in options, create a pin
    17. Do not "Use my sign-in to automatically finish setting up my device and reopen my apps after an update or restart."
    18. Privacy - turn it all off
    19. Wifi - turn off 2.0, turn off allow another device to turn mobile hotspot on
    20. Video Playback - optimize for movie quality. If I am watching a movie, I’ll eventually plug things in
    21. Cortana - my cloud content off, device history off, no cortana on locked screen
    22. No web search from Cortane/local search - https://www.thewindowsclub.com/disable-web-search-in-windows-10 (did not work for me, testing https://pureinfotech.com/disable-cortana-windows-10/ via regedit)
    23. Disable onedrive starting at startup - from Task Manager, revisit later
    24. Turn off - account info for apps
    25. Turn off - apps accessing contacts, calendar, call history, tasks, email, text messages, radios, other devices, feedback and diagnostics
    26. Minimize background apps
    27. Don’t let apps access diagnostic info
    28. Automatic downloads off
    29. Start > Live Tiles, right click on each one and unpin from start. Once all the tiles are gone, use a mouse or trackpad to drag the right edge of Start all the way to the left.
    30. Settings > Personalization > Start - show app list on start menu
  2. Download programs
    1. Chrome -- set as default browser, sync settings
      1. Add a new person to chrome, UW
    2. Install Google Drive Stream for UW account
    3. Install Office 365 - UW subscription
    4. Install Visual Studio Community - project properties > c++ > precompiled headers - not using them. Remove pch.h and cpp
    5. Install Adobe Acrobat DC
    6. Install Microsoft Subsystem for Linux (WSL) such as Ubuntu from Windows Store https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6?activetab=pivot:overviewtab
      1. sudo apt-get update
      2. sudo apt install g++, git, python3, python3-pip, cmake, cppcheck, emacs25, valgrind, cmake, gdb
      3. pip install cpplint
      4. Ubuntu can edit Windows files by accessing /mnt/c but Windows cannot access Ubuntu files -- learned it the hard way!
    7. Install CodeBlocks -- toolchain executables is in C:\msys64\mingw64\bin
    8. Download Unity Hub
    9. github for desktop
  3. Pin to Taskbar: Chrome, Emacs, Msys2, putty, powershell
    1. For emacs, edit properties to start runemacs from C:\msys64\mingw64\bin. Change emacs start directory to be c:\
    2. For Msys2, edit properties to run C:\msys64\msys2_shell.cmd