How do I setup Qt 6.2 on Linux Mint to use GLEW / GLFW
-
Hi,
Having spent a fruitless afternoon trying to find an answer to this, I'm hoping someone here can help.
I want to use GLFW / GLEW because I am following a course. (I am fully aware that Qt has it's own GL implementation)
I am assuming that I can use the Qt Creator IDE for this as I have used it in the past for non-Qt applications.I am using Qt 6.2 on Linux Mint 20.1, and everything works fine.
I downloaded GLFW and built it with the same GCC compiler that Qt uses. I now have a libglfw3.a file.I have copied the 2 header files to the include directory and they are found by the IDE.
What do I do with the compiled libglfw3.a file? I have put it in /usr/lib but the linker does not find it.
I am using Cmake for building, so how do I tell it where to find the library?I have read the Cmake documentation but it isn't much help. The same for the Qt documentation.
I am sure that this is a simple question but I just cannot find an answer anywhere. I have seen the question asked numerous times but no-one has answered the actual problem.The minimal 'hello world' application from the GLFW website compiles but won't link.
Thanks
-
Hi @Colins2
Here is some minimum CMake to add to your project which will link to the lib.
target_link_libraries(yourprojectname PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) //this should already exist in the auto generated cmake file target_link_libraries(yourprojectname PUBLIC libglfwbinary) //specify binary location here target_include_directories(mailman-server PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/../pathtolibglfwheaders" //specify header location )
from that you should be able to include your headers and cmake should know where the binary is when you compile.
Also consider making your library dynamic instead of static (.so extension instead of .a). If you don't know how look that up, but really not that critical for now.
-