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.
- 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
- Install Git for Windows https://git-scm.com/downloads
- 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
- 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
- pip install --upgrade pip
- pip install cpplint
- Run c:\msys64\mingw64.exe to get started and pin it to the taskbar for future
- Make sure the compilers are installed, try 'which g++' to find the location of g++
- 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
- Install Xcode -- we need it for the command line tools
- Start XCode and agree to Terms and Conditions
- Open terminal use: "xcode-select --install" This will install comman-line interface (CLI)
- Install homebrew
- Open terminal use: brew install valgrind cppcheck gcc make cmake emacs gdb wget python3
- pip3 install cpplint
CLion
Install CLion, assuming Msys2 has already been set as above for Windows or necessary programs installed for Mac
- 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")
- Clion add plugins cpplint and cppcheck
- Configure cppcheck
- C:\msys64\mingw64\bin\cppcheck.exe
Cppcheck should give a warning for "int *x = new int[100];" indicating memory leak
- set cppcheck options
--enable=all --inconclusive --language=c++ --std=posix --suppress=missingIncludeSystem
- Configure cpplint
- python C:\msys64\usr\bin\python.exe and cpplint at C:\msys64\usr\lib\python3.7\site-packages\cpplint.py ( setting it to C:\msys64\usr\bin\cpplint is reported not to work)
- Cpplint should give a warning about no copyright message found at the top of file
- set cpplint options (can also create a file CPPLINT.cfg in the project):
--filter=-legal/copyright,-whitespace/tab,-build/namespaces,-build/include,-build/header_guard,-whitespace/newline,-whitespace/braces,-build/c++11,-runtime/threadsafe_fn
- Add Ctrl-R as a Clion shortcut for Run
- Ctrl-I as Auto-Indent Lines (instead or inaddition to Ctrl-Alt-I)
- Check that you can use different toolchaings
- g++ for regular Windows development
- wsl for compiling thinghs under ubuntu and using valgrind
- Visual Studio's compiler -- if necessary
- 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
- If you are using GitHub
- Download gitignore for JetBrains.CLion from https://github.com/github/gitignore/tree/master/Global and save it to ~/.gitignore_global
- File > Settings > Plugins -- enable GitHub and Git Integration plugins
- File > Settings > Version Control > GitHub -- add your github account
- File > Settings > Version Control > Git -- add executable to git program, something like c:\msys64\usr\bin\git.exe
- Confirm that cpplint and cppcheck are working from CLion
- Confirm that Using VCS menu option, files can be committed and pushed to repository
- If you have installed WSL (Windows Subsystem for Linux)
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.
- Preparation
- 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
- 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/
- Install basic version of FileZilla. Need this to transfer files to CSS Linux Labs. https://filezilla-project.org/download.php?type=client
- 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
- Create a second admin account - eventually make this account a
regular account and use the admin account when installing new software
is required
- Windows Update - if you need it
- Add c:\Users\pisan to Quick Access in File Explorer
- Right Click on Start > System > Search for View Advanced
System Settings > Advanced > Visual Effects -- modify as needed
- Right Click on Start > System > Search for View Advanced
System Settings > Computer Name - somename -- need to reboot after
this
- Create a restore point, Search “restore point”, allocate 1-2% for System, and create the first restore point
- Turn off Right Click on Start > System > Search for View Advanced System Settings > Remote Assistance
- (Search) Notifications and Actions, Disable most notifications
- Kill apps on shutdown - maybe, https://www.tomshardware.com/picturestory/853-windows-10-settings-you-should-change.html#s4
- Themes - set theme, back to colors to set the default color to blue rather than switching with theme/background
- Taskbar - remove people
- Sign-in options, create a pin
- Do not "Use my sign-in to automatically finish setting up my device and reopen my apps after an update or restart."
- Privacy - turn it all off
- Wifi - turn off 2.0, turn off allow another device to turn mobile hotspot on
- Video Playback - optimize for movie quality. If I am watching a movie, I’ll eventually plug things in
- Cortana - my cloud content off, device history off, no cortana on locked screen
- 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)
- Disable onedrive starting at startup - from Task Manager, revisit later
- Turn off - account info for apps
- Turn off - apps accessing contacts, calendar, call history,
tasks, email, text messages, radios, other devices, feedback and
diagnostics
- Minimize background apps
- Don’t let apps access diagnostic info
- Automatic downloads off
- 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.
- Settings > Personalization > Start - show app list on start menu
- Download programs
- Chrome -- set as default browser, sync settings
- Add a new person to chrome, UW
- Install Google Drive Stream for UW account
- Install Office 365 - UW subscription
- Install Visual Studio Community - project properties > c++ > precompiled headers - not using them. Remove pch.h and cpp
- Install Adobe Acrobat DC
- Install Microsoft Subsystem for Linux (WSL) such as Ubuntu from
Windows Store
https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6?activetab=pivot:overviewtab
- sudo apt-get update
- sudo apt install g++, git, python3, python3-pip, cmake, cppcheck, emacs25, valgrind, cmake, gdb
- pip install cpplint
- Ubuntu can edit Windows files by accessing /mnt/c but Windows cannot access Ubuntu files -- learned it the hard way!
- Install CodeBlocks -- toolchain executables is in C:\msys64\mingw64\bin
- Download Unity Hub
- github for desktop
- Pin to Taskbar: Chrome, Emacs, Msys2, putty, powershell
- For emacs, edit properties to start runemacs from C:\msys64\mingw64\bin. Change emacs start directory to be c:\
- For Msys2, edit properties to run C:\msys64\msys2_shell.cmd