Using Libraries in C++ (Static Linking)

The Cherno · 501K views · 2017 · 18:43

Open on YouTube

C, C++, Rust, Go & systems languagesTesting, debugging & developer toolstutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering questions about unresolved or missing .lib files and include paths in Visual Studio, since it walks through the exact project property settings.

Recommended by 3 people across 3 different months, 2018 to 2025.

What it is

A Cherno tutorial in the C++ series on how to use third-party libraries by static linking in Visual Studio. It uses GLFW as the example and shows setting the include directories, library directories and linker inputs in the project settings.

What people said

Recommends Alfąs Noblik · 2018-07 · Stack Overflow · on “Calling fuctions from the .dll library using dynamic linking”

@V.Kravhcenko I've followed this tutorial: [this video] And I've added the paths and names in the VS settings in *Linker->general->Additional Library Directories*, *Linker->input->Additional Dependancies* and *C/C++->General->Additional Include Directories* in the way it was shown there.

Recommends Bipin Maharjan · 2021-05 · Stack Overflow · on “cannot open file 'SDL2.lib'”

Watch this video [this video] . In summary, you need to add the path of include folder here: (configuration properties> C/C++ > General> Additional Include Directories), [LINK] and add the path of the lib folder here: (configuration properties> Linker > General> Additional Library Directories) [LINK] and finally, link .lib file in: linker > input > Additional Dependencies. [LINK]

Recommends Light · 2021-09 · Stack Overflow · on “Visual Studio C++: Using static libraries produced by one project in another project”

Add plus and times to your main project as a reference: Right click on main project -> Add -> Reference... -> tick the plus and times projects Specify the paths to the header files of plus and times in your main project's additional include directories: Right click on main project -> Properties -> C/C++ -> General -> Additional Include Directories Read Also: Cherno: Using Libraries in C++ (Static Linking) [this video] Microsoft: Walkthrough: Create and use a static library [LINK] StackOverflow: How static libraries work? [LINK]

Cites mike · 2020-11 · Stack Overflow · on “I built an OpenCV project in C++ visual studio 2019 using static library, but still needs dll file at the run time”

I built an OpenCV project in C++ visual studio 2019 using static library: I made path to the lib file and also set Runtime Library (in project properties--> C\C++--> code generation) as Multi-Threaded/MT. Project is in Release mode. Also I made similar to the following video: [this video]

Cites Kris · 2025-05 · Stack Overflow · on “Glfw import looks weird but it works?”

I've followed This Tutorial [this video] to use glfw, and I got it to work, but my code looks a bit different than the video. This is my code: #include <iostream> #include <glfw3.h> int main() { std::cout << "Hello World!\n"; GLFWwindow* window; if (!glfwInit()) exit(EXIT_FAILURE); window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } while (true) { //stay running } } The part I want to focus on is #include <glfw3.h> . I've done the correct steps with linking and include, but for some reason, vscode doesn't recognize it when i type #include <GLFW/glfw3.h> . My code works how it is, it makes a window, but in the video it shows I ne