Cmake link library target link error

本小妞迷上赌 提交于 2019-11-28 07:23:24
Zifre

The syntax for target_link_libraries is:

target_link_libraries(your_executable_name libraries_list)

And you don't have to add add_definition statements (target_link_libraries adds this options)

There are also some useful variables provided by OpenGL and GLEW packages.

Your CMakeLists.txt should be like:

cmake_minimum_required (VERSION 2.6)
project (test)

find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)

include_directories(${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS})

add_executable(test
    main.cpp
)

target_link_libraries(test ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES})

One important detail to keep in mind is to place the target_link_libraries after the add_executable (or add_library) line.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!