Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Use Cmake to Get Binaries from Source Code

Learn how to use cmake to get binaries from source Code with clear steps, practical context, and useful troubleshooting guidance.

Table of Contents

This updated guide examines How to Use Cmake to Get Binaries from Source Code and organizes the essential facts, background, and practical takeaways in clear American English.

Method 1

Installing CMake

  1. How to Use Cmake to Get Binaries from Source Code — contextual image 1 Highlight what you expect to do. For example see picture above.
  2. How to Use Cmake to Get Binaries from Source Code — contextual image 2 Download CMake. Right-click on following address and select Open Link in New Window https://cmake.org/download/. Scroll down the page (see image above). Under "Latest Release (today is 3.16.2)" on the second "Platform" list, find "Windows win64-x64. ZIP" and click the beside entry (today is cmake-3.16.2-win64-x64.zip > in opening wizard select Save file .
  3. Copy and unzip the zip folder.
    • In downloading window, click folder > right click > in drop-down menu select Copy .
    • Navigate to directory C: > right click > select Paste .
    • When copying and unzipping (extracting files) is finished, double click unzip folder cmake-3.16.2-win64-x64 (or latest version) > 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: > cmake-3.16.2-win64-x64 (or latest version) > bin > double click file cmake-gui (the one with CMake's logo).

Method 2

Processing Source Code

  1. In directory C, create folder GL . In Windows File Explorer navigate to C: > inside, right click > select New > Folder > type: GL > hit?Enter.
  2. 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 .
  3. Copy and unzip folder.
    • In downloading window click zip folder glfw-3.3 (or latest version) > right click > select Copy .
    • Navigate to C: > GL > right click > select Paste .
    • Now in directory C:GL, you have unzip folder glfw-3.3 . Click twice on its name > delete name > type: glfw > hit?Enter.
  4. How to Use Cmake to Get Binaries from Source Code — contextual image 3 Where is the source code. In CMake GUI first text field. Copy C:/GL/glfw and paste.
  5. Where to build the binaries. In second text field. Copy C:/GL/glfw/build and paste.
  6. Configure and generate. In CMake GUI, clickConfigure> in wizard Create Directory clickYes> select Visual Studio 16 2019 > clickFinish.
    • When, in CMake GUI, you read: "Configuring done", clickGenerate. You should read: "Generating done".
    • Close CMake GUI.
  7. Build your solution.
    • Navigate to C: > GL > glfw > build. 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: XX succeeded, 0 failed, 0 up-to-date, 2 skipped" ==========
      • Number XX of "succeeded" changes in glfw versions. Today (31-12-2019) is 32.
    • Navigate to C: > GL > glfw > build > src > Debug. Inside you should see file glfw3.lib .

Method 3

Testing Binaries

  1. Create empty project. In V. S. main menu click File > New > Project… >Create a new project>Empty project>Next.
    • In Project name text box type: Project-0 .
    • Next to Location text box, click....
    • Navigate to C: > GL > Click Select a folder . The Location is C:GL.
    • Check box Place solution and project in the same directory .
    • ClickCreate.
  2. Add your source file to the Project. In Solution Explorer wizard, right click the Source Files folder (the last one) > click Add > New Item…
    • In the Add New Item - Project-0 window, click C++ File (.cpp) (the first one) from the middle of the window. In the Name text box, type Main.cpp .
    • The Location is C:GLProject-0.
    • Click theAddbutton. The file will open in the main text editor but leave it blank for now.
  3. Configure project's Properties . In Solution Explorer wizard, right click Project's name that is Project-0 > select Properties .
    • (1) Project-0 Property Pages main menu. In Platform entry select x64 > clickConfiguration Manager....
      • In Active solution platform: select x64 .
      • In Platform entry, x64 is automatically selected.
      • ClickClose.
    • (2) Additional Include Directories . Click C/C++ > General > In beside menu select the first one, Additional Include Directories > click the down arrow at the end of the field > click Edit... > first icon > three dots...
      • Navigate to C: > GL > glfw > include > click include > clickSelect a folder> clickOK.
    • (3) Additional Library Directories . Double click Linker > click General > Additional Library Directories > click the down arrow at the end of the field > click Edit... > first icon > three dots....
      • Navigate to C: > GL > glfw > build > src > Debug > clickSelect a folder> clickOK.
    • (4) Additional Dependencies . In Linker drop-down menu select Input > in beside menu select the first one, Additional Dependencies > click the down arrow at the end of the field > Edit... > copy opengl32.lib; glfw3.lib and paste in Additional Dependencies wizard's upper-most text box > clickOK.
    • (5) Set System to SubSystem CONSOLE. In Linker drop-down menu select System > in beside menu select the first one, SubSystem > click the down arrow at the end of the field > select Console (/SUBSYSTEM:CONSOLE) . ClickApplyandOK.
  4. Test code. Right-click on following address and select Open Link in New Window https://www.glfw.org/docs/3.0/quick.html > scroll down the page to last section: Putting it together: A small GLFW application , and copy code > go to Visual studio and paste it in Main.cpp code area. HitCtrl+F5. If everything gone well two windows appear: one black and other with a rotating colored triangle in black background. Good job.
  5. Correct any errors. In "Error List" if you see error about
    • file with extension.h go to Method 3, step 3, sub-step (2) and follow instructions.
    • file with extension.lib go Method 3, step 3, sub-step (3), and follow instructions. Also to sub-step (4).
    • "entry point must be defined" go to Method 3, step 3, sub-step (5), Set "SubSystem" to "CONSOLE" , and follow instructions.
    • For other errors, if you can't correct them, close Visual Studio > delete project folder Project-0 which lives in C:GL > open Visual Studio > repeat set up from part Method 2 .

FAQ

What is How to Use Cmake to Get Binaries from Source Code about?

It provides a structured overview of click, explains the main context, and highlights practical takeaways for readers.

Why does this topic matter?

Understanding the main concepts helps readers evaluate the issue, avoid common mistakes, and make better-informed decisions.

How should readers use this information?

Use the guidance as a practical starting point, confirm details that may have changed, and follow current product, safety, or security recommendations.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.