ОБНОВЛЕНИЕ Я перешел на систему сборки meson. Теперь все работает нормально!
Я новичок в использовании C ++, OpenGl и Gnome Builder. У меня очень простая основа работы с C ++, и я знаю, как связывать файлы заголовков и библиотеки в CodeLite, однако после того, как я возился с Gnome Builder, я хочу переключиться. Я не нашел удобных для новичков руководств по использованию Builder. Я просто не понимаю, как мне связывать внешние библиотеки в Builder. Я просто вручную редактирую Makefile или есть где-то настройка, которая автоматизирует процесс makefile с помощью automake? Я ошибаюсь, полагая, что это проблема с make-файлом? Приносим извинения, если это вопрос для новичков.
Я использую Ubuntu. Я получаю сообщение об ошибке «неопределенная ссылка на ...» для всех переменных и заголовков glfw и glew. После установки библиотек с помощью apt, мои библиотеки установлены в usr / lib / x86-64-linux-gnu, заголовки - в usr / include.
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
int main ()
{
glewExperimental = true;
if (!glfwInit() )
{
fprintf(stderr, "Failed to initialize GLFW \n");
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window;
window = glfwCreateWindow(1024, 768, "Tutorial 01", NULL, NULL);
if ( window == NULL )
{
fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. \n");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glewExperimental = true;
if (glewInit() != GLEW_OK)
{
fprintf(stderr, "Failed to Initialize GLEW. \n");
return -1;
}
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
do {
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
while ( glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && glfwWindowShouldClose(window) == 0);
return 0;
}
При попытке сборки я получаю этот вывод ошибки ~
g ++ -o практика -Wall -ggdb -fno-omit-frame-pointer -O2 Practice.cpp / usr / bin / ld: /tmp/ccLx11Ky.o: in function
main': /home/joe/Projects/practice/practice.cpp:30: undefined reference to
glewExperimental '/ usr / bin / ld: / home / joe /Projects/practice/practice.cpp:31: неопределенная ссылка наglfwInit' /usr/bin/ld: /home/joe/Projects/practice/practice.cpp:36: undefined reference to
glfwWindowHint '/ usr / bin / ld: /home/joe/Projects/practice/practice.cpp:37: неопределенная ссылка наglfwWindowHint' /usr/bin/ld: /home/joe/Projects/practice/practice.cpp:38: undefined reference to
glfwWindowHint' / usr / bin / ld: /home/joe/Projects/practice/practice.cpp:39: неопределенная ссылка наglfwWindowHint' /usr/bin/ld: /home/joe/Projects/practice/practice.cpp:40: undefined reference to
glfwWindowHint '/ usr / bin / ld: /home/joe/Projects/practice/practice.cpp:43: неопределенная ссылка наglfwCreateWindow' /usr/bin/ld: /home/joe/Projects/practice/practice.cpp:50: undefined reference to
glfwMakeContextCurrent' / usr / bin / ld: /home/joe/Projects/practice/practice.cpp:51: неопределенная ссылка наglewExperimental' /usr/bin/ld: /home/joe/Projects/practice/practice.cpp:52: undefined reference to
glewInit '/ usr / bin / ld: /home/joe/Projects/practice/practice.cpp:58: неопределенная ссылка наglfwSetInputMode' /usr/bin/ld: /home/joe/Projects/practice/practice.cpp:65: undefined reference to
glfwWindowShouldClose '/ usr / bin / ld: /home/joe/Projects/practice/practice.cpp:61: неопределенная ссылка наglClear' /usr/bin/ld: /home/joe/Projects/practice/practice.cpp:62: undefined reference to
glfwSwapBuffers' / usr / bin / ld: /home/joe/Projects/practice/practice.cpp:63: неопределенная ссылка наglfwPollEvents' /usr/bin/ld: /home/joe/Projects/practice/practice.cpp:65: undefined reference to
glfwGetKey '/ usr / bin / ld: / home / joe / Projects / Practice / Practice.cpp: 47: undefined ссылка на `glfwTerminate 'collect2: error: ld вернул 1 статус выхода make: *** [Makefile: 8: Practice] Ошибка 1
Мой Makefile по умолчанию выглядит следующим образом ~
all: practice
WARNINGS = -Wall
DEBUG = -ggdb -fno-omit-frame-pointer
OPTIMIZE = -O2
practice: Makefile practice.cpp
$(CXX) -o $@ $(WARNINGS) $(DEBUG) $(OPTIMIZE) practice.cpp
clean:
rm -f practice
# Builder will call this to install the application before running.
install:
echo "Installing is not supported"
# Builder uses this target to run your application.
run:
./practice