Привет всем! Столкнулся с проблемой - никак не удаётся скомпилировать базовый код отображения окна (для OpenGL проги). Ubuntu 17.04 (x64) CLion 2017.1.1
Устанавливал GLFW точно по инструкции: http://www.glfw.org/docs/latest/compile.html#compile_compile
Код программки:
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
Содержимое CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
project(opengl)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(opengl ${SOURCE_FILES})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread -fpermissive")
find_package (PkgConfig REQUIRED)
find_package (GLUT REQUIRED)
find_package(glfw3 3.2 REQUIRED)
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIRS} ${glfw3})
file(GLOB SOURCE_FILES
*.cpp
*.h
)
add_executable(main.cpp ${SOURCE_FILES})
target_link_libraries (main.cpp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} GL m dl Xinerama Xrandr Xi Xcursor X11 Xxf86vm pthread)
Получаемые ошибки компиляции:
CMakeFiles/opengl.dir/main.cpp.o: In function `main':
/home/efi/w/opengl/main.cpp:8: undefined reference to `glfwInit'
/home/efi/w/opengl/main.cpp:12: undefined reference to `glfwCreateWindow'
/home/efi/w/opengl/main.cpp:15: undefined reference to `glfwTerminate'
/home/efi/w/opengl/main.cpp:20: undefined reference to `glfwMakeContextCurrent'
/home/efi/w/opengl/main.cpp:23: undefined reference to `glfwWindowShouldClose'
/home/efi/w/opengl/main.cpp:26: undefined reference to `glClear'
/home/efi/w/opengl/main.cpp:29: undefined reference to `glfwSwapBuffers'
/home/efi/w/opengl/main.cpp:32: undefined reference to `glfwPollEvents'
/home/efi/w/opengl/main.cpp:35: undefined reference to `glfwTerminate'
collect2: error: ld returned 1 exit status
CMakeFiles/opengl.dir/build.make:94: recipe for target 'opengl' failed
make[3]: *** [opengl] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/opengl.dir/all' failed
make[2]: *** [CMakeFiles/opengl.dir/all] Error 2
CMakeFiles/Makefile2:116: recipe for target 'CMakeFiles/opengl.dir/rule' failed
make[1]: *** [CMakeFiles/opengl.dir/rule] Error 2
Makefile:131: recipe for target 'opengl' failed
make: *** [opengl] Error 2
Подозрения на ошибки CMakeLists.txt Есть идеи, как с этим бороться?