This repository contains code examples and lecture materials for Stanford CS106L, a course on Standard C++ programming. The code in this repository is meant to supplement the lectures and provide hands-on examples of the concepts discussed in class.
Before getting started, make sure you have the following installed:
- C++ Compiler: You will need a C++ compiler like GCC or Clang. You can check if you have one installed by running
g++ --versionin your terminal. - CMake: We will be using CMake to manage our build process. You can check if you have it installed by running
cmake --version. - Git: To download the lecture code, you'll need Git. You can check if you have it installed by running
git --version.
To download the lecture code, open up a terminal and run the following command:
git clone https://github.com/cs106l/cs106l-lecture-code.gitThis will download the code into a folder named cs106l-lecture-code.
If you're using VSCode, navigate into the folder and open it with:
cd cs106l-lecture-code && code .This will open the entire repository as a workspace in VSCode.
We will be using CMake to build the lecture code examples. Here's how you can set it up and build the project.
If you don't have CMake installed, you can follow the instructions here to download and install it for your operating system.
It's a good practice to create a separate directory for your build files. This keeps the source code clean and separates it from the generated build files. Run the following commands:
mkdir build
cd buildOnce you're inside the build directory, use CMake to generate the necessary build files. Assuming your CMakeLists.txt file is in the root of the repository, run:
cmake ..This command tells CMake to look in the parent directory (..) for the CMakeLists.txt file.
Once CMake has generated the build files, you can compile the project by running:
makeThis will compile the project and produce the executable files for the code examples.
After building the project, you can run the compiled code. For example, if your executable is named main, you can run it with:
./mainAs we update the lecture code, you can pull the latest changes by running:
git pull origin mainThis will fetch the latest lecture code examples.
Feel free to reach out if you have any issues or questions about the setup!