1

I am trying to implement shaders and meshes. For doing so I need to link external libraries SDL2, GL, GLEW. I decided to write a CMake file to compile the source file and include the headers and link the required libraries, but it seems like external libraries are not getting linked since i am encountering errors.

Following is my cmake file

cmake_minimum_required(VERSION 3.0)

project(OpenGL)

include_directories(include)
file(GLOB_RECURSE SOURCES "src/*.cpp")

add_executable(Run ${SOURCES})

set(CMAKE_CXX_FLAGS "-g -lGL -lSDL2 -lGLEW")

How do I remove the linking errors ?

Gaurav Pant
  • 962
  • 10
  • 30
  • seems like you should tell cmake where to find libraries? Where are those libs located? – ErniBrown Aug 27 '18 at 15:18
  • 3
    Compiler flags are not for linking. Use `target_link_libraries(Run GL SDL2 GLEW)`. You probably also want to add `find_package` for these libraries. – keltar Aug 27 '18 at 15:29

0 Answers0