OpenGL: undefined reference to `gladLoadGLLoader'
## undefined reference to `gladLoadGLLoader'
```sh
[100%] Linking CXX executable example
CMakeFiles/example.dir/example.cpp.o: In function `main':
example.cpp:(.text+0xc7): undefined reference to `gladLoadGLLoader'
example.cpp:(.text+0x127): undefined reference to `glad_glClearColor'
example.cpp:(.text+0x150): undefined reference to `glad_glClear'
CMakeFiles/example.dir/example.cpp.o: In function `framebuffer_size_callback(GLFWwindow*, int, int)':
example.cpp:(.text+0x1ca): undefined reference to `glad_glViewport'
collect2: error: ld returned 1 exit status
CMakeFiles/example.dir/build.make:98: recipe for target 'example' failed
make[2]: *** [example] Error 1
```
## Solution
comple with glad.c
```sh
add_executable(example example.cpp glad.c)
```
## Reference
- https://discourse.glfw.org/t/error-compiling-simple-c-using-gcc/730
![yubao_blog_cover](https://raw.githubusercontent.com/yubaoliu/assets/image/yubao_blog_cover.png)
No comments