문제

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

도움이 되었습니까?

해결책

You just edit the CMakeLists.txt of your project like you would with any other CMake project. Qt Creator doesn't add any complexity on top of it.

For Glfw you should only have to add

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

Note that that ${PROJECT_NAME} is the default that is added in Qt Creator, it just needs to be whatever the first parameter of the add_executable() call is (of course of the executable that you want to link glfw to).

after that you should be able to just grab the code example at the end of the getting started page of glfw and compile that within your project without a problem to test if it worked.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top