0% found this document useful (0 votes)
31 views1 page

GlewFromSrcFiles OpenGL Instruction

This document provides instructions for linking to the GLEW library in a CMake project. It describes downloading GLEW source files, copying them to the project directory, modifying one file, including the header file in source code, creating a static library target in CMake, and linking the executable to that target.

Uploaded by

Sahil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views1 page

GlewFromSrcFiles OpenGL Instruction

This document provides instructions for linking to the GLEW library in a CMake project. It describes downloading GLEW source files, copying them to the project directory, modifying one file, including the header file in source code, creating a static library target in CMake, and linking the executable to that target.

Uploaded by

Sahil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

https://stackoverflow.

com/questions/11027485/linking-to-glew-in-c

I want to extend the excellent @TheBuzzSaw's idea by providing a more detailed answer for
a cmake project.

1. Download GLEW sources from here.
2. Unzip the archive and copy two files (src/glew.c and include/GL/glew.h) into your
project's directory.
3. Edit glew.c so that the beginning of the file looks like this:
#ifndef GLEW_INCLUDE
#include "glew.h" /* Point to local glew.h file. */
#else
#include GLEW_INCLUDE
#endif
4. Use the following in your main.cpp file to include static GLEW correctly:
#define GLEW_STATIC
#include "glew.h"
5. To build the project, you must compile and link the static GLEW library.
Sample CMakeLists.txt file with the use of copied files:
cmake_minimum_required(VERSION 3.17)
project(your-project-name)

add_library(STATIC_GLEW glew.c)
add_executable(your-project-name main.cpp)

target_link_libraries(your-project-name STATIC_GLEW)
Now, you should be able to build your project without any linking errors

You might also like