
views
Configuring Visual Studio
Highlight what you expect to do. Highlight step or sub-step you expect to do and then do it. See as example picture above.
Download Visual Studio 2022. If you have not done so you can download it from https://www.visualstudio.com/downloads. Check the Desktop development with C++ workload box as you download. If necessary scroll down the page. Click "Language pack" and check "English" box. Set Up SDL with Visual Studio 2017 Step 3 Version 2.jpg
Installing CMake
Compiling a library from the source code guarantees that the resulting library is perfectly tailored for your CPU/OS, a luxury pre-compiled binaries don't always provide. It is also important that binaries you get target x64 platform.
Create folders GL and GLP. Open Windows's File Explorer > Navigate to disk (directory) C. If folders GL and GLP exist it's okay. If they do not, right click in empty area > select New > Folder > type GL > hit ↵ Enter. By same way create folder GLP.
Download CMake. Right-click on following address and select Open Link in New Window https://cmake.org/download/. Scroll down the page and find "Latest Release (3.25.1)", (or latest). In second "Platform" list, find (see image above) "Windows x64 ZIP" and click the beside entry cmake-3.25.1-windows-x86_64.zip (or latest) > in opening wizard select Save file.
Copy and unzip the zip folder. If the downloaded folder doesn't contain line with stripes (unzipped folder) click it > right click > Copy. If downloaded folder's icon contains vertical line with stripes (zipped folder), double click it for get unzipped folder, (or alternatively, click folder > right click > in drop-down menu select Extract all). When unzipping (extracting files) is finished, click unzip folder cmake-3.25.1-windows-x86_64.zip (or latest) > right click > Copy. Go to drive (directory) C: > GL > right click > Paste. (Alternatively click folder "cmake-3.25.1-windows-x86_64" and drag into folder "GL"). When copying is finished click folder "cmake-3.25.1-windows-x86_64" > right click > select "Rename" > type CMake > hit ↵ Enter > double click it > double click folder bin > inside you should see CMake's logo next to file name cmake-gui > double click this file. If wizard "Windows protect your PC" appears, click More information > Run anyway. Now on your screen you have CMake GUI. Each time you need CMake, navigate to C:\ > GL > double click folder CMake > double click "bin" > double click file cmake-gui (the one with CMake's logo).
Processing Source Code
Download source code. As an example we use GLFW. Right-click on following address and select Open Link in New Window https://www.glfw.org/download.html. Select "Source package". In opened wizard select Save File.
Unzip and copy folder. In downloading window click zip folder glfw-3.3.8 (or latest) > if you get no stripped (unzipped) icon, it's okay. If not, right click > select Extract all. Copy unzip folder and paste in C:\GL. (Alternatively click downloaded folder and drag into folder C:\GL). Now in directory C:\GL, you have unzip folder glfw-3.3.8 (or latest). Click on its name > delete name > type: GLFWsrc > hit ↵ Enter > close downloading window.
Compile source code. See above image. Where is the source code. Copy (attention: do not copy any space)C:\GL\GLFWsrc and paste in CMake GUI first text field. Where to build the binaries. Copy (attention: do not copy any space)C:\GL\GLFWsrc\build an paste in second text field. Configure and generate. In CMake GUI, click Configure > in wizard Create Directory click Yes. Be sure you have downloaded Visual Studio 2022 > in wizard "Specify the generator for this project" , check whether visual studio version is 17 2022 > click Finish. When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done". If, instead, wizard "Error" is thrown, click OK > check whether you have downloaded visual studio 2022. If you have, in CMake GUI click "File" > click "Delete Cache" > in thrown wizard "Delete Cache", click Yes > close CMake GUI > open it again > repeat this step.
Build your solution. Copy C:\GL\GLFWsrc\build and paste in File Explorer Address Bar > hit ↵ Enter > Double click "GLFW.sln", or "GLFW", or "ALL_BUILD.vcxproj". An instance of Visual Studio appears. Wait until in main menu Build entry appears. Click it > "Build Solution". Wait till you read the last line in "Output" window: ========== Build: 32 succeeded, 0 failed, 0 up-to-date, 3 skipped" ========== Numbers of "succeeded" and "skipped" change in glfw versions. Today (12-Nov-2022) is 32 and 3 respectively. Copy C:\GL\GLFWsrc\build\src\Debug and paste in File Explorer Address Bar > hit ↵ Enter. You should see file glfw3.lib. Close cmake GUI.
Creating Project with compiled Binaries
Create empty project. See above image. Title "Visual Studio 2019" doesn't matter. . In Visual Studio main menu click File > New > Project… . In Create a new project wizard, select Empty Project> click Next. In Configure your new project wizard, In Project name text box type (or copy and paste): GLFWsrc-0 Copy C:\GLP and paste in Location text box . Check box Place solution and project in the same directory. Click Create.
Add your source file to the Project. See above image. Project's name in it is "SDLproject", but it doesn't matter. In Solution Explorer wizard, right click the Source Files folder (the last one) > click Add > New Item… In the Add New Item - GLFWsrc-0 wizard, click C++ File (.cpp) (the first one) from the middle of the window. In the Name text box, type Main.cpp. The Location should be C:\GLP\GLFWsrc-0. If it's not, copy C:\GLP\GLFWsrc-0 and paste. Click the Add button. The file will open in the text editor but leave it blank for now.
Testing project GLFWsrc-0 and Correcting errors
Test code. Right-click on following address and select Open Link in New Window https://www.glfw.org/docs/3.0/quick.html#quick_example > copy code > go to Visual Studio GUI and paste in Main.cpp code area. Hit Ctrl+F5. If everything gone well two windows appear: one black and other with a rotating colored triangle in black background. Good job.
Correct errors if any. Files are missing. Copy C:\GLP\GLFWsrc-0 and paste in File Explorer Address Bar. You should see file you added Main.cpp, and 4 other files added by Visual Studio. If they are missing you missed add file Main.cpp. Go to Part 3, step 2, and add it now. In "Error List" if you see error aboutUse CMake to Get Binaries from Source Code Step 15.jpg file with extension .h go to Part 3, step 3, sub-steps 1 and 2 and follow instructions. file with extension .lib go Part 3, step 3, sub-step 3, and follow instructions. Also to sub-step 4. "entry point must be defined" go to Part 3, step 3, sub-step 5. For other errors, if you can't correct them, close Visual Studio > delete project folder GLFWsrc-0 which lives in C:\GLP\ > open Visual Studio > repeat set up from Part 3.
Comments
0 comment