0

I want to use the Ubunut/Linux Library libglfw (Glfw) with a Standard C++ Project, that uses CMake in Qt Creator. How do I do that? How do I have to include the Linked Library?

Edit: Actually I Include the libglfw (/usr/lib/lglfw.so) like

#include "GL/glfw.h" //That line works
int main(void) {
 GLFWwindow* window; //Just like in the GLFW-Example
 ...
}

And I get the error "GLFWwindow was not declared in this scope" and similar errors for each glfw-call

4

1 回答 1

1

您只需像编辑CMakeLists.txt任何其他 CMake 项目一样编辑您的项目。Qt Creator 不会在其之上增加任何复杂性。

对于 Glfw,您只需要添加

FIND_PACKAGE (glfw REQUIRED)
INCLUDE_DIRECTORIES (${GLFW_INCLUDE_DIR})
TARGET_LINK_LIBRARIES (${PROJECT_NAME} ${GLFW_LIBRARY})

请注意,这${PROJECT_NAME}是 Qt Creator 中添加的默认值,它只需要是add_executable()调用的第一个参数(当然是您想要链接 glfw 的可执行文件)。

之后,您应该能够在glfw的入门页面末尾获取代码示例并在您的项目中编译它,而不会出现问题来测试它是否有效。

于 2013-07-25T21:42:13.060 回答