Я пытаюсь настроить приложение с glfw и glew для использования OpenGL в Ubuntu18.04.Я скопировал пример glew в исходный файл.Со всеми настройками я мог запустить приложение и увидеть белый треугольник на экране.Проблема:
Я не могу включить точки останова в исходном коде.Как только я начал отлаживать все установленные точки останова, стал grep / disabled с комментариями «Непроверенная точка останова».
Я думал, что в CMakeLists.txt установка set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Wall")
может решить проблему, но это не так.
Есть предложения?
среда: OS: Ubuntu 18.04
IDE: Visual Studio Code 1.33.1
cmake: 3.10.2
gdb: 8.2
gcc: 7.4
Я устанавливаю launch.json как:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "MapPoints",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/MapPoints",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
В случае, если мне нужно изменить другие настройки, я просто публикую их здесь. Вот мои задачи. Json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"options": {
"cwd": "${workspaceRoot}/build"
},
"tasks": [
{
"label": "cmake",
"type": "shell",
"command": "cmake",
"args": [".."],
"group": "build",
},
{
"label": "build",
"command": "cmake",
"args": ["--build", "."],
"group": {
"kind": "build",
"isDefault": true
},
}
]
}
Это CMakeLists.txt
#cmake --help-command-list
#cmake --help-variable-list
#cmake --help-property-list
cmake_minimum_required(VERSION 3.10)
project(MapPoints)
SET(SOURCE main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE})
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
include_directories(${GLFW_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${GLFW_LIBRARIES})
MESSAGE("project name: " ${PROJECT_NAME} )
MESSAGE("project src dir: " ${PROJECT_SOURCE_DIR} )
FOREACH(item ${GLFW3_STATIC_LIBRARIES})
MESSAGE(STATUS " using lib: " ${item})
ENDFOREACH()
find_package(GLEW REQUIRED)
if (GLEW_FOUND)
MESSAGE(STATUS " [Found GLEW library]")
MESSAGE(STATUS " GLEW include directory:" ${GLEW_INCLUDE_DIRS})
FOREACH(item ${GLEW_LIBRARIES})
MESSAGE(STATUS " using lib: " ${item})
ENDFOREACH()
include_directories(${GLEW_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${GLEW_LIBRARIES})
endif()
#link the local openGL driver library
find_package(OpenGL REQUIRED)
if (OPENGL_FOUND)
MESSAGE(STATUS " [Found OpenGL library]")
MESSAGE(STATUS " OpenGL include directory:" ${OPENGL_INCLUDE_DIR})
FOREACH(item ${OPENGL_LIBRARIES})
MESSAGE(STATUS " using lib: " ${item})
ENDFOREACH()
include_directories(${OPENGL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES})
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Wall")
# using c++17
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 17
CXX_EXTENSIONS OFF)
Источникфайл:
// sudo apt-get install libglfw3-dev libglfw3
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <GL/glut.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);
glBegin(GL_TRIANGLES);
glVertex2f(-0.5f, -0.5f);
glVertex2f(0.5f, -0.5f);
glVertex2f(0.0f, 0.5f);
glEnd();
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}